mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-22 00:06:48 +02:00
Convert logging to use Timber
This commit is contained in:
@@ -26,7 +26,6 @@ import android.support.test.runner.screenshot.BasicScreenCaptureProcessor;
|
||||
import android.support.test.runner.screenshot.ScreenCapture;
|
||||
import android.support.test.runner.screenshot.Screenshot;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
||||
import com.health.openscale.R;
|
||||
@@ -51,6 +50,8 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.os.Environment.DIRECTORY_PICTURES;
|
||||
import static android.os.Environment.getExternalStoragePublicDirectory;
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
@@ -194,7 +195,7 @@ public class ScreenshotRecorder {
|
||||
try {
|
||||
scaleMeasurementList = CsvHelper.importFrom(new BufferedReader(new StringReader(data)));
|
||||
} catch (IOException | ParseException e) {
|
||||
Log.e("ScreenshotRecorder", e.getMessage());
|
||||
Timber.e(e);
|
||||
}
|
||||
|
||||
// set current year to the measurement data
|
||||
@@ -282,7 +283,7 @@ public class ScreenshotRecorder {
|
||||
|
||||
mActivityTestRule.finishActivity();
|
||||
} catch (InterruptedException e) {
|
||||
Log.e("ScreenshotRecorder", e.getMessage());
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,5 +29,8 @@ public class Application extends android.app.Application {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(new Timber.DebugTree());
|
||||
}
|
||||
|
||||
// Create OpenScale instance
|
||||
OpenScale.getInstance(getApplicationContext());
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,6 @@ import android.preference.PreferenceManager;
|
||||
import android.provider.OpenableColumns;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.health.openscale.R;
|
||||
@@ -69,6 +68,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class OpenScale {
|
||||
|
||||
public static final String DATABASE_NAME = "openScale.db";
|
||||
@@ -103,6 +104,7 @@ public class OpenScale {
|
||||
|
||||
public static OpenScale getInstance(Context context) {
|
||||
if (instance == null) {
|
||||
Timber.d("Creating instance");
|
||||
instance = new OpenScale(context.getApplicationContext());
|
||||
}
|
||||
|
||||
@@ -161,6 +163,7 @@ public class OpenScale {
|
||||
}
|
||||
|
||||
public void selectScaleUser(int userId) {
|
||||
Timber.d("Select user %d", userId);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
prefs.edit().putInt("selectedUserId", userId).apply();
|
||||
|
||||
@@ -202,6 +205,7 @@ public class OpenScale {
|
||||
return selectedScaleUser;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Timber.e(e);
|
||||
Toast.makeText(context, "Error: " + e.getMessage(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@@ -209,6 +213,7 @@ public class OpenScale {
|
||||
}
|
||||
|
||||
public void deleteScaleUser(int id) {
|
||||
Timber.d("Delete user %d", id);
|
||||
userDAO.delete(userDAO.get(id));
|
||||
selectedScaleUser = null;
|
||||
|
||||
@@ -531,8 +536,7 @@ public class OpenScale {
|
||||
}
|
||||
|
||||
public boolean connectToBluetoothDevice(String deviceName, String hwAddress, Handler callbackBtHandler) {
|
||||
Log.d("OpenScale", "Trying to connect to bluetooth device " + hwAddress
|
||||
+ " (" + deviceName + ")");
|
||||
Timber.d("Trying to connect to bluetooth device %s (%s)", hwAddress, deviceName);
|
||||
|
||||
disconnectFromBluetoothDevice();
|
||||
|
||||
@@ -552,7 +556,7 @@ public class OpenScale {
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.d("OpenScale", "Disconnecting from bluetooth device");
|
||||
Timber.d("Disconnecting from bluetooth device");
|
||||
btDeviceDriver.disconnect(true);
|
||||
btDeviceDriver = null;
|
||||
|
||||
|
@@ -23,7 +23,6 @@ import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.OpenScale;
|
||||
|
||||
@@ -32,6 +31,8 @@ import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class AlarmBackupHandler
|
||||
{
|
||||
public static final String INTENT_EXTRA_BACKUP_ALARM = "alarmBackupIntent";
|
||||
@@ -105,9 +106,9 @@ public class AlarmBackupHandler
|
||||
|
||||
try {
|
||||
openScale.exportDatabase(Uri.fromFile(exportFile));
|
||||
Log.d("AlarmBackupHandler", "openScale Auto Backup to " + exportFile);
|
||||
Timber.d("openScale Auto Backup to %s", exportFile);
|
||||
} catch (IOException e) {
|
||||
Log.e("AlarmBackupHandler", "Error while exporting database: " + e.getMessage());
|
||||
Timber.e(e, "Error while exporting database");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,6 @@ import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.R;
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
@@ -35,13 +34,14 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.content.Context.NOTIFICATION_SERVICE;
|
||||
|
||||
public class AlarmHandler
|
||||
{
|
||||
public static final String INTENT_EXTRA_ALARM = "alarmIntent";
|
||||
private static final int ALARM_NOTIFICATION_ID = 0x01;
|
||||
private static final String LOG_TAG = "AlarmBuilder";
|
||||
|
||||
public void scheduleAlarms(Context context)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ public class AlarmHandler
|
||||
|
||||
private void setRepeatingAlarm(Context context, int dayOfWeek, Calendar nextAlarmTimestamp)
|
||||
{
|
||||
Log.d(LOG_TAG, "Set repeating alarm for " + nextAlarmTimestamp.getTime());
|
||||
Timber.d("Set repeating alarm for %s", nextAlarmTimestamp.getTime());
|
||||
PendingIntent alarmPendingIntent = getPendingAlarmIntent(context, dayOfWeek);
|
||||
AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||
alarmMgr.setInexactRepeating(AlarmManager.RTC_WAKEUP, nextAlarmTimestamp.getTimeInMillis(),
|
||||
|
@@ -22,7 +22,6 @@ package com.health.openscale.core.bluetooth;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.R;
|
||||
import com.health.openscale.core.OpenScale;
|
||||
@@ -39,9 +38,9 @@ import java.util.Date;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
private final static String TAG = "BeurerSanitas";
|
||||
import timber.log.Timber;
|
||||
|
||||
public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
enum DeviceType { BEURER_BF700_800_RT_LIBRA, BEURER_BF710, SANITAS_SBF70_70 }
|
||||
|
||||
private static final int PRIMARY_SERVICE = 0x180A;
|
||||
@@ -196,7 +195,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
// Unknown user, request creation of new user
|
||||
if (countRegisteredScaleUsers == maxRegisteredScaleUser) {
|
||||
setBtMachineState(BT_MACHINE_STATE.BT_CLEANUP_STATE);
|
||||
Log.d(TAG, "Cannot create additional scale user");
|
||||
Timber.d("Cannot create additional scale user");
|
||||
sendMessage(R.string.error_max_scale_users, 0);
|
||||
break;
|
||||
}
|
||||
@@ -209,7 +208,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
byte[] nick = selectedUser.getUserName().toUpperCase().substring(0, maxIdx).getBytes();
|
||||
|
||||
byte activity = 2; // activity level: 1 - 5
|
||||
Log.d(TAG, "Create User:" + selectedUser.getUserName());
|
||||
Timber.d("Create User:" + selectedUser.getUserName());
|
||||
|
||||
writeBytes(new byte[]{
|
||||
(byte) startByte, (byte) 0x31, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
||||
@@ -224,14 +223,14 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
});
|
||||
} else {
|
||||
// Get existing user information
|
||||
Log.d(TAG, "Request getUserInfo " + currentScaleUserId);
|
||||
Timber.d("Request getUserInfo " + currentScaleUserId);
|
||||
writeBytes(new byte[]{
|
||||
(byte) startByte, (byte) 0x36, (byte) 0x0, (byte) 0x0, (byte) 0x0,
|
||||
(byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) currentScaleUserId
|
||||
});
|
||||
|
||||
}
|
||||
Log.d(TAG, "scaleuserid:" + currentScaleUserId + " registered users: " + countRegisteredScaleUsers +
|
||||
Timber.d("scaleuserid:" + currentScaleUserId + " registered users: " + countRegisteredScaleUsers +
|
||||
" extracted users: " + seenUsers.size());
|
||||
break;
|
||||
case 7:
|
||||
@@ -253,7 +252,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
if (currentScaleUserId == 0)
|
||||
break;
|
||||
|
||||
Log.d(TAG, "Request Saved User Measurements");
|
||||
Timber.d("Request Saved User Measurements");
|
||||
writeBytes(new byte[]{
|
||||
(byte) startByte, (byte) 0x41, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) currentScaleUserId
|
||||
});
|
||||
@@ -293,17 +292,17 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
return;
|
||||
|
||||
if ((data[0] & 0xFF) == getAlternativeStartByte(6) && (data[1] & 0xFF) == 0x00) {
|
||||
Log.d(TAG, "ACK Scale is ready");
|
||||
Timber.d("ACK Scale is ready");
|
||||
nextMachineStateStep();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && data[2] == 0x33) {
|
||||
Log.d(TAG, "ACK Got general user information");
|
||||
Timber.d("ACK Got general user information");
|
||||
|
||||
int count = (byte) (data[4] & 0xFF);
|
||||
int maxUsers = (byte) (data[5] & 0xFF);
|
||||
Log.d(TAG, "Count:" + count + " maxUsers:" + maxUsers);
|
||||
Timber.d("Count:" + count + " maxUsers:" + maxUsers);
|
||||
|
||||
countRegisteredScaleUsers = count;
|
||||
// Check if any scale user is registered
|
||||
@@ -317,7 +316,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x34) {
|
||||
Log.d(TAG, "Ack Get UUIDSs List of Users");
|
||||
Timber.d("Ack Get UUIDSs List of Users");
|
||||
|
||||
byte currentUserMax = (byte) (data[2] & 0xFF);
|
||||
byte currentUserID = (byte) (data[3] & 0xFF);
|
||||
@@ -340,7 +339,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
// We have seen all users: user is unknown
|
||||
currentScaleUserId = 0;
|
||||
}
|
||||
Log.d(TAG, "Send ack gotUser");
|
||||
Timber.d("Send ack gotUser");
|
||||
writeBytes(new byte[]{
|
||||
(byte) startByte, (byte) 0xf1, (byte) 0x34, currentUserMax,
|
||||
currentUserID
|
||||
@@ -351,7 +350,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xF0 && (data[2] & 0xFF) == 0x36) {
|
||||
Log.d(TAG, "Ack Get User Info Initials");
|
||||
Timber.d("Ack Get User Info Initials");
|
||||
String name = new String(data, 4, 3);
|
||||
byte year = (byte) (data[7] & 0xFF);
|
||||
byte month = (byte) (data[8] & 0xFF);
|
||||
@@ -361,7 +360,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
boolean male = (data[11] & 0xF0) != 0;
|
||||
byte activity = (byte) (data[11] & 0x0F);
|
||||
|
||||
Log.d(TAG, "Name " + name + " YY-MM-DD: " + year + " " + month + " " + day +
|
||||
Timber.d("Name " + name + " YY-MM-DD: " + year + " " + month + " " + day +
|
||||
"Height: " + height + " Sex:" + (male ? "M" : "F") + "activity: " + activity);
|
||||
|
||||
// Get scale status for user
|
||||
@@ -374,7 +373,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x4F) {
|
||||
Log.d(TAG, "Ack Get scale status");
|
||||
Timber.d("Ack Get scale status");
|
||||
|
||||
int unknown = data[3];
|
||||
int batteryLevel = (data[4] & 0xFF);
|
||||
@@ -386,7 +385,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
boolean userMeasurementExist = (data[10] == 0);
|
||||
int scaleVersion = data[11];
|
||||
|
||||
Log.d(TAG, "BatteryLevel:" + batteryLevel + " weightThreshold: " + weightThreshold +
|
||||
Timber.d("BatteryLevel:" + batteryLevel + " weightThreshold: " + weightThreshold +
|
||||
" BodyFatThresh: " + bodyFatThreshold + " Unit: " + unit + " userExists: " + userExists +
|
||||
" UserReference Weight Exists: " + userReferWeightExists + " UserMeasurementExists: " + userMeasurementExist +
|
||||
" scaleVersion: " + scaleVersion);
|
||||
@@ -394,7 +393,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && data[2] == 0x31) {
|
||||
Log.d(TAG, "Acknowledge creation of user");
|
||||
Timber.d("Acknowledge creation of user");
|
||||
|
||||
// Indicate user to step on scale
|
||||
sendMessage(R.string.info_step_on_scale, 0);
|
||||
@@ -410,16 +409,16 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x41) {
|
||||
Log.d(TAG, "Will start to receive measurements User Specific");
|
||||
Timber.d("Will start to receive measurements User Specific");
|
||||
|
||||
byte nr_measurements = data[3];
|
||||
|
||||
Log.d(TAG, "New measurements: " + nr_measurements / 2);
|
||||
Timber.d("New measurements: " + nr_measurements / 2);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x42) {
|
||||
Log.d(TAG, "Specific measurement User specific");
|
||||
Timber.d("Specific measurement User specific");
|
||||
|
||||
// Measurements are split into two parts
|
||||
|
||||
@@ -448,7 +447,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
ScaleMeasurement parsedData = parseScaleData(receivedScaleData.toByteArray());
|
||||
addScaleData(parsedData);
|
||||
} catch (ParseException e) {
|
||||
Log.d(TAG, "Could not parse byte array: " + byteInHex(receivedScaleData.toByteArray()));
|
||||
Timber.d(e, "Could not parse byte array: " + byteInHex(receivedScaleData.toByteArray()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -461,7 +460,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x58) {
|
||||
Log.d(TAG, "Active measurement");
|
||||
Timber.d("Active measurement");
|
||||
float weight = getKiloGram(data, 3);
|
||||
if ((data[2] & 0xFF) != 0x00) {
|
||||
// temporary value;
|
||||
@@ -469,7 +468,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG, "Got weight: " + weight);
|
||||
Timber.i("Got weight: " + weight);
|
||||
|
||||
writeBytes(new byte[]{
|
||||
(byte) startByte, (byte) 0xf1, (byte) (data[1] & 0xFF),
|
||||
@@ -481,7 +480,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0x59) {
|
||||
// Get stable measurement results
|
||||
Log.d(TAG, "Get measurement data " + ((int) data[3]));
|
||||
Timber.d("Get measurement data " + ((int) data[3]));
|
||||
|
||||
int max_items = (data[2] & 0xFF);
|
||||
int current_item = (data[3] & 0xFF);
|
||||
@@ -512,7 +511,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
// Delete data
|
||||
deleteScaleData();
|
||||
} catch (ParseException e) {
|
||||
Log.d(TAG, "Parse Exception " + byteInHex(receivedScaleData.toByteArray()));
|
||||
Timber.d(e, "Parse Exception " + byteInHex(receivedScaleData.toByteArray()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,11 +519,11 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
}
|
||||
|
||||
if ((data[0] & 0xFF) == startByte && (data[1] & 0xFF) == 0xf0 && (data[2] & 0xFF) == 0x43) {
|
||||
Log.d(TAG, "Acknowledge: Data deleted.");
|
||||
Timber.d("Acknowledge: Data deleted.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "DataChanged - not handled: " + byteInHex(data));
|
||||
Timber.d("DataChanged - not handled: " + byteInHex(data));
|
||||
}
|
||||
|
||||
private void deleteScaleData() {
|
||||
@@ -569,7 +568,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
receivedMeasurement.setMuscle(muscle);
|
||||
receivedMeasurement.setBone(bone);
|
||||
|
||||
Log.i(TAG, "Measurement: " + receivedMeasurement.getDateTime().toString() +
|
||||
Timber.i("Measurement: " + receivedMeasurement.getDateTime().toString() +
|
||||
" Impedance: " + impedance + " Weight:" + weight +
|
||||
" Fat: " + fat + " Water: " + water + " Muscle: " + muscle +
|
||||
" Bone: " + bone + " BMR: " + bmr + " AMR: " + amr + " BMI: " + bmi);
|
||||
@@ -581,7 +580,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
// Update date/time of the scale
|
||||
long unixTime = System.currentTimeMillis() / 1000L;
|
||||
byte[] unixTimeBytes = Converters.toUnsignedInt32Be(unixTime);
|
||||
Log.d(TAG, "Write new Date/Time:" + unixTime + " " + byteInHex(unixTimeBytes));
|
||||
Timber.d("Write new Date/Time:" + unixTime + " " + byteInHex(unixTimeBytes));
|
||||
|
||||
writeBytes(new byte[]{(byte) getAlternativeStartByte(9),
|
||||
unixTimeBytes[0], unixTimeBytes[1], unixTimeBytes[2], unixTimeBytes[3]});
|
||||
@@ -602,7 +601,7 @@ public class BluetoothBeurerSanitas extends BluetoothCommunication {
|
||||
command[2] = (byte) 0x04;
|
||||
break;
|
||||
}
|
||||
Log.d(TAG, "Setting unit " + selectedUser.getScaleUnit().toString());
|
||||
Timber.d("Setting unit " + selectedUser.getScaleUnit().toString());
|
||||
writeBytes(command);
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,6 @@ import android.bluetooth.BluetoothGattDescriptor;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
|
||||
@@ -33,6 +32,8 @@ import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public abstract class BluetoothCommunication {
|
||||
public enum BT_STATUS_CODE {BT_RETRIEVE_SCALE_DATA, BT_INIT_PROCESS, BT_CONNECTION_ESTABLISHED,
|
||||
BT_CONNECTION_LOST, BT_NO_DEVICE_FOUND, BT_UNEXPECTED_ERROR, BT_SCALE_MESSAGE
|
||||
@@ -300,7 +301,7 @@ public abstract class BluetoothCommunication {
|
||||
*/
|
||||
protected String byteInHex(byte[] data) {
|
||||
if (data == null) {
|
||||
Log.e("BluetoothCommunication", "Data is null");
|
||||
Timber.e("Data is null");
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -377,7 +378,7 @@ public abstract class BluetoothCommunication {
|
||||
protected void nextMachineStateStep() {
|
||||
switch (btMachineState) {
|
||||
case BT_INIT_STATE:
|
||||
Log.d("BluetoothCommunication", "INIT STATE: " + initStepNr);
|
||||
Timber.d("INIT STATE: " + initStepNr);
|
||||
if (!nextInitCmd(initStepNr)) {
|
||||
btMachineState = BT_MACHINE_STATE.BT_CMD_STATE;
|
||||
nextMachineStateStep();
|
||||
@@ -385,12 +386,12 @@ public abstract class BluetoothCommunication {
|
||||
initStepNr++;
|
||||
break;
|
||||
case BT_CMD_STATE:
|
||||
Log.d("BluetoothCommunication", "CMD STATE: " + cmdStepNr);
|
||||
Timber.d("CMD STATE: " + cmdStepNr);
|
||||
nextBluetoothCmd(cmdStepNr);
|
||||
cmdStepNr++;
|
||||
break;
|
||||
case BT_CLEANUP_STATE:
|
||||
Log.d("BluetoothCommunication", "CLEANUP STATE: " + cleanupStepNr);
|
||||
Timber.d("CLEANUP STATE: " + cleanupStepNr);
|
||||
nextCleanUpCmd(cleanupStepNr);
|
||||
cleanupStepNr++;
|
||||
break;
|
||||
@@ -408,7 +409,7 @@ public abstract class BluetoothCommunication {
|
||||
BluetoothGattDescriptor descriptorRequest = descriptorRequestQueue.poll();
|
||||
if (descriptorRequest != null) {
|
||||
if (!bluetoothGatt.writeDescriptor(descriptorRequest)) {
|
||||
Log.d("BTC", "Descriptor Write failed(" + byteInHex(descriptorRequest.getValue()) + ")");
|
||||
Timber.d("Descriptor Write failed(" + byteInHex(descriptorRequest.getValue()) + ")");
|
||||
}
|
||||
openRequest = true;
|
||||
return;
|
||||
@@ -418,7 +419,7 @@ public abstract class BluetoothCommunication {
|
||||
BluetoothGattCharacteristic characteristicRequest = characteristicRequestQueue.poll();
|
||||
if (characteristicRequest != null) {
|
||||
if (!bluetoothGatt.writeCharacteristic(characteristicRequest)) {
|
||||
Log.d("BTC", "Characteristic Write failed(" + byteInHex(characteristicRequest.getValue()) + ")");
|
||||
Timber.d("Characteristic Write failed(" + byteInHex(characteristicRequest.getValue()) + ")");
|
||||
}
|
||||
openRequest = true;
|
||||
return;
|
||||
|
@@ -18,7 +18,6 @@ package com.health.openscale.core.bluetooth;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
|
||||
@@ -29,6 +28,8 @@ import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class BluetoothCustomOpenScale extends BluetoothCommunication {
|
||||
private final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Standard SerialPortService ID
|
||||
|
||||
@@ -201,13 +202,13 @@ public class BluetoothCustomOpenScale extends BluetoothCommunication {
|
||||
|
||||
switch (btString.charAt(1)) {
|
||||
case 'I':
|
||||
Log.i("OpenScale", "MCU Information: " + btMsg);
|
||||
Timber.i("MCU Information: " + btMsg);
|
||||
break;
|
||||
case 'E':
|
||||
Log.e("OpenScale", "MCU Error: " + btMsg);
|
||||
Timber.e("MCU Error: " + btMsg);
|
||||
break;
|
||||
case 'S':
|
||||
Log.i("OpenScale", "MCU stored data size: " + btMsg);
|
||||
Timber.i("MCU stored data size: " + btMsg);
|
||||
break;
|
||||
case 'D':
|
||||
String[] csvField = btMsg.split(",");
|
||||
|
@@ -19,7 +19,6 @@ package com.health.openscale.core.bluetooth;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.OpenScale;
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
@@ -28,6 +27,8 @@ import com.health.openscale.core.datatypes.ScaleUser;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class BluetoothDigooDGSO38H extends BluetoothCommunication {
|
||||
private final UUID WEIGHT_MEASUREMENT_SERVICE = UUID.fromString("0000fff0-0000-1000-8000-00805f9b34fb");
|
||||
private final UUID WEIGHT_MEASUREMENT_CHARACTERISTIC = UUID.fromString("0000fff1-0000-1000-8000-00805f9b34fb");
|
||||
@@ -120,8 +121,8 @@ public class BluetoothDigooDGSO38H extends BluetoothCommunication {
|
||||
weight = (float) (((weightBytes[3] & 0xFF) << 8) | (weightBytes[4] & 0xFF)) / 100.0f;
|
||||
fat = (float) (((weightBytes[6] & 0xFF) << 8) | (weightBytes[7] & 0xFF)) / 10.0f;
|
||||
if (Math.abs(fat - 0.0) < 0.00001) {
|
||||
Log.d("BluetoothDigooDGSO38H", "Scale signaled that measurement of all data " +
|
||||
"is done, but fat ist still zero. Settling for just adding weight.");
|
||||
Timber.d("Scale signaled that measurement of all data " +
|
||||
"is done, but fat is still zero. Settling for just adding weight.");
|
||||
} else {
|
||||
//subcutaneousFat = (float) (((weightBytes[8] & 0xFF) << 8) | (weightBytes[9] & 0xFF)) / 10.0f;
|
||||
//visceralFat = (float) (weightBytes[10] & 0xFF) / 10.0f;
|
||||
|
@@ -20,7 +20,6 @@ package com.health.openscale.core.bluetooth;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothSocket;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
|
||||
@@ -31,6 +30,8 @@ import java.util.UUID;
|
||||
import java.util.Date;
|
||||
import java.util.Arrays;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
private final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Standard SerialPortService ID
|
||||
|
||||
@@ -55,19 +56,19 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
@Override
|
||||
protected boolean nextInitCmd(int stateNr) {
|
||||
Log.w("openscale","ihealthHS3 - nextInitCmd - returning false");
|
||||
Timber.w("ihealthHS3 - nextInitCmd - returning false");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean nextBluetoothCmd(int stateNr) {
|
||||
Log.w("openscale","ihealthHS3 - nextBluetoothCmd - returning false");
|
||||
Timber.w("ihealthHS3 - nextBluetoothCmd - returning false");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean nextCleanUpCmd(int stateNr) {
|
||||
Log.w("openscale","ihealthHS3 - nextCleanUpCmd - returning false");
|
||||
Timber.w("ihealthHS3 - nextCleanUpCmd - returning false");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
@Override
|
||||
public void disconnect(boolean doCleanup) {
|
||||
|
||||
Log.w("openscale","HS3 - disconnect");
|
||||
Timber.w("HS3 - disconnect");
|
||||
if (btSocket != null) {
|
||||
if (btSocket.isConnected()) {
|
||||
try {
|
||||
@@ -140,7 +141,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
|
||||
private boolean sendBtData(String data) {
|
||||
Log.w("openscale","ihealthHS3 - sendBtData"+data);
|
||||
Timber.w("ihealthHS3 - sendBtData"+data);
|
||||
if (btSocket.isConnected()) {
|
||||
btConnectThread = new BluetoothConnectedThread();
|
||||
btConnectThread.write(data.getBytes());
|
||||
@@ -149,7 +150,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
return true;
|
||||
}
|
||||
Log.w("openscale","ihealthHS3 - sendBtData - socket is not connected");
|
||||
Timber.w("ihealthHS3 - sendBtData - socket is not connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
private volatile boolean isCancel;
|
||||
|
||||
public BluetoothConnectedThread() {
|
||||
// Log.w("openscale","ihealthHS3 - BluetoothConnectedThread");
|
||||
// Timber.w("ihealthHS3 - BluetoothConnectedThread");
|
||||
isCancel = false;
|
||||
|
||||
// Get the input and output bluetooth streams
|
||||
@@ -175,14 +176,14 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
byte btByte;
|
||||
byte[] weightBytes = new byte[2];
|
||||
// Log.w("openscale","ihealthHS3 - run");
|
||||
// Timber.w("ihealthHS3 - run");
|
||||
// Keep listening to the InputStream until an exception occurs (e.g. device partner goes offline)
|
||||
while (!isCancel) {
|
||||
try {
|
||||
// stream read is a blocking method
|
||||
|
||||
btByte = (byte) btInStream.read();
|
||||
// Log.w("openscale","iheathHS3 - seen a byte "+String.format("%02X",btByte));
|
||||
// Timber.w("iheathHS3 - seen a byte "+String.format("%02X",btByte));
|
||||
|
||||
if ( btByte == (byte) 0xA0 ) {
|
||||
btByte = (byte) btInStream.read();
|
||||
@@ -191,7 +192,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
if ( btByte == (byte) 0xa6 ) {
|
||||
btByte = (byte) btInStream.read();
|
||||
if ( btByte == (byte) 0x28 ) {
|
||||
// Log.w("openscale","seen 0xa009a628 - Weight packet");
|
||||
// Timber.w("seen 0xa009a628 - Weight packet");
|
||||
// deal with a weight packet - read 5 bytes we dont care about
|
||||
btByte = (byte) btInStream.read();
|
||||
btByte = (byte) btInStream.read();
|
||||
@@ -210,10 +211,10 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
}
|
||||
else if (btByte == (byte) 0x33 ) {
|
||||
Log.w("openscale","seen 0xa009a633 - time packet");
|
||||
Timber.w("seen 0xa009a633 - time packet");
|
||||
// deal with a time packet, if needed
|
||||
} else {
|
||||
Log.w("openscale","iHealthHS3 - seen byte after control leader "+String.format("%02X",btByte));
|
||||
Timber.w("iHealthHS3 - seen byte after control leader "+String.format("%02X",btByte));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +232,7 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
private ScaleMeasurement parseWeightArray(byte[] weightBytes ) throws IOException {
|
||||
ScaleMeasurement scaleBtData = new ScaleMeasurement();
|
||||
|
||||
// Log.w("openscale","iHealthHS3 - ScaleMeasurement "+String.format("%02X",weightBytes[0])+String.format("%02X",weightBytes[1]));
|
||||
// Timber.w("iHealthHS3 - ScaleMeasurement "+String.format("%02X",weightBytes[0])+String.format("%02X",weightBytes[1]));
|
||||
|
||||
String ws = String.format("%02X",weightBytes[0])+String.format("%02X",weightBytes[1]);
|
||||
StringBuilder ws1 = new StringBuilder (ws);
|
||||
@@ -239,13 +240,13 @@ public class BluetoothIhealthHS3 extends BluetoothCommunication {
|
||||
|
||||
|
||||
float weight = Float.parseFloat(ws1.toString());
|
||||
// Log.w("openscale","iHealthHS3 - ScaleMeasurement "+String.format("%f",weight));
|
||||
// Timber.w("iHealthHS3 - ScaleMeasurement "+String.format("%f",weight));
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
// If the weight is the same as the lastWeight, and the time since the last reading is less than maxTimeDiff then return null
|
||||
if (Arrays.equals(weightBytes,lastWeight) && (now.getTime() - lastWeighed.getTime() < maxTimeDiff)) {
|
||||
// Log.w("openscale","iHealthHS3 - parseWeightArray returning null");
|
||||
// Timber.w("iHealthHS3 - parseWeightArray returning null");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.OpenScale;
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
@@ -35,6 +34,8 @@ import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.health.openscale.core.bluetooth.BluetoothCommunication.BT_STATUS_CODE.BT_UNEXPECTED_ERROR;
|
||||
|
||||
public class BluetoothMiScale extends BluetoothCommunication {
|
||||
@@ -67,7 +68,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
||||
if (currentYear == scaleYear && currentMonth == scaleMonth && currentDay == scaleDay) {
|
||||
setBtMachineState(BT_MACHINE_STATE.BT_CMD_STATE);
|
||||
} else {
|
||||
Log.d("BluetoothMiScale", "Current year and scale year is different");
|
||||
Timber.d("Current year and scale year is different");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,14 +204,14 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
||||
final boolean isLBSUnit = isBitSet(ctrlByte, 0);
|
||||
final boolean isCattyUnit = isBitSet(ctrlByte, 4);
|
||||
|
||||
/*Log.d("GattCallback", "IsWeightRemoved: " + isBitSet(ctrlByte, 7));
|
||||
Log.d("GattCallback", "6 LSB Unknown: " + isBitSet(ctrlByte, 6));
|
||||
Log.d("GattCallback", "IsStabilized: " + isBitSet(ctrlByte, 5));
|
||||
Log.d("GattCallback", "IsCattyOrKg: " + isBitSet(ctrlByte, 4));
|
||||
Log.d("GattCallback", "3 LSB Unknown: " + isBitSet(ctrlByte, 3));
|
||||
Log.d("GattCallback", "2 LSB Unknown: " + isBitSet(ctrlByte, 2));
|
||||
Log.d("GattCallback", "1 LSB Unknown: " + isBitSet(ctrlByte, 1));
|
||||
Log.d("GattCallback", "IsLBS: " + isBitSet(ctrlByte, 0));*/
|
||||
/*Timber.d("IsWeightRemoved: " + isBitSet(ctrlByte, 7));
|
||||
Timber.d("6 LSB Unknown: " + isBitSet(ctrlByte, 6));
|
||||
Timber.d("IsStabilized: " + isBitSet(ctrlByte, 5));
|
||||
Timber.d("IsCattyOrKg: " + isBitSet(ctrlByte, 4));
|
||||
Timber.d("3 LSB Unknown: " + isBitSet(ctrlByte, 3));
|
||||
Timber.d("2 LSB Unknown: " + isBitSet(ctrlByte, 2));
|
||||
Timber.d("1 LSB Unknown: " + isBitSet(ctrlByte, 1));
|
||||
Timber.d("IsLBS: " + isBitSet(ctrlByte, 0));*/
|
||||
|
||||
// Only if the value is stabilized and the weight is *not* removed, the date is valid
|
||||
if (isStabilized && !isWeightRemoved) {
|
||||
@@ -242,7 +243,7 @@ public class BluetoothMiScale extends BluetoothCommunication {
|
||||
|
||||
addScaleData(scaleBtData);
|
||||
} else {
|
||||
Log.e("BluetoothMiScale", "Invalid Mi scale weight year " + year);
|
||||
Timber.e("Invalid Mi scale weight year " + year);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
|
@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.OpenScale;
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
@@ -35,6 +34,8 @@ import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.health.openscale.core.bluetooth.BluetoothCommunication.BT_STATUS_CODE.BT_UNEXPECTED_ERROR;
|
||||
|
||||
public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
@@ -62,7 +63,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
final byte[] data = gattCharacteristic.getValue();
|
||||
|
||||
if (data != null && data.length > 0) {
|
||||
Log.d("MIScale_v2", "DataChange hex data: "+ byteInHex(data));
|
||||
Timber.d("DataChange hex data: "+ byteInHex(data));
|
||||
|
||||
// Stop command from mi scale received
|
||||
if (data[0] == 0x03) {
|
||||
@@ -213,7 +214,7 @@ public class BluetoothMiScale2 extends BluetoothCommunication {
|
||||
|
||||
addScaleData(scaleBtData);
|
||||
} else {
|
||||
Log.e("BluetoothMiScale", "Invalid Mi scale weight year " + year);
|
||||
Timber.e("Invalid Mi scale weight year " + year);
|
||||
}
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
|
@@ -21,7 +21,6 @@ import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.datatypes.ScaleMeasurement;
|
||||
|
||||
@@ -30,6 +29,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 6;
|
||||
public static final String DATABASE_NAME = "openScaleDatabase.db";
|
||||
@@ -143,7 +144,7 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
|
||||
cursorScaleDB.close();
|
||||
} catch (SQLException ex) {
|
||||
Log.e("ScaleDatabase", "SQL exception occurred while getting scale data list: " + ex.getMessage());
|
||||
Timber.e(ex, "SQL exception occurred while getting scale data list");
|
||||
}
|
||||
|
||||
return scaleMeasurementList;
|
||||
@@ -169,10 +170,10 @@ public class ScaleDatabase extends SQLiteOpenHelper {
|
||||
|
||||
scaleMeasurement.setDateTime(formatDateTime.parse(date_time));
|
||||
} catch (ParseException ex) {
|
||||
Log.e("ScaleDatabase", "Can't parse the date time string: " + ex.getMessage());
|
||||
Timber.e(ex, "Can't parse the date time string");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
|
||||
Timber.e(ex, "Illegal argument while reading from scale database");
|
||||
}
|
||||
|
||||
return scaleMeasurement;
|
||||
|
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.datatypes.ScaleUser;
|
||||
import com.health.openscale.core.utils.Converters;
|
||||
@@ -30,6 +29,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
public class ScaleUserDatabase extends SQLiteOpenHelper {
|
||||
private static final int DATABASE_VERSION = 3;
|
||||
public static final String DATABASE_NAME = "openScaleUserDatabase.db";
|
||||
@@ -143,10 +144,10 @@ public class ScaleUserDatabase extends SQLiteOpenHelper {
|
||||
scaleUser.setInitialWeight(Math.round(initial_weight * 100.0f) / 100.0f);
|
||||
scaleUser.setGoalWeight(Math.round(goal_weight * 100.0f) / 100.0f);
|
||||
} catch (ParseException ex) {
|
||||
Log.e("ScaleDatabase", "Can't parse the date time string: " + ex.getMessage());
|
||||
Timber.e(ex, "Can't parse the date time string");
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
|
||||
Timber.e(ex, "Illegal argument while reading from scale database");
|
||||
}
|
||||
|
||||
return scaleUser;
|
||||
|
@@ -21,7 +21,6 @@ import android.arch.persistence.room.Entity;
|
||||
import android.arch.persistence.room.ForeignKey;
|
||||
import android.arch.persistence.room.Index;
|
||||
import android.arch.persistence.room.PrimaryKey;
|
||||
import android.util.Log;
|
||||
|
||||
import com.health.openscale.core.utils.Converters;
|
||||
import com.j256.simplecsv.common.CsvColumn;
|
||||
@@ -29,6 +28,8 @@ import com.j256.simplecsv.common.CsvColumn;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
@Entity(tableName = "scaleMeasurements",
|
||||
indices = {@Index(value = {"userId", "datetime"}, unique = true)},
|
||||
foreignKeys = @ForeignKey(
|
||||
@@ -119,7 +120,7 @@ public class ScaleMeasurement implements Cloneable {
|
||||
field.setAccessible(false);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("ScaleMeasurement", "Error: " + e.getMessage());
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +137,7 @@ public class ScaleMeasurement implements Cloneable {
|
||||
field.setAccessible(false);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("ScaleMeasurement", "Error: " + e.getMessage());
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ public class ScaleMeasurement implements Cloneable {
|
||||
field.setAccessible(false);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("ScaleMeasurement", "Error: " + e.getMessage());
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,6 @@ import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
@@ -69,6 +68,7 @@ import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import cat.ereza.customactivityoncrash.config.CaocConfig;
|
||||
import timber.log.Timber;
|
||||
|
||||
public class MainActivity extends BaseAppCompatActivity
|
||||
implements SharedPreferences.OnSharedPreferenceChangeListener{
|
||||
@@ -495,27 +495,27 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
case BT_INIT_PROCESS:
|
||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_success);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_init), Toast.LENGTH_SHORT).show();
|
||||
Log.d("OpenScale", "Bluetooth initializing");
|
||||
Timber.d("Bluetooth initializing");
|
||||
break;
|
||||
case BT_CONNECTION_LOST:
|
||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_connection_lost), Toast.LENGTH_SHORT).show();
|
||||
Log.d("OpenScale", "Bluetooth connection lost");
|
||||
Timber.d("Bluetooth connection lost");
|
||||
break;
|
||||
case BT_NO_DEVICE_FOUND:
|
||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_no_device), Toast.LENGTH_SHORT).show();
|
||||
Log.d("OpenScale", "No Bluetooth device found");
|
||||
Timber.d("No Bluetooth device found");
|
||||
break;
|
||||
case BT_CONNECTION_ESTABLISHED:
|
||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_success);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_connection_successful), Toast.LENGTH_SHORT).show();
|
||||
Log.d("OpenScale", "Bluetooth connection successful established");
|
||||
Timber.d("Bluetooth connection successful established");
|
||||
break;
|
||||
case BT_UNEXPECTED_ERROR:
|
||||
setBluetoothStatusIcon(R.drawable.ic_bluetooth_connection_lost);
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_connection_error) + ": " + msg.obj, Toast.LENGTH_SHORT).show();
|
||||
Log.e("OpenScale", "Bluetooth unexpected error: " + msg.obj);
|
||||
Timber.e("Bluetooth unexpected error: " + msg.obj);
|
||||
break;
|
||||
case BT_SCALE_MESSAGE:
|
||||
String toastMessage = String.format(getResources().getString(msg.arg1), msg.obj);
|
||||
@@ -734,9 +734,9 @@ public class MainActivity extends BaseAppCompatActivity
|
||||
item.setChecked(item.getItemData().isChecked());
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e("BNVHelper", "Unable to get shift mode field", e);
|
||||
Timber.e(e, "Unable to get shift mode field");
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("BNVHelper", "Unable to change value of shift mode", e);
|
||||
Timber.e(e, "Unable to change value of shift mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user