mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 16:23:09 +02:00
add full support for multiple users
This commit is contained in:
@@ -26,7 +26,8 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity android:name="com.health.openscale.gui.SettingsActivity"></activity>
|
<activity android:name="com.health.openscale.gui.SettingsActivity"></activity>
|
||||||
<activity android:name="com.health.openscale.gui.NewEntryActivity" android:theme="@android:style/Theme.Holo.Dialog" android:label="New Scale Data Entry"></activity>
|
<activity android:name="com.health.openscale.gui.NewEntryActivity" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/title_new_data_entry"></activity>
|
||||||
|
<activity android:name=".gui.UserSettingsActivity" android:theme="@android:style/Theme.Holo.Dialog" android:label="@string/title_user"></activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -17,8 +17,10 @@
|
|||||||
package com.health.openscale.core;
|
package com.health.openscale.core;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@@ -31,22 +33,29 @@ import java.io.OutputStreamWriter;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class OpenScale {
|
public class OpenScale {
|
||||||
|
|
||||||
private static OpenScale instance;
|
private static OpenScale instance;
|
||||||
|
|
||||||
private ScaleDatabase scaleDB;
|
private ScaleDatabase scaleDB;
|
||||||
private ArrayList<ScaleData> scaleDBEntries;
|
private ScaleUserDatabase scaleUserDB;
|
||||||
|
private ArrayList<ScaleData> scaleDataList;
|
||||||
|
|
||||||
private BluetoothCommunication btCom;
|
private BluetoothCommunication btCom;
|
||||||
private String btDeviceName;
|
private String btDeviceName;
|
||||||
|
|
||||||
private SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
private SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
private OpenScale(Context con) {
|
private OpenScale(Context con) {
|
||||||
scaleDB = new ScaleDatabase(con);
|
context = con;
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
scaleDB = new ScaleDatabase(context);
|
||||||
|
scaleUserDB = new ScaleUserDatabase(context);
|
||||||
|
|
||||||
|
updateScaleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OpenScale getInstance(Context con) {
|
public static OpenScale getInstance(Context con) {
|
||||||
@@ -57,8 +66,79 @@ public class OpenScale {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ScaleData> getScaleDBEntries() {
|
public void addScaleUser(String name, String birthday, int body_height, int scale_unit)
|
||||||
return scaleDBEntries;
|
{
|
||||||
|
ScaleUser scaleUser = new ScaleUser();
|
||||||
|
|
||||||
|
try {
|
||||||
|
scaleUser.user_name = name;
|
||||||
|
scaleUser.birthday = new SimpleDateFormat("dd.MM.yyyy").parse(birthday);
|
||||||
|
scaleUser.body_height = body_height;
|
||||||
|
scaleUser.scale_unit = scale_unit;
|
||||||
|
|
||||||
|
} catch (ParseException e) {
|
||||||
|
Log.e("OpenScale", "Can't parse date time string while adding to the database");
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleUserDB.insertEntry(scaleUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ScaleUser> getScaleUserList()
|
||||||
|
{
|
||||||
|
updateScaleData();
|
||||||
|
|
||||||
|
return scaleUserDB.getScaleUserList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScaleUser getScaleUser(int userId)
|
||||||
|
{
|
||||||
|
return scaleUserDB.getScaleUser(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScaleUser getSelectedScaleUser()
|
||||||
|
{
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
if (selectedUserId == -1) {
|
||||||
|
ScaleUser scaleUser = new ScaleUser();
|
||||||
|
|
||||||
|
scaleUser.id = -1;
|
||||||
|
scaleUser.user_name = "anonymous";
|
||||||
|
scaleUser.birthday = new Date();
|
||||||
|
scaleUser.scale_unit = 1;
|
||||||
|
scaleUser.body_height = 1;
|
||||||
|
|
||||||
|
return scaleUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
return scaleUserDB.getScaleUser(selectedUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteScaleUser(int id)
|
||||||
|
{
|
||||||
|
scaleUserDB.deleteEntry(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateScaleUser(int id, String name, String birthday, int body_height, int scale_unit)
|
||||||
|
{
|
||||||
|
ScaleUser scaleUser = new ScaleUser();
|
||||||
|
|
||||||
|
try {
|
||||||
|
scaleUser.id = id;
|
||||||
|
scaleUser.user_name = name;
|
||||||
|
scaleUser.birthday = new SimpleDateFormat("dd.MM.yyyy").parse(birthday);
|
||||||
|
scaleUser.body_height = body_height;
|
||||||
|
scaleUser.scale_unit = scale_unit;
|
||||||
|
} catch (ParseException e) {
|
||||||
|
Log.e("OpenScale", "Can't parse date time string while adding to the database");
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleUserDB.updateScaleUser(scaleUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ScaleData> getScaleDataList() {
|
||||||
|
return scaleDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addScaleData(int user_id, String date_time, float weight, float fat,
|
public void addScaleData(int user_id, String date_time, float weight, float fat,
|
||||||
@@ -78,14 +158,14 @@ public class OpenScale {
|
|||||||
|
|
||||||
scaleDB.insertEntry(scaleData);
|
scaleDB.insertEntry(scaleData);
|
||||||
|
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
updateScaleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteScaleData(long id)
|
public void deleteScaleData(long id)
|
||||||
{
|
{
|
||||||
scaleDB.deleteEntry(id);
|
scaleDB.deleteEntry(id);
|
||||||
|
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
updateScaleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importData(String filename) throws IOException {
|
public void importData(String filename) throws IOException {
|
||||||
@@ -104,12 +184,13 @@ public class OpenScale {
|
|||||||
|
|
||||||
ScaleData newScaleData = new ScaleData();
|
ScaleData newScaleData = new ScaleData();
|
||||||
|
|
||||||
newScaleData.user_id = Integer.parseInt(csvField[0]);
|
newScaleData.date_time = dateTimeFormat.parse(csvField[0]);
|
||||||
newScaleData.date_time = dateTimeFormat.parse(csvField[1]);
|
newScaleData.weight = Float.parseFloat(csvField[1]);
|
||||||
newScaleData.weight = Float.parseFloat(csvField[2]);
|
newScaleData.fat = Float.parseFloat(csvField[2]);
|
||||||
newScaleData.fat = Float.parseFloat(csvField[3]);
|
newScaleData.water = Float.parseFloat(csvField[3]);
|
||||||
newScaleData.water = Float.parseFloat(csvField[4]);
|
newScaleData.muscle = Float.parseFloat(csvField[4]);
|
||||||
newScaleData.muscle = Float.parseFloat(csvField[5]);
|
|
||||||
|
newScaleData.user_id = getSelectedScaleUser().id;
|
||||||
|
|
||||||
scaleDB.insertEntry(newScaleData);
|
scaleDB.insertEntry(newScaleData);
|
||||||
|
|
||||||
@@ -120,7 +201,7 @@ public class OpenScale {
|
|||||||
throw new IOException("Can't parse date format. Please set the date time format as <dd.MM.yyyy HH:mm> (e.g. 31.10.2014 05:23)");
|
throw new IOException("Can't parse date format. Please set the date time format as <dd.MM.yyyy HH:mm> (e.g. 31.10.2014 05:23)");
|
||||||
}
|
}
|
||||||
|
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
updateScaleData();
|
||||||
|
|
||||||
csvReader.close();
|
csvReader.close();
|
||||||
inputReader.close();
|
inputReader.close();
|
||||||
@@ -134,8 +215,7 @@ public class OpenScale {
|
|||||||
|
|
||||||
OutputStreamWriter csvWriter = new OutputStreamWriter(outputStream);
|
OutputStreamWriter csvWriter = new OutputStreamWriter(outputStream);
|
||||||
|
|
||||||
for (ScaleData scaleData : scaleDBEntries) {
|
for (ScaleData scaleData : scaleDataList) {
|
||||||
csvWriter.append(Integer.toString(scaleData.user_id) + ",");
|
|
||||||
csvWriter.append(dateTimeFormat.format(scaleData.date_time) + ",");
|
csvWriter.append(dateTimeFormat.format(scaleData.date_time) + ",");
|
||||||
csvWriter.append(Float.toString(scaleData.weight) + ",");
|
csvWriter.append(Float.toString(scaleData.weight) + ",");
|
||||||
csvWriter.append(Float.toString(scaleData.fat) + ",");
|
csvWriter.append(Float.toString(scaleData.fat) + ",");
|
||||||
@@ -144,26 +224,39 @@ public class OpenScale {
|
|||||||
csvWriter.append("\n");
|
csvWriter.append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
csvWriter.close();
|
csvWriter.close();
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAllDBEntries() {
|
public void clearScaleData() {
|
||||||
scaleDB.deleteAllEntries();
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
scaleDB.clearScaleData(selectedUserId);
|
||||||
|
|
||||||
|
updateScaleData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getCountsOfMonth(int year) {
|
public int[] getCountsOfMonth(int year) {
|
||||||
return scaleDB.getCountsOfAllMonth(year);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
return scaleDB.getCountsOfAllMonth(selectedUserId, year);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ScaleData> getAllDataOfMonth(int year, int month) {
|
public ArrayList<ScaleData> getScaleDataOfMonth(int year, int month) {
|
||||||
return scaleDB.getAllDBEntriesOfMonth(year, month);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
return scaleDB.getScaleDataOfMonth(selectedUserId, year, month);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxValueOfDBEntries(int year, int month) {
|
public float getMaxValueOfScaleData(int year, int month) {
|
||||||
return scaleDB.getMaxValueOfDBEntries(year, month);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
return scaleDB.getMaxValueOfScaleData(selectedUserId, year, month);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startBluetoothServer(String deviceName) {
|
public void startBluetoothServer(String deviceName) {
|
||||||
@@ -199,7 +292,7 @@ public class OpenScale {
|
|||||||
parseBtString(line);
|
parseBtString(line);
|
||||||
break;
|
break;
|
||||||
case BluetoothCommunication.BT_SOCKET_CLOSED:
|
case BluetoothCommunication.BT_SOCKET_CLOSED:
|
||||||
scaleDBEntries = scaleDB.getAllDBEntries();
|
updateScaleData();
|
||||||
|
|
||||||
Log.d("OpenScale", "Socket closed! Restarting socket ");
|
Log.d("OpenScale", "Socket closed! Restarting socket ");
|
||||||
|
|
||||||
@@ -279,4 +372,12 @@ public class OpenScale {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateScaleData()
|
||||||
|
{
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
scaleDataList = scaleDB.getScaleDataList(selectedUserId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
"CREATE TABLE " + TABLE_NAME + " (" +
|
"CREATE TABLE " + TABLE_NAME + " (" +
|
||||||
COLUMN_NAME_ID + " INTEGER PRIMARY KEY," +
|
COLUMN_NAME_ID + " INTEGER PRIMARY KEY," +
|
||||||
COLUMN_NAME_USER_ID + " INTEGER," +
|
COLUMN_NAME_USER_ID + " INTEGER," +
|
||||||
COLUMN_NAME_DATE_TIME + " TEXT UNIQUE," +
|
COLUMN_NAME_DATE_TIME + " TEXT," +
|
||||||
COLUMN_NAME_WEIGHT + " REAL," +
|
COLUMN_NAME_WEIGHT + " REAL," +
|
||||||
COLUMN_NAME_FAT + " REAL," +
|
COLUMN_NAME_FAT + " REAL," +
|
||||||
COLUMN_NAME_WATER + " REAL," +
|
COLUMN_NAME_WATER + " REAL," +
|
||||||
@@ -74,17 +74,17 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
onCreate(db);
|
onCreate(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAllEntries() {
|
public void clearScaleData(int userId) {
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
db.delete(TABLE_NAME, null, null);
|
db.delete(TABLE_NAME, COLUMN_NAME_USER_ID + "=" + Integer.toString(userId), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean insertEntry(ScaleData scaleData) {
|
public boolean insertEntry(ScaleData scaleData) {
|
||||||
SQLiteDatabase db = getWritableDatabase();
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
Cursor cursorScaleDB = db.query(TABLE_NAME, new String[] {COLUMN_NAME_DATE_TIME}, COLUMN_NAME_DATE_TIME + " = ?",
|
Cursor cursorScaleDB = db.query(TABLE_NAME, new String[] {COLUMN_NAME_DATE_TIME}, COLUMN_NAME_DATE_TIME + "=? AND " + COLUMN_NAME_USER_ID + "=?",
|
||||||
new String[] {formatDateTime.format(scaleData.date_time)}, null, null, null);
|
new String[] {formatDateTime.format(scaleData.date_time), Integer.toString(scaleData.user_id)}, null, null, null);
|
||||||
|
|
||||||
if (cursorScaleDB.getCount() > 0) {
|
if (cursorScaleDB.getCount() > 0) {
|
||||||
// we don't want double entries
|
// we don't want double entries
|
||||||
@@ -118,7 +118,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
db.delete(TABLE_NAME, COLUMN_NAME_ID + "= ?", new String[] {String.valueOf(id)});
|
db.delete(TABLE_NAME, COLUMN_NAME_ID + "= ?", new String[] {String.valueOf(id)});
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getCountsOfAllMonth(int year) {
|
public int[] getCountsOfAllMonth(int userId, int year) {
|
||||||
int [] numOfMonth = new int[12];
|
int [] numOfMonth = new int[12];
|
||||||
|
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
@@ -134,8 +134,8 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
Cursor cursorScaleDB = db.query(
|
Cursor cursorScaleDB = db.query(
|
||||||
TABLE_NAME, // The table to query
|
TABLE_NAME, // The table to query
|
||||||
new String[]{"count(*)"}, // The columns to return
|
new String[]{"count(*)"}, // The columns to return
|
||||||
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? ", // The columns for the WHERE clause
|
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? AND " + COLUMN_NAME_USER_ID + "=?", // The columns for the WHERE clause
|
||||||
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime())}, // The values for the WHERE clause
|
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime()), Integer.toString(userId)}, // The values for the WHERE clause
|
||||||
null, // don't group the rows
|
null, // don't group the rows
|
||||||
null, // don't filter by row groups
|
null, // don't filter by row groups
|
||||||
null // The sort order
|
null // The sort order
|
||||||
@@ -149,7 +149,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
return numOfMonth;
|
return numOfMonth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxValueOfDBEntries(int year, int month) {
|
public float getMaxValueOfScaleData(int userId, int year, int month) {
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
|
||||||
Calendar start_cal = Calendar.getInstance();
|
Calendar start_cal = Calendar.getInstance();
|
||||||
@@ -169,8 +169,8 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
Cursor cursorScaleDB = db.query(
|
Cursor cursorScaleDB = db.query(
|
||||||
TABLE_NAME, // The table to query
|
TABLE_NAME, // The table to query
|
||||||
projection, // The columns to return
|
projection, // The columns to return
|
||||||
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? ", // The columns for the WHERE clause
|
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? AND " + COLUMN_NAME_USER_ID + "=?", // The columns for the WHERE clause
|
||||||
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime())}, // The values for the WHERE clause
|
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime()), Integer.toString(userId)}, // The values for the WHERE clause
|
||||||
null, // don't group the rows
|
null, // don't group the rows
|
||||||
null, // don't filter by row groups
|
null, // don't filter by row groups
|
||||||
null // The sort order
|
null // The sort order
|
||||||
@@ -192,9 +192,9 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<ScaleData> getAllDBEntriesOfMonth(int year, int month) {
|
public ArrayList<ScaleData> getScaleDataOfMonth(int userId, int year, int month) {
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
ArrayList<ScaleData> scaleDBEntries = new ArrayList<ScaleData>();
|
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
|
||||||
|
|
||||||
String[] projection = {
|
String[] projection = {
|
||||||
COLUMN_NAME_ID,
|
COLUMN_NAME_ID,
|
||||||
@@ -218,8 +218,8 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
Cursor cursorScaleDB = db.query(
|
Cursor cursorScaleDB = db.query(
|
||||||
TABLE_NAME, // The table to query
|
TABLE_NAME, // The table to query
|
||||||
projection, // The columns to return
|
projection, // The columns to return
|
||||||
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? ", // The columns for the WHERE clause
|
COLUMN_NAME_DATE_TIME + " >= ? AND " + COLUMN_NAME_DATE_TIME + " < ? AND " + COLUMN_NAME_USER_ID + "=?", // The columns for the WHERE clause
|
||||||
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime())}, // The values for the WHERE clause
|
new String[]{formatDateTime.format(start_cal.getTime()), formatDateTime.format(end_cal.getTime()), Integer.toString(userId)}, // The values for the WHERE clause
|
||||||
null, // don't group the rows
|
null, // don't group the rows
|
||||||
null, // don't filter by row groups
|
null, // don't filter by row groups
|
||||||
sortOrder // The sort order
|
sortOrder // The sort order
|
||||||
@@ -229,19 +229,19 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
cursorScaleDB.moveToFirst();
|
cursorScaleDB.moveToFirst();
|
||||||
|
|
||||||
while (!cursorScaleDB.isAfterLast()) {
|
while (!cursorScaleDB.isAfterLast()) {
|
||||||
ScaleData dataEntry = new ScaleData();
|
ScaleData scaleData = new ScaleData();
|
||||||
|
|
||||||
dataEntry.id = cursorScaleDB.getLong(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
scaleData.id = cursorScaleDB.getLong(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
||||||
dataEntry.user_id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_ID));
|
scaleData.user_id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_ID));
|
||||||
String date_time = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
|
String date_time = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
|
||||||
dataEntry.weight = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT));
|
scaleData.weight = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT));
|
||||||
dataEntry.fat = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_FAT));
|
scaleData.fat = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_FAT));
|
||||||
dataEntry.water = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WATER));
|
scaleData.water = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WATER));
|
||||||
dataEntry.muscle = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE));
|
scaleData.muscle = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE));
|
||||||
|
|
||||||
dataEntry.date_time = formatDateTime.parse(date_time);
|
scaleData.date_time = formatDateTime.parse(date_time);
|
||||||
|
|
||||||
scaleDBEntries.add(dataEntry);
|
scaleDataList.add(scaleData);
|
||||||
|
|
||||||
cursorScaleDB.moveToNext();
|
cursorScaleDB.moveToNext();
|
||||||
}
|
}
|
||||||
@@ -252,12 +252,12 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
|
Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return scaleDBEntries;
|
return scaleDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ScaleData> getAllDBEntries() {
|
public ArrayList<ScaleData> getScaleDataList(int userId) {
|
||||||
SQLiteDatabase db = getReadableDatabase();
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
ArrayList<ScaleData> scaleDBEntries = new ArrayList<ScaleData>();
|
ArrayList<ScaleData> scaleDataList = new ArrayList<ScaleData>();
|
||||||
|
|
||||||
String[] projection = {
|
String[] projection = {
|
||||||
COLUMN_NAME_ID,
|
COLUMN_NAME_ID,
|
||||||
@@ -274,8 +274,8 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
Cursor cursorScaleDB = db.query(
|
Cursor cursorScaleDB = db.query(
|
||||||
TABLE_NAME, // The table to query
|
TABLE_NAME, // The table to query
|
||||||
projection, // The columns to return
|
projection, // The columns to return
|
||||||
null, // The columns for the WHERE clause
|
COLUMN_NAME_USER_ID + "=?", // The columns for the WHERE clause
|
||||||
null, // The values for the WHERE clause
|
new String[]{Integer.toString(userId)}, // The values for the WHERE clause
|
||||||
null, // don't group the rows
|
null, // don't group the rows
|
||||||
null, // don't filter by row groups
|
null, // don't filter by row groups
|
||||||
sortOrder // The sort order
|
sortOrder // The sort order
|
||||||
@@ -285,19 +285,19 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
cursorScaleDB.moveToFirst();
|
cursorScaleDB.moveToFirst();
|
||||||
|
|
||||||
while (!cursorScaleDB.isAfterLast()) {
|
while (!cursorScaleDB.isAfterLast()) {
|
||||||
ScaleData dataEntry = new ScaleData();
|
ScaleData scaleData = new ScaleData();
|
||||||
|
|
||||||
dataEntry.id = cursorScaleDB.getLong(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
scaleData.id = cursorScaleDB.getLong(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
||||||
dataEntry.user_id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_ID));
|
scaleData.user_id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_ID));
|
||||||
String date_time = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
|
String date_time = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
|
||||||
dataEntry.weight = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT));
|
scaleData.weight = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT));
|
||||||
dataEntry.fat = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_FAT));
|
scaleData.fat = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_FAT));
|
||||||
dataEntry.water = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WATER));
|
scaleData.water = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WATER));
|
||||||
dataEntry.muscle = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE));
|
scaleData.muscle = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE));
|
||||||
|
|
||||||
dataEntry.date_time = formatDateTime.parse(date_time);
|
scaleData.date_time = formatDateTime.parse(date_time);
|
||||||
|
|
||||||
scaleDBEntries.add(dataEntry);
|
scaleDataList.add(scaleData);
|
||||||
|
|
||||||
cursorScaleDB.moveToNext();
|
cursorScaleDB.moveToNext();
|
||||||
}
|
}
|
||||||
@@ -309,6 +309,6 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return scaleDBEntries;
|
return scaleDataList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,35 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.health.openscale.core;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class ScaleUser {
|
||||||
|
public static final String[] UNIT_STRING = new String[] {"kg", "lb", "st"};
|
||||||
|
|
||||||
|
public int id;
|
||||||
|
public String user_name;
|
||||||
|
public Date birthday;
|
||||||
|
public int body_height;
|
||||||
|
public int scale_unit;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "ID : " + id + " NAME: " + user_name + " BIRTHDAY: " + birthday.toString() + " BODY_HEIGHT: " + body_height + " SCALE_UNIT: " + UNIT_STRING[scale_unit];
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,217 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.health.openscale.core;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.SQLException;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class ScaleUserDatabase extends SQLiteOpenHelper {
|
||||||
|
private static final int DATABASE_VERSION = 1;
|
||||||
|
private static final String DATABASE_NAME = "openScaleUserDatabase.db";
|
||||||
|
|
||||||
|
private static final String TABLE_NAME = "scaleuserdata";
|
||||||
|
private static final String COLUMN_NAME_ID = "id";
|
||||||
|
private static final String COLUMN_NAME_USER_NAME = "user_name";
|
||||||
|
private static final String COLUMN_NAME_BIRTHDAY = "birthday";
|
||||||
|
private static final String COLUMN_NAME_BODY_HEIGHT = "body_height";
|
||||||
|
private static final String COLUMN_NAME_SCALE_UNIT = "scale_unit";
|
||||||
|
|
||||||
|
private static final String SQL_CREATE_ENTRIES =
|
||||||
|
"CREATE TABLE " + TABLE_NAME + " (" +
|
||||||
|
COLUMN_NAME_ID + " INTEGER PRIMARY KEY," +
|
||||||
|
COLUMN_NAME_USER_NAME + " TEXT," +
|
||||||
|
COLUMN_NAME_BIRTHDAY + " TEXT," +
|
||||||
|
COLUMN_NAME_BODY_HEIGHT + " INTEGER," +
|
||||||
|
COLUMN_NAME_SCALE_UNIT + " INTEGER" +
|
||||||
|
")";
|
||||||
|
|
||||||
|
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 ScaleUserDatabase(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 clearDatabase() {
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
|
db.delete(TABLE_NAME, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean insertEntry(ScaleUser scaleUser) {
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_NAME_USER_NAME, scaleUser.user_name);
|
||||||
|
values.put(COLUMN_NAME_BIRTHDAY, formatDateTime.format(scaleUser.birthday));
|
||||||
|
values.put(COLUMN_NAME_BODY_HEIGHT, scaleUser.body_height);
|
||||||
|
values.put(COLUMN_NAME_SCALE_UNIT, scaleUser.scale_unit);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.insertOrThrow(TABLE_NAME, null, values);
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
Log.e("ScaleUserDatabase", "An error occured while inserting a new entry into the scale user database: " + e.toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEntry(int id) {
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
|
db.delete(TABLE_NAME, COLUMN_NAME_ID + "= ?", new String[] {String.valueOf(id)});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateScaleUser(ScaleUser scaleUser)
|
||||||
|
{
|
||||||
|
SQLiteDatabase db = getWritableDatabase();
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(COLUMN_NAME_USER_NAME, scaleUser.user_name);
|
||||||
|
values.put(COLUMN_NAME_BIRTHDAY, formatDateTime.format(scaleUser.birthday));
|
||||||
|
values.put(COLUMN_NAME_BODY_HEIGHT, scaleUser.body_height);
|
||||||
|
values.put(COLUMN_NAME_SCALE_UNIT, scaleUser.scale_unit);
|
||||||
|
|
||||||
|
db.update(TABLE_NAME, values, COLUMN_NAME_ID + "=" + scaleUser.id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScaleUser getScaleUser(int id)
|
||||||
|
{
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
ScaleUser scaleUser = new ScaleUser();
|
||||||
|
|
||||||
|
String[] projection = {
|
||||||
|
COLUMN_NAME_ID,
|
||||||
|
COLUMN_NAME_USER_NAME,
|
||||||
|
COLUMN_NAME_BIRTHDAY,
|
||||||
|
COLUMN_NAME_BODY_HEIGHT,
|
||||||
|
COLUMN_NAME_SCALE_UNIT
|
||||||
|
};
|
||||||
|
|
||||||
|
Cursor cursorScaleDB = db.query(
|
||||||
|
TABLE_NAME, // The table to query
|
||||||
|
projection, // The columns to return
|
||||||
|
COLUMN_NAME_ID + "=?", // The columns for the WHERE clause
|
||||||
|
new String[] {Integer.toString(id)}, // The values for the WHERE clause
|
||||||
|
null, // don't group the rows
|
||||||
|
null, // don't filter by row groups
|
||||||
|
null // The sort order
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
cursorScaleDB.moveToFirst();
|
||||||
|
|
||||||
|
scaleUser.id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
||||||
|
scaleUser.user_name = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_NAME));
|
||||||
|
String birthday = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_BIRTHDAY));
|
||||||
|
scaleUser.body_height = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_BODY_HEIGHT));
|
||||||
|
scaleUser.scale_unit = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_SCALE_UNIT));
|
||||||
|
|
||||||
|
scaleUser.birthday = formatDateTime.parse(birthday);
|
||||||
|
|
||||||
|
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 scaleUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<ScaleUser> getScaleUserList() {
|
||||||
|
SQLiteDatabase db = getReadableDatabase();
|
||||||
|
ArrayList<ScaleUser> scaleUserDBEntries = new ArrayList<ScaleUser>();
|
||||||
|
|
||||||
|
String[] projection = {
|
||||||
|
COLUMN_NAME_ID,
|
||||||
|
COLUMN_NAME_USER_NAME,
|
||||||
|
COLUMN_NAME_BIRTHDAY,
|
||||||
|
COLUMN_NAME_BODY_HEIGHT,
|
||||||
|
COLUMN_NAME_SCALE_UNIT
|
||||||
|
};
|
||||||
|
|
||||||
|
String sortOrder = COLUMN_NAME_ID + " 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()) {
|
||||||
|
ScaleUser scaleUser = new ScaleUser();
|
||||||
|
|
||||||
|
scaleUser.id = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
|
||||||
|
scaleUser.user_name = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_USER_NAME));
|
||||||
|
String birthday = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_BIRTHDAY));
|
||||||
|
scaleUser.body_height = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_BODY_HEIGHT));
|
||||||
|
scaleUser.scale_unit = cursorScaleDB.getInt(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_SCALE_UNIT));
|
||||||
|
|
||||||
|
scaleUser.birthday = formatDateTime.parse(birthday);
|
||||||
|
|
||||||
|
scaleUserDBEntries.add(scaleUser);
|
||||||
|
|
||||||
|
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 scaleUserDBEntries;
|
||||||
|
}
|
||||||
|
}
|
@@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
package com.health.openscale.gui;
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.health.openscale.core.ScaleData;
|
import com.health.openscale.core.ScaleData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public interface FragmentUpdateListener {
|
public interface FragmentUpdateListener {
|
||||||
public void updateOnView(ArrayList<ScaleData> scaleDBEntries);
|
public void updateOnView(ArrayList<ScaleData> scaleDataList);
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import android.widget.Toast;
|
|||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.OpenScale;
|
import com.health.openscale.core.OpenScale;
|
||||||
import com.health.openscale.core.ScaleData;
|
import com.health.openscale.core.ScaleData;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -63,7 +64,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
|
|
||||||
private Calendar yearCal;
|
private Calendar yearCal;
|
||||||
|
|
||||||
private ArrayList<ScaleData> scaleDBEntries;
|
private ArrayList<ScaleData> scaleDataList;
|
||||||
|
|
||||||
private enum lines {WEIGHT, FAT, WATER, MUSCLE}
|
private enum lines {WEIGHT, FAT, WATER, MUSCLE}
|
||||||
private ArrayList<lines> activeLines;
|
private ArrayList<lines> activeLines;
|
||||||
@@ -109,15 +110,15 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOnView(ArrayList<ScaleData> scaleDBEntries)
|
public void updateOnView(ArrayList<ScaleData> scaleDataList)
|
||||||
{
|
{
|
||||||
generateColumnData();
|
generateColumnData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateLineData(Calendar cal)
|
private void generateLineData(Calendar cal)
|
||||||
{
|
{
|
||||||
scaleDBEntries = openScale.getAllDataOfMonth(yearCal.get(Calendar.YEAR), cal.get(Calendar.MONTH));
|
scaleDataList = openScale.getScaleDataOfMonth(yearCal.get(Calendar.YEAR), cal.get(Calendar.MONTH));
|
||||||
float maxValue = openScale.getMaxValueOfDBEntries(yearCal.get(Calendar.YEAR), cal.get(Calendar.MONTH));
|
float maxValue = openScale.getMaxValueOfScaleData(yearCal.get(Calendar.YEAR), cal.get(Calendar.MONTH));
|
||||||
|
|
||||||
SimpleDateFormat day_date = new SimpleDateFormat("dd", Locale.getDefault());
|
SimpleDateFormat day_date = new SimpleDateFormat("dd", Locale.getDefault());
|
||||||
|
|
||||||
@@ -142,7 +143,7 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
|
|
||||||
Calendar calDB = Calendar.getInstance();
|
Calendar calDB = Calendar.getInstance();
|
||||||
|
|
||||||
for(ScaleData scaleEntry: scaleDBEntries)
|
for(ScaleData scaleEntry: scaleDataList)
|
||||||
{
|
{
|
||||||
calDB.setTime(scaleEntry.date_time);
|
calDB.setTime(scaleEntry.date_time);
|
||||||
|
|
||||||
@@ -280,23 +281,23 @@ public class GraphFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
private class ChartTopValueTouchListener implements LineChartView.LineChartOnValueTouchListener {
|
private class ChartTopValueTouchListener implements LineChartView.LineChartOnValueTouchListener {
|
||||||
@Override
|
@Override
|
||||||
public void onValueTouched(int lineIndex, int pointIndex, PointValue pointValue) {
|
public void onValueTouched(int lineIndex, int pointIndex, PointValue pointValue) {
|
||||||
ScaleData scaleEntry = scaleDBEntries.get(pointIndex);
|
ScaleData scaleData = scaleDataList.get(pointIndex);
|
||||||
lines selectedLine = activeLines.get(lineIndex);
|
lines selectedLine = activeLines.get(lineIndex);
|
||||||
|
|
||||||
String date_time = new SimpleDateFormat("dd. MMM yyyy (EE) HH:mm").format(scaleEntry.date_time);
|
String date_time = new SimpleDateFormat("dd. MMM yyyy (EE) HH:mm").format(scaleData.date_time);
|
||||||
|
|
||||||
switch (selectedLine) {
|
switch (selectedLine) {
|
||||||
case WEIGHT:
|
case WEIGHT:
|
||||||
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_weight) + " " + scaleEntry.weight + getResources().getString(R.string.weight_unit) + " " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_weight) + " " + scaleData.weight + ScaleUser.UNIT_STRING[OpenScale.getInstance(graphView.getContext()).getSelectedScaleUser().scale_unit] + " " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case FAT:
|
case FAT:
|
||||||
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_fat) + " " + scaleEntry.fat + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_fat) + " " + scaleData.fat + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case WATER:
|
case WATER:
|
||||||
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_water) + " " + scaleEntry.water + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_water) + " " + scaleData.water + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
case MUSCLE:
|
case MUSCLE:
|
||||||
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_muscle) + " " + scaleEntry.muscle + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getResources().getString(R.string.info_your_muscle) + " " + scaleData.muscle + "% " + getResources().getString(R.string.info_on_date) + " " + date_time, Toast.LENGTH_SHORT).show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,6 +60,7 @@ public class MainActivity extends ActionBarActivity implements
|
|||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
|
||||||
if(prefs.getBoolean("btEnable", false)) {
|
if(prefs.getBoolean("btEnable", false)) {
|
||||||
String deviceName = prefs.getString("btDeviceName", "openScale");
|
String deviceName = prefs.getString("btDeviceName", "openScale");
|
||||||
OpenScale.getInstance(getApplicationContext()).startBluetoothServer(deviceName);
|
OpenScale.getInstance(getApplicationContext()).startBluetoothServer(deviceName);
|
||||||
@@ -87,7 +88,7 @@ public class MainActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
FragmentUpdateListener fragment = (FragmentUpdateListener) mSectionsPagerAdapter.instantiateItem(mViewPager, position);
|
FragmentUpdateListener fragment = (FragmentUpdateListener) mSectionsPagerAdapter.instantiateItem(mViewPager, position);
|
||||||
if (fragment != null) {
|
if (fragment != null) {
|
||||||
fragment.updateOnView(OpenScale.getInstance(mViewPager.getContext()).getScaleDBEntries());
|
fragment.updateOnView(OpenScale.getInstance(mViewPager.getContext()).getScaleDataList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -102,6 +103,15 @@ public class MainActivity extends ActionBarActivity implements
|
|||||||
.setText(mSectionsPagerAdapter.getPageTitle(i))
|
.setText(mSectionsPagerAdapter.getPageTitle(i))
|
||||||
.setTabListener(this));
|
.setTabListener(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (prefs.getBoolean("firstStart", true)) {
|
||||||
|
Intent intent = new Intent(this, UserSettingsActivity.class);
|
||||||
|
intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
prefs.edit().putBoolean("firstStart", false).commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,11 +127,13 @@ public class MainActivity extends ActionBarActivity implements
|
|||||||
// automatically handle clicks on the Home/Up button, so long
|
// automatically handle clicks on the Home/Up button, so long
|
||||||
// as you specify a parent activity in AndroidManifest.xml.
|
// as you specify a parent activity in AndroidManifest.xml.
|
||||||
int id = item.getItemId();
|
int id = item.getItemId();
|
||||||
if (id == R.id.action_settings) {
|
|
||||||
|
if (id == R.id.action_general_settings) {
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,10 +16,13 @@
|
|||||||
package com.health.openscale.gui;
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.DatePickerDialog;
|
import android.app.DatePickerDialog;
|
||||||
import android.app.TimePickerDialog;
|
import android.app.TimePickerDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.DatePicker;
|
import android.widget.DatePicker;
|
||||||
@@ -28,6 +31,7 @@ import android.widget.TimePicker;
|
|||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.OpenScale;
|
import com.health.openscale.core.OpenScale;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@@ -54,6 +58,7 @@ public class NewEntryActivity extends Activity {
|
|||||||
context = this;
|
context = this;
|
||||||
|
|
||||||
txtWeight = (EditText) findViewById(R.id.txtWeight);
|
txtWeight = (EditText) findViewById(R.id.txtWeight);
|
||||||
|
txtWeight.setHint(getResources().getString(R.string.info_enter_value_unit) + " " + ScaleUser.UNIT_STRING[OpenScale.getInstance(context).getSelectedScaleUser().scale_unit]);
|
||||||
txtFat = (EditText) findViewById(R.id.txtFat);
|
txtFat = (EditText) findViewById(R.id.txtFat);
|
||||||
txtWater = (EditText) findViewById(R.id.txtWater);
|
txtWater = (EditText) findViewById(R.id.txtWater);
|
||||||
txtMuscle = (EditText) findViewById(R.id.txtMuscle);
|
txtMuscle = (EditText) findViewById(R.id.txtMuscle);
|
||||||
@@ -161,18 +166,30 @@ public class NewEntryActivity extends Activity {
|
|||||||
{
|
{
|
||||||
OpenScale openScale = OpenScale.getInstance(context);
|
OpenScale openScale = OpenScale.getInstance(context);
|
||||||
|
|
||||||
int user_id = 0;
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
float weight = Float.valueOf(txtWeight.getText().toString());
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
float fat = Float.valueOf(txtFat.getText().toString());
|
|
||||||
float water = Float.valueOf(txtWater.getText().toString());
|
if (selectedUserId == -1) {
|
||||||
float muscle = Float.valueOf(txtMuscle.getText().toString());
|
AlertDialog.Builder infoDialog = new AlertDialog.Builder(context);
|
||||||
|
|
||||||
String date = txtDate.getText().toString();
|
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
|
||||||
String time = txtTime.getText().toString();
|
|
||||||
|
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
|
||||||
openScale.addScaleData(user_id, date + " " + time, weight, fat, water, muscle);
|
|
||||||
|
infoDialog.show();
|
||||||
finish();
|
} else {
|
||||||
|
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(selectedUserId, date + " " + time, weight, fat, water, muscle);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@ import android.widget.TextView;
|
|||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.OpenScale;
|
import com.health.openscale.core.OpenScale;
|
||||||
import com.health.openscale.core.ScaleData;
|
import com.health.openscale.core.ScaleData;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -40,6 +41,8 @@ import lecho.lib.hellocharts.view.PieChartView;
|
|||||||
|
|
||||||
public class OverviewFragment extends Fragment implements FragmentUpdateListener {
|
public class OverviewFragment extends Fragment implements FragmentUpdateListener {
|
||||||
private View overviewView;
|
private View overviewView;
|
||||||
|
|
||||||
|
private TextView txtOverviewTitle;
|
||||||
private PieChartView pieChart;
|
private PieChartView pieChart;
|
||||||
private TextView txtAvgWeight;
|
private TextView txtAvgWeight;
|
||||||
private TextView txtAvgFat;
|
private TextView txtAvgFat;
|
||||||
@@ -50,8 +53,9 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
overviewView = inflater.inflate(R.layout.fragment_overview, container, false);
|
overviewView = inflater.inflate(R.layout.fragment_overview, container, false);
|
||||||
|
|
||||||
pieChart = (PieChartView) overviewView.findViewById(R.id.data_pie_chart);
|
txtOverviewTitle = (TextView) overviewView.findViewById(R.id.txtOverviewTitle);
|
||||||
|
pieChart = (PieChartView) overviewView.findViewById(R.id.pieChart);
|
||||||
txtAvgWeight = (TextView) overviewView.findViewById(R.id.txtAvgWeight);
|
txtAvgWeight = (TextView) overviewView.findViewById(R.id.txtAvgWeight);
|
||||||
txtAvgFat = (TextView) overviewView.findViewById(R.id.txtAvgFat);
|
txtAvgFat = (TextView) overviewView.findViewById(R.id.txtAvgFat);
|
||||||
txtAvgWater = (TextView) overviewView.findViewById(R.id.txtAvgWater);
|
txtAvgWater = (TextView) overviewView.findViewById(R.id.txtAvgWater);
|
||||||
@@ -63,32 +67,36 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
updateOnView(OpenScale.getInstance(overviewView.getContext()).getScaleDBEntries());
|
updateOnView(OpenScale.getInstance(overviewView.getContext()).getScaleDataList());
|
||||||
|
|
||||||
return overviewView;
|
return overviewView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOnView(ArrayList<ScaleData> scaleDBEntries)
|
public void updateOnView(ArrayList<ScaleData> scaleDataList)
|
||||||
{
|
{
|
||||||
|
ScaleUser scaleUser = OpenScale.getInstance(overviewView.getContext()).getSelectedScaleUser();
|
||||||
|
|
||||||
|
txtOverviewTitle.setText(getResources().getString(R.string.label_overview_title_start) + " " + scaleUser.user_name + " " + getResources().getString(R.string.label_overview_title_end));
|
||||||
|
|
||||||
List<ArcValue> arcValues = new ArrayList<ArcValue>();
|
List<ArcValue> arcValues = new ArrayList<ArcValue>();
|
||||||
|
|
||||||
if (scaleDBEntries.isEmpty()) {
|
if (scaleDataList.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScaleData lastEntry = scaleDBEntries.get(0);
|
ScaleData lastScaleData = scaleDataList.get(0);
|
||||||
|
|
||||||
arcValues.add(new ArcValue(lastEntry.fat, Utils.COLOR_ORANGE));
|
arcValues.add(new ArcValue(lastScaleData.fat, Utils.COLOR_ORANGE));
|
||||||
arcValues.add(new ArcValue(lastEntry.water, Utils.COLOR_BLUE));
|
arcValues.add(new ArcValue(lastScaleData.water, Utils.COLOR_BLUE));
|
||||||
arcValues.add(new ArcValue(lastEntry.muscle, Utils.COLOR_GREEN));
|
arcValues.add(new ArcValue(lastScaleData.muscle, Utils.COLOR_GREEN));
|
||||||
|
|
||||||
PieChartData pieChartData = new PieChartData(arcValues);
|
PieChartData pieChartData = new PieChartData(arcValues);
|
||||||
pieChartData.setHasLabels(true);
|
pieChartData.setHasLabels(true);
|
||||||
pieChartData.setFormatter(new SimpleValueFormatter(1, false, null, " %".toCharArray()));
|
pieChartData.setFormatter(new SimpleValueFormatter(1, false, null, " %".toCharArray()));
|
||||||
pieChartData.setHasCenterCircle(true);
|
pieChartData.setHasCenterCircle(true);
|
||||||
pieChartData.setCenterText1(Float.toString(lastEntry.weight) + " " + getResources().getString(R.string.weight_unit));
|
pieChartData.setCenterText1(Float.toString(lastScaleData.weight) + " " + ScaleUser.UNIT_STRING[scaleUser.scale_unit]);
|
||||||
pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy (EE)").format(lastEntry.date_time));
|
pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy (EE)").format(lastScaleData.date_time));
|
||||||
|
|
||||||
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
|
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
|
||||||
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
||||||
@@ -108,7 +116,7 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
double avgWater = 0;
|
double avgWater = 0;
|
||||||
double avgMuscle = 0;
|
double avgMuscle = 0;
|
||||||
|
|
||||||
for (ScaleData scaleData : scaleDBEntries)
|
for (ScaleData scaleData : scaleDataList)
|
||||||
{
|
{
|
||||||
avgWeight += scaleData.weight;
|
avgWeight += scaleData.weight;
|
||||||
avgFat += scaleData.fat;
|
avgFat += scaleData.fat;
|
||||||
@@ -116,21 +124,26 @@ public class OverviewFragment extends Fragment implements FragmentUpdateListener
|
|||||||
avgMuscle += scaleData.muscle;
|
avgMuscle += scaleData.muscle;
|
||||||
}
|
}
|
||||||
|
|
||||||
avgWeight = avgWeight / scaleDBEntries.size();
|
avgWeight = avgWeight / scaleDataList.size();
|
||||||
avgFat = avgFat / scaleDBEntries.size();
|
avgFat = avgFat / scaleDataList.size();
|
||||||
avgWater = avgWater / scaleDBEntries.size();
|
avgWater = avgWater / scaleDataList.size();
|
||||||
avgMuscle = avgMuscle / scaleDBEntries.size();
|
avgMuscle = avgMuscle / scaleDataList.size();
|
||||||
|
|
||||||
txtAvgWeight.setText(String.format( "%.1f " + getResources().getString(R.string.weight_unit), avgWeight));
|
txtAvgWeight.setText(String.format( "%.1f " + ScaleUser.UNIT_STRING[scaleUser.scale_unit], avgWeight));
|
||||||
txtAvgFat.setText(String.format( "%.1f %%", avgFat));
|
txtAvgFat.setText(String.format( "%.1f %%", avgFat));
|
||||||
txtAvgWater.setText(String.format( "%.1f %%", avgWater));
|
txtAvgWater.setText(String.format( "%.1f %%", avgWater));
|
||||||
txtAvgMuscle.setText(String.format( "%.1f %%", avgMuscle));
|
txtAvgMuscle.setText(String.format( "%.1f %%", avgMuscle));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void btnOnClickInsertData()
|
public void btnOnClickInsertData()
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(overviewView.getContext(), NewEntryActivity.class);
|
Intent intent = new Intent(overviewView.getContext(), NewEntryActivity.class);
|
||||||
startActivity(intent);
|
startActivityForResult(intent, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
|
{
|
||||||
|
updateOnView(OpenScale.getInstance(overviewView.getContext()).getScaleDataList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.health.openscale.gui;
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -23,11 +24,15 @@ import android.preference.ListPreference;
|
|||||||
import android.preference.MultiSelectListPreference;
|
import android.preference.MultiSelectListPreference;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.preference.PreferenceCategory;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import com.health.openscale.R;
|
import com.health.openscale.R;
|
||||||
import com.health.openscale.core.OpenScale;
|
import com.health.openscale.core.OpenScale;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
|
||||||
|
|
||||||
@@ -36,8 +41,50 @@ protected void onCreate(Bundle savedInstanceState) {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.preferences);
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
initSummary(getPreferenceScreen());
|
initSummary(getPreferenceScreen());
|
||||||
|
|
||||||
|
updateUserPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateUserPreferences()
|
||||||
|
{
|
||||||
|
PreferenceCategory usersCategory = (PreferenceCategory)findPreference("catUsers");
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
|
usersCategory.removeAll();
|
||||||
|
|
||||||
|
OpenScale openScale = OpenScale.getInstance(this);
|
||||||
|
|
||||||
|
ArrayList<ScaleUser> scaleUserList = openScale.getScaleUserList();
|
||||||
|
|
||||||
|
for (ScaleUser scaleUser : scaleUserList)
|
||||||
|
{
|
||||||
|
Preference prefUser = new Preference(this);
|
||||||
|
prefUser.setOnPreferenceClickListener(new onClickListenerUserSelect());
|
||||||
|
|
||||||
|
if (scaleUser.id == selectedUserId) {
|
||||||
|
prefUser.setTitle("> " + scaleUser.user_name);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
prefUser.setTitle(scaleUser.user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
prefUser.setKey(Integer.toString(scaleUser.id));
|
||||||
|
|
||||||
|
usersCategory.addPreference(prefUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Preference prefAddUser = new Preference(this);
|
||||||
|
|
||||||
|
prefAddUser.setOnPreferenceClickListener(new onClickListenerAddUser());
|
||||||
|
prefAddUser.setTitle("+ Add User");
|
||||||
|
|
||||||
|
usersCategory.addPreference(prefAddUser);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -108,5 +155,44 @@ private void updatePrefSummary(Preference p) {
|
|||||||
findPreference("btDeviceName").setEnabled(false);
|
findPreference("btDeviceName").setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
|
{
|
||||||
|
if (requestCode == UserSettingsActivity.ADD_USER_REQUEST) {
|
||||||
|
if(resultCode == RESULT_OK){
|
||||||
|
updateUserPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (requestCode == UserSettingsActivity.EDIT_USER_REQUEST) {
|
||||||
|
if(resultCode == RESULT_OK){
|
||||||
|
updateUserPreferences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerUserSelect implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
||||||
|
intent.putExtra("mode", UserSettingsActivity.EDIT_USER_REQUEST);
|
||||||
|
intent.putExtra("id", Integer.parseInt(preference.getKey()));
|
||||||
|
startActivityForResult(intent, UserSettingsActivity.EDIT_USER_REQUEST);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerAddUser implements Preference.OnPreferenceClickListener {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
Intent intent = new Intent(preference.getContext(), UserSettingsActivity.class);
|
||||||
|
intent.putExtra("mode", UserSettingsActivity.ADD_USER_REQUEST);
|
||||||
|
startActivityForResult(intent, UserSettingsActivity.ADD_USER_REQUEST);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -17,10 +17,12 @@ package com.health.openscale.gui;
|
|||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -87,54 +89,54 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOnView(ArrayList<ScaleData> scaleDBEntries)
|
public void updateOnView(ArrayList<ScaleData> scaleDataList)
|
||||||
{
|
{
|
||||||
TableRow headerRow = (TableRow) tableView.findViewById(R.id.tableHeader);
|
TableRow headerRow = (TableRow) tableView.findViewById(R.id.tableHeader);
|
||||||
tableDataView.removeAllViews();
|
tableDataView.removeAllViews();
|
||||||
tableDataView.addView(headerRow);
|
tableDataView.addView(headerRow);
|
||||||
|
|
||||||
for(ScaleData scaleEntry: scaleDBEntries)
|
for(ScaleData scaleData: scaleDataList)
|
||||||
{
|
{
|
||||||
TableRow dataRow = new TableRow(tableView.getContext());
|
TableRow dataRow = new TableRow(tableView.getContext());
|
||||||
dataRow.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
dataRow.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
TextView timeIdView = new TextView(tableView.getContext());
|
TextView idView = new TextView(tableView.getContext());
|
||||||
timeIdView.setText(Long.toString(scaleEntry.id));
|
idView.setText(Long.toString(scaleData.id));
|
||||||
timeIdView.setVisibility(View.GONE);
|
idView.setVisibility(View.GONE);
|
||||||
dataRow.addView(timeIdView);
|
dataRow.addView(idView);
|
||||||
|
|
||||||
TextView dateTextView = new TextView(tableView.getContext());
|
TextView dateTextView = new TextView(tableView.getContext());
|
||||||
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
|
if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE ||
|
||||||
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
(getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE) {
|
||||||
dateTextView.setText(new SimpleDateFormat("dd. MMM yyyy (EE)").format(scaleEntry.date_time));
|
dateTextView.setText(new SimpleDateFormat("dd. MMM yyyy (EE)").format(scaleData.date_time));
|
||||||
} else{
|
} else{
|
||||||
dateTextView.setText(new SimpleDateFormat("dd/MM/yy").format(scaleEntry.date_time));
|
dateTextView.setText(new SimpleDateFormat("dd/MM/yy").format(scaleData.date_time));
|
||||||
}
|
}
|
||||||
dateTextView.setPadding(0, 5, 5, 5);
|
dateTextView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(dateTextView);
|
dataRow.addView(dateTextView);
|
||||||
|
|
||||||
TextView timeTextView = new TextView(tableView.getContext());
|
TextView timeTextView = new TextView(tableView.getContext());
|
||||||
timeTextView.setText(new SimpleDateFormat("HH:mm").format(scaleEntry.date_time));
|
timeTextView.setText(new SimpleDateFormat("HH:mm").format(scaleData.date_time));
|
||||||
timeTextView.setPadding(0, 5, 5, 5);
|
timeTextView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(timeTextView);
|
dataRow.addView(timeTextView);
|
||||||
|
|
||||||
TextView weightView = new TextView(tableView.getContext());
|
TextView weightView = new TextView(tableView.getContext());
|
||||||
weightView.setText(Float.toString(scaleEntry.weight));
|
weightView.setText(Float.toString(scaleData.weight));
|
||||||
weightView.setPadding(0, 5, 5, 5);
|
weightView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(weightView);
|
dataRow.addView(weightView);
|
||||||
|
|
||||||
TextView fatView = new TextView(tableView.getContext());
|
TextView fatView = new TextView(tableView.getContext());
|
||||||
fatView.setText(Float.toString(scaleEntry.fat));
|
fatView.setText(Float.toString(scaleData.fat));
|
||||||
fatView.setPadding(0, 5, 5, 5);
|
fatView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(fatView);
|
dataRow.addView(fatView);
|
||||||
|
|
||||||
TextView waterView = new TextView(tableView.getContext());
|
TextView waterView = new TextView(tableView.getContext());
|
||||||
waterView.setText(Float.toString(scaleEntry.water));
|
waterView.setText(Float.toString(scaleData.water));
|
||||||
waterView.setPadding(0, 5, 5, 5);
|
waterView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(waterView);
|
dataRow.addView(waterView);
|
||||||
|
|
||||||
TextView muscleView = new TextView(tableView.getContext());
|
TextView muscleView = new TextView(tableView.getContext());
|
||||||
muscleView.setText(Float.toString(scaleEntry.muscle));
|
muscleView.setText(Float.toString(scaleData.muscle));
|
||||||
muscleView.setPadding(0, 5, 5, 5);
|
muscleView.setPadding(0, 5, 5, 5);
|
||||||
dataRow.addView(muscleView);
|
dataRow.addView(muscleView);
|
||||||
|
|
||||||
@@ -169,41 +171,58 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
private class onClickListenerImport implements View.OnClickListener {
|
private class onClickListenerImport implements View.OnClickListener {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
AlertDialog.Builder filenameDialog = new AlertDialog.Builder(getActivity());
|
|
||||||
|
|
||||||
filenameDialog.setTitle(getResources().getString(R.string.info_set_filename) + " /sdcard ...");
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(v.getContext());
|
||||||
|
int selectedUserId = prefs.getInt("selectedUserId", -1);
|
||||||
|
|
||||||
final EditText txtFilename = new EditText(tableView.getContext());
|
if (selectedUserId == -1)
|
||||||
txtFilename.setText("/openScale_data.csv");
|
{
|
||||||
|
AlertDialog.Builder infoDialog = new AlertDialog.Builder(v.getContext());
|
||||||
|
|
||||||
filenameDialog.setView(txtFilename);
|
infoDialog.setMessage(getResources().getString(R.string.info_no_selected_user));
|
||||||
|
|
||||||
filenameDialog.setPositiveButton(getResources().getString(R.string.label_ok), new DialogInterface.OnClickListener() {
|
infoDialog.setPositiveButton(getResources().getString(R.string.label_ok), null);
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
boolean isError = false;
|
|
||||||
|
|
||||||
try {
|
infoDialog.show();
|
||||||
OpenScale.getInstance(tableView.getContext()).importData(Environment.getExternalStorageDirectory().getPath() + txtFilename.getText().toString());
|
}
|
||||||
} catch (IOException e) {
|
else
|
||||||
Toast.makeText(tableView.getContext(), getResources().getString(R.string.error_importing) + " " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
{
|
||||||
isError = true;
|
AlertDialog.Builder filenameDialog = new AlertDialog.Builder(getActivity());
|
||||||
}
|
|
||||||
|
|
||||||
if (!isError) {
|
filenameDialog.setTitle(getResources().getString(R.string.info_set_filename) + " /sdcard ...");
|
||||||
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_imported) + " /sdcard" + txtFilename.getText().toString(), Toast.LENGTH_SHORT).show();
|
|
||||||
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDBEntries());
|
final EditText txtFilename = new EditText(tableView.getContext());
|
||||||
}
|
txtFilename.setText("/openScale_data_" + OpenScale.getInstance(tableView.getContext()).getSelectedScaleUser().user_name + ".csv");
|
||||||
|
|
||||||
|
filenameDialog.setView(txtFilename);
|
||||||
|
|
||||||
|
filenameDialog.setPositiveButton(getResources().getString(R.string.label_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(), getResources().getString(R.string.error_importing) + " " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||||
|
isError = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isError) {
|
||||||
|
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_imported) + " /sdcard" + txtFilename.getText().toString(), Toast.LENGTH_SHORT).show();
|
||||||
|
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDataList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
filenameDialog.setNegativeButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
filenameDialog.show();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
filenameDialog.setNegativeButton(getResources().getString(R.string.label_cancel), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.dismiss();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
filenameDialog.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +234,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
filenameDialog.setTitle(getResources().getString(R.string.info_set_filename) + " /sdcard ...");
|
filenameDialog.setTitle(getResources().getString(R.string.info_set_filename) + " /sdcard ...");
|
||||||
|
|
||||||
final EditText txtFilename = new EditText(tableView.getContext());
|
final EditText txtFilename = new EditText(tableView.getContext());
|
||||||
txtFilename.setText("/openScale_data.csv");
|
txtFilename.setText("/openScale_data_" + OpenScale.getInstance(tableView.getContext()).getSelectedScaleUser().user_name + ".csv");
|
||||||
|
|
||||||
filenameDialog.setView(txtFilename);
|
filenameDialog.setView(txtFilename);
|
||||||
|
|
||||||
@@ -256,10 +275,10 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
|
|
||||||
deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() {
|
deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
OpenScale.getInstance(tableView.getContext()).deleteAllDBEntries();
|
OpenScale.getInstance(tableView.getContext()).clearScaleData();
|
||||||
|
|
||||||
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_all_deleted), Toast.LENGTH_SHORT).show();
|
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_all_deleted), Toast.LENGTH_SHORT).show();
|
||||||
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDBEntries());
|
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDataList());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -283,7 +302,7 @@ public class TableFragment extends Fragment implements FragmentUpdateListener {
|
|||||||
OpenScale.getInstance(tableView.getContext()).deleteScaleData(id);
|
OpenScale.getInstance(tableView.getContext()).deleteScaleData(id);
|
||||||
|
|
||||||
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_deleted), Toast.LENGTH_SHORT).show();
|
Toast.makeText(tableView.getContext(), getResources().getString(R.string.info_data_deleted), Toast.LENGTH_SHORT).show();
|
||||||
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDBEntries());
|
updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDataList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,259 @@
|
|||||||
|
/* Copyright (C) 2014 olie.xdev <olie.xdev@googlemail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
package com.health.openscale.gui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
|
||||||
|
import com.health.openscale.R;
|
||||||
|
import com.health.openscale.core.OpenScale;
|
||||||
|
import com.health.openscale.core.ScaleUser;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class UserSettingsActivity extends Activity {
|
||||||
|
|
||||||
|
public static final int ADD_USER_REQUEST = 0;
|
||||||
|
public static final int EDIT_USER_REQUEST = 1;
|
||||||
|
|
||||||
|
private EditText txtUserName;
|
||||||
|
private EditText txtBodyHeight;
|
||||||
|
private EditText txtBirthday;
|
||||||
|
private RadioGroup radioScaleUnit;
|
||||||
|
|
||||||
|
private Button btnBirthdaySet;
|
||||||
|
private Button btnOk;
|
||||||
|
private Button btnCancel;
|
||||||
|
private Button btnDelete;
|
||||||
|
|
||||||
|
private SimpleDateFormat birthdayFormat = new SimpleDateFormat("dd.MM.yyyy");
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_usersettings);
|
||||||
|
context = this;
|
||||||
|
|
||||||
|
txtUserName = (EditText) findViewById(R.id.txtUserName);
|
||||||
|
txtBodyHeight = (EditText) findViewById(R.id.txtBodyHeight);
|
||||||
|
radioScaleUnit = (RadioGroup) findViewById(R.id.groupScaleUnit);
|
||||||
|
|
||||||
|
txtBirthday = (EditText) findViewById(R.id.txtBirthday);
|
||||||
|
|
||||||
|
btnBirthdaySet = (Button) findViewById(R.id.btnDateSet);
|
||||||
|
btnDelete = (Button) findViewById(R.id.btnDelete);
|
||||||
|
btnOk = (Button)findViewById(R.id.btnOk);
|
||||||
|
btnCancel = (Button)findViewById(R.id.btnCancel);
|
||||||
|
|
||||||
|
btnOk.setOnClickListener(new onClickListenerOk());
|
||||||
|
btnCancel.setOnClickListener(new onClickListenerCancel());
|
||||||
|
btnDelete.setOnClickListener(new onClickListenerDelete());
|
||||||
|
btnBirthdaySet.setOnClickListener(new onClickListenerBirthdaySet());
|
||||||
|
|
||||||
|
txtBirthday.setText(birthdayFormat.format(new Date()));
|
||||||
|
|
||||||
|
if (getIntent().getExtras().getInt("mode") == EDIT_USER_REQUEST)
|
||||||
|
{
|
||||||
|
editMode();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
btnOk.setText(getResources().getString(R.string.label_add));
|
||||||
|
btnDelete.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editMode()
|
||||||
|
{
|
||||||
|
int id = getIntent().getExtras().getInt("id");
|
||||||
|
|
||||||
|
OpenScale openScale = OpenScale.getInstance(context);
|
||||||
|
|
||||||
|
ScaleUser scaleUser = openScale.getScaleUser(id);
|
||||||
|
|
||||||
|
txtUserName.setText(scaleUser.user_name);
|
||||||
|
txtBodyHeight.setText(Integer.toString(scaleUser.body_height));
|
||||||
|
txtBirthday.setText(birthdayFormat.format(scaleUser.birthday));
|
||||||
|
|
||||||
|
switch (scaleUser.scale_unit)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
radioScaleUnit.check(R.id.btnRadioKG);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
radioScaleUnit.check(R.id.btnRadioLB);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
radioScaleUnit.check(R.id.btnRadioST);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean validateInput()
|
||||||
|
{
|
||||||
|
boolean validate = true;
|
||||||
|
|
||||||
|
if( txtUserName.getText().toString().length() == 0 )
|
||||||
|
{
|
||||||
|
txtUserName.setError(getResources().getString(R.string.error_user_name_required));
|
||||||
|
validate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( txtBodyHeight.getText().toString().length() == 0 )
|
||||||
|
{
|
||||||
|
txtBodyHeight.setError(getResources().getString(R.string.error_body_height_required));
|
||||||
|
validate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return validate;
|
||||||
|
}
|
||||||
|
|
||||||
|
private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
|
||||||
|
@Override
|
||||||
|
public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
|
||||||
|
txtBirthday.setText(String.format("%02d.%02d.%04d", selectedDay, selectedMonth + 1, selectedYear));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private class onClickListenerDelete implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(v.getContext());
|
||||||
|
|
||||||
|
deleteAllDialog.setMessage(getResources().getString(R.string.question_really_delete_user));
|
||||||
|
|
||||||
|
deleteAllDialog.setPositiveButton(getResources().getString(R.string.label_yes), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
int userId = getIntent().getExtras().getInt("id");
|
||||||
|
|
||||||
|
OpenScale openScale = OpenScale.getInstance(context);
|
||||||
|
openScale.deleteScaleUser(userId);
|
||||||
|
openScale.clearScaleData();
|
||||||
|
|
||||||
|
ArrayList<ScaleUser> scaleUser = openScale.getScaleUserList();
|
||||||
|
|
||||||
|
int lastUserId = -1;
|
||||||
|
|
||||||
|
if (!scaleUser.isEmpty()) {
|
||||||
|
lastUserId = scaleUser.get(0).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
prefs.edit().putInt("selectedUserId", lastUserId).commit();
|
||||||
|
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
setResult(RESULT_OK, returnIntent);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteAllDialog.setNegativeButton(getResources().getString(R.string.label_no), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteAllDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerOk implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (validateInput())
|
||||||
|
{
|
||||||
|
OpenScale openScale = OpenScale.getInstance(context);
|
||||||
|
|
||||||
|
String name = txtUserName.getText().toString();
|
||||||
|
int body_height = Integer.valueOf(txtBodyHeight.getText().toString());
|
||||||
|
int checkedRadioButtonId = radioScaleUnit.getCheckedRadioButtonId();
|
||||||
|
|
||||||
|
int scale_unit = -1;
|
||||||
|
|
||||||
|
switch (checkedRadioButtonId) {
|
||||||
|
case R.id.btnRadioKG:
|
||||||
|
scale_unit = 0;
|
||||||
|
break;
|
||||||
|
case R.id.btnRadioLB:
|
||||||
|
scale_unit = 1;
|
||||||
|
break;
|
||||||
|
case R.id.btnRadioST:
|
||||||
|
scale_unit = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String date = txtBirthday.getText().toString();
|
||||||
|
|
||||||
|
int id = -1;
|
||||||
|
|
||||||
|
if (getIntent().getExtras().getInt("mode") == EDIT_USER_REQUEST)
|
||||||
|
{
|
||||||
|
id = getIntent().getExtras().getInt("id");
|
||||||
|
openScale.updateScaleUser(id, name, date, body_height, scale_unit);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
openScale.addScaleUser(name, date, body_height, scale_unit);
|
||||||
|
|
||||||
|
id = openScale.getScaleUserList().get(0).id;
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
prefs.edit().putInt("selectedUserId", id).commit();
|
||||||
|
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
setResult(RESULT_OK, returnIntent);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerBirthdaySet implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class onClickListenerCancel implements View.OnClickListener {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent returnIntent = new Intent();
|
||||||
|
setResult(RESULT_CANCELED, returnIntent);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
160
android_app/app/src/main/res/layout/activity_usersettings.xml
Normal file
160
android_app/app/src/main/res/layout/activity_usersettings.xml
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="5dp" >
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:stretchColumns="*" >
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:id="@+id/tableRow1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_user_name" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/txtUserName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="text"
|
||||||
|
android:hint="@string/info_enter_user_name">
|
||||||
|
|
||||||
|
<requestFocus />
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:id="@+id/tableRow2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_body_height" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/txtBodyHeight"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="@string/info_enter_value_cm"
|
||||||
|
android:inputType="numberDecimal|numberSigned" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:id="@+id/tableRow3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_scale_unit" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_column="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:id="@+id/groupScaleUnit">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="kg"
|
||||||
|
android:id="@+id/btnRadioKG"
|
||||||
|
android:checked="true" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="lb"
|
||||||
|
android:id="@+id/btnRadioLB" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="st"
|
||||||
|
android:id="@+id/btnRadioST" />
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:id="@+id/tableRow5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_birthday" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/txtBirthday"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="5"
|
||||||
|
android:ems="10"
|
||||||
|
android:enabled="false"
|
||||||
|
android:inputType="date" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnDateSet"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/label_set"
|
||||||
|
android:textSize="15sp" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnCancel"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="5"
|
||||||
|
android:background="@drawable/flat_selector"
|
||||||
|
android:text="@string/label_cancel"
|
||||||
|
android:layout_marginRight="10dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnDelete"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="5"
|
||||||
|
android:background="@drawable/flat_selector"
|
||||||
|
android:text="@string/label_delete"
|
||||||
|
android:layout_marginRight="10dp" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnOk"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="5"
|
||||||
|
android:background="@drawable/flat_selector"
|
||||||
|
android:text="@string/label_ok" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
@@ -14,8 +14,15 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:weightSum="100">
|
android:weightSum="100">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:id="@+id/txtOverviewTitle"
|
||||||
|
android:gravity="center" />
|
||||||
|
|
||||||
<lecho.lib.hellocharts.view.PieChartView
|
<lecho.lib.hellocharts.view.PieChartView
|
||||||
android:id="@+id/data_pie_chart"
|
android:id="@+id/pieChart"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_gravity="top|center"
|
android:layout_gravity="top|center"
|
||||||
|
@@ -4,9 +4,8 @@
|
|||||||
tools:context="com.example.openscale.MainActivity" >
|
tools:context="com.example.openscale.MainActivity" >
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_settings"
|
android:id="@+id/action_general_settings"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:title="@string/action_settings"
|
android:title="@string/action_settings"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
@@ -5,12 +5,17 @@
|
|||||||
<string name="title_overview">Overview</string>
|
<string name="title_overview">Overview</string>
|
||||||
<string name="title_graph">Chart</string>
|
<string name="title_graph">Chart</string>
|
||||||
<string name="title_frag">Table</string>
|
<string name="title_frag">Table</string>
|
||||||
|
<string name="title_user">User</string>
|
||||||
|
<string name="title_new_data_entry">Data Entry</string>
|
||||||
|
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
<string name="label_add">Add</string>
|
<string name="label_add">Add</string>
|
||||||
<string name="label_cancel">Cancel</string>
|
<string name="label_cancel">Cancel</string>
|
||||||
<string name="label_ok">OK</string>
|
<string name="label_ok">OK</string>
|
||||||
<string name="label_yes">Yes</string>
|
<string name="label_yes">Yes</string>
|
||||||
<string name="label_no">No</string>
|
<string name="label_no">No</string>
|
||||||
|
<string name="label_delete">Delete</string>
|
||||||
|
|
||||||
<string name="label_id">Id</string>
|
<string name="label_id">Id</string>
|
||||||
<string name="label_weight">Weight</string>
|
<string name="label_weight">Weight</string>
|
||||||
@@ -18,16 +23,20 @@
|
|||||||
<string name="label_water">Water</string>
|
<string name="label_water">Water</string>
|
||||||
<string name="label_muscle">Muscle</string>
|
<string name="label_muscle">Muscle</string>
|
||||||
|
|
||||||
<string name="weight_unit">kg</string>
|
|
||||||
|
|
||||||
<string name="label_date">Date</string>
|
<string name="label_date">Date</string>
|
||||||
<string name="label_time">Time</string>
|
<string name="label_time">Time</string>
|
||||||
<string name="label_set">Set</string>
|
<string name="label_set">Set</string>
|
||||||
|
<string name="label_birthday">Birthday</string>
|
||||||
|
<string name="label_user_name">Name</string>
|
||||||
|
<string name="label_body_height">Body height</string>
|
||||||
|
<string name="label_scale_unit">Scale unit</string>
|
||||||
|
|
||||||
<string name="label_weight_average">Weight Ø</string>
|
<string name="label_weight_average">Weight Ø</string>
|
||||||
<string name="label_fat_average">Fat Ø</string>
|
<string name="label_fat_average">Fat Ø</string>
|
||||||
<string name="label_water_average">Water Ø</string>
|
<string name="label_water_average">Water Ø</string>
|
||||||
<string name="label_muscle_average">Muscle Ø</string>
|
<string name="label_muscle_average">Muscle Ø</string>
|
||||||
|
<string name="label_overview_title_start">Hello</string>
|
||||||
|
<string name="label_overview_title_end">your last measurement is:</string>
|
||||||
|
|
||||||
<string name="label_import">Import</string>
|
<string name="label_import">Import</string>
|
||||||
<string name="label_export">Export</string>
|
<string name="label_export">Export</string>
|
||||||
@@ -41,6 +50,8 @@
|
|||||||
<string name="error_value_range_0_100">Value must be in range from 0 to 100!</string>
|
<string name="error_value_range_0_100">Value must be in range from 0 to 100!</string>
|
||||||
<string name="error_exporting">Error exporting</string>
|
<string name="error_exporting">Error exporting</string>
|
||||||
<string name="error_importing">Error importing</string>
|
<string name="error_importing">Error importing</string>
|
||||||
|
<string name="error_user_name_required">Error user name is required!</string>
|
||||||
|
<string name="error_body_height_required">Error body height is required!</string>
|
||||||
|
|
||||||
<string name="info_data_deleted">Database entry deleted!</string>
|
<string name="info_data_deleted">Database entry deleted!</string>
|
||||||
<string name="info_data_all_deleted">All database entries deleted!</string>
|
<string name="info_data_all_deleted">All database entries deleted!</string>
|
||||||
@@ -48,16 +59,24 @@
|
|||||||
<string name="info_data_imported">Data imported from</string>
|
<string name="info_data_imported">Data imported from</string>
|
||||||
<string name="info_set_filename">Set filename to</string>
|
<string name="info_set_filename">Set filename to</string>
|
||||||
<string name="info_enter_value_percent">Enter value in %</string>
|
<string name="info_enter_value_percent">Enter value in %</string>
|
||||||
<string name="info_enter_value_unit">Enter value in kg</string>
|
<string name="info_enter_value_unit">Enter value in</string>
|
||||||
|
<string name="info_is_visible">Is visible</string>
|
||||||
|
<string name="info_is_not_visible">Is not visible</string>
|
||||||
|
<string name="info_bluetooth_enable">Searching for Bluetooth bathroom scale is enabled</string>
|
||||||
|
<string name="info_bluetooth_disable">Searching for Bluetooth bathroom scale is disabled</string>
|
||||||
<string name="info_new_bluetooth_data">New Bluetooth scale data received!</string>
|
<string name="info_new_bluetooth_data">New Bluetooth scale data received!</string>
|
||||||
|
<string name="info_enter_value_cm">Enter your height in cm</string>
|
||||||
|
<string name="info_enter_user_name">Enter your name</string>
|
||||||
|
<string name="info_no_selected_user">No user exist! Please create a new user in the settings</string>
|
||||||
|
|
||||||
<string name="question_really_delete_all">Do you really want to delete all database entries?</string>
|
<string name="question_really_delete_all">Do you really want to delete all database entries?</string>
|
||||||
|
<string name="question_really_delete_user">Do you really want to delete the user? </string>
|
||||||
|
|
||||||
<string name="label_bluetooth_title">Bluetooth</string>
|
<string name="label_bluetooth_title">Bluetooth</string>
|
||||||
<string name="label_bluetooth_enable">Enable Bluetooth Server</string>
|
<string name="label_bluetooth_enable">Search mode</string>
|
||||||
<string name="label_device_name">Device Name</string>
|
<string name="label_device_name">Device Name</string>
|
||||||
|
|
||||||
<string name="label_enable_labels">Labels on data points</string>
|
<string name="label_enable_labels">Label on data point</string>
|
||||||
<string name="label_enable_weight">Weight line</string>
|
<string name="label_enable_weight">Weight line</string>
|
||||||
<string name="label_enable_fat">Fat line</string>
|
<string name="label_enable_fat">Fat line</string>
|
||||||
<string name="label_enable_water">Water line</string>
|
<string name="label_enable_water">Water line</string>
|
||||||
|
@@ -1,17 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="Users" android:key="catUsers">
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/label_bluetooth_title">
|
<PreferenceCategory android:title="@string/label_bluetooth_title">
|
||||||
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:key="btEnable" android:defaultValue="false"/>
|
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:summaryOn="@string/info_bluetooth_enable" android:summaryOff="@string/info_bluetooth_disable" android:key="btEnable" android:defaultValue="false"/>
|
||||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="openScale" />
|
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="openScale" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/title_graph">
|
<PreferenceCategory android:title="@string/title_graph">
|
||||||
<CheckBoxPreference android:title="@string/label_enable_labels" android:key="labelsEnable" android:defaultValue="true"/>
|
<CheckBoxPreference android:title="@string/label_enable_labels" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="labelsEnable" android:defaultValue="true"/>
|
||||||
<CheckBoxPreference android:title="@string/label_enable_weight" android:key="weightEnable" android:defaultValue="true"/>
|
<CheckBoxPreference android:title="@string/label_enable_weight" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="weightEnable" android:defaultValue="true"/>
|
||||||
<CheckBoxPreference android:title="@string/label_enable_fat" android:key="fatEnable" android:defaultValue="true"/>
|
<CheckBoxPreference android:title="@string/label_enable_fat" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="fatEnable" android:defaultValue="true"/>
|
||||||
<CheckBoxPreference android:title="@string/label_enable_water" android:key="waterEnable" android:defaultValue="true"/>
|
<CheckBoxPreference android:title="@string/label_enable_water" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="waterEnable" android:defaultValue="true"/>
|
||||||
<CheckBoxPreference android:title="@string/label_enable_muscle" android:key="muscleEnable" android:defaultValue="true"/>
|
<CheckBoxPreference android:title="@string/label_enable_muscle" android:summaryOn="@string/info_is_visible" android:summaryOff="@string/info_is_not_visible" android:key="muscleEnable" android:defaultValue="true"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Reference in New Issue
Block a user