reformat code
This commit is contained in:
parent
c4590d3989
commit
dbbcf20bbc
|
@ -176,6 +176,7 @@ public class GB {
|
|||
* Creates and display a Toast message using the application context.
|
||||
* Additionally the toast is logged using the provided severity.
|
||||
* Can be called from any thread.
|
||||
*
|
||||
* @param message the message to display.
|
||||
* @param displayTime something like Toast.LENGTH_SHORT
|
||||
* @param severity either INFO, WARNING, ERROR
|
||||
|
@ -188,6 +189,7 @@ public class GB {
|
|||
* Creates and display a Toast message using the application context.
|
||||
* Additionally the toast is logged using the provided severity.
|
||||
* Can be called from any thread.
|
||||
*
|
||||
* @param message the message to display.
|
||||
* @param displayTime something like Toast.LENGTH_SHORT
|
||||
* @param severity either INFO, WARNING, ERROR
|
||||
|
@ -199,6 +201,7 @@ public class GB {
|
|||
/**
|
||||
* Creates and display a Toast message using the application context
|
||||
* Can be called from any thread.
|
||||
*
|
||||
* @param context the context to use
|
||||
* @param message the message to display
|
||||
* @param displayTime something like Toast.LENGTH_SHORT
|
||||
|
@ -211,6 +214,7 @@ public class GB {
|
|||
/**
|
||||
* Creates and display a Toast message using the application context
|
||||
* Can be called from any thread.
|
||||
*
|
||||
* @param context the context to use
|
||||
* @param message the message to display
|
||||
* @param displayTime something like Toast.LENGTH_SHORT
|
||||
|
|
|
@ -24,7 +24,6 @@ import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
|||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.charts.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.charts.SleepUtils;
|
||||
|
||||
public abstract class AbstractChartFragment extends Fragment {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -13,13 +12,10 @@ import android.support.v4.app.FragmentPagerAdapter;
|
|||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.github.mikephil.charting.utils.ValueFormatter;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -97,7 +96,7 @@ public class SleepChartFragment extends AbstractChartFragment {
|
|||
set.setValueFormatter(new ValueFormatter() {
|
||||
@Override
|
||||
public String getFormattedValue(float value) {
|
||||
return GB.formatDurationHoursMinutes((long)value, TimeUnit.SECONDS);
|
||||
return GB.formatDurationHoursMinutes((long) value, TimeUnit.SECONDS);
|
||||
}
|
||||
});
|
||||
set.setColors(colors);
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
|||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* The Bluedroid implementation only allows performing one GATT request at a time.
|
||||
|
|
|
@ -188,7 +188,7 @@ public final class BtLEQueue {
|
|||
// To support automatic reconnection, we keep the mBluetoothGatt instance
|
||||
// alive (we do not close() it). Unfortunately we sometimes have problems
|
||||
// reconnecting automatically, so we try to fix this by re-creating mBluetoothGatt.
|
||||
if (status != 0 ) {
|
||||
if (status != 0) {
|
||||
maybeReconnect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package nodomain.freeyourgadget.gadgetbridge.charts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
|
@ -13,7 +12,7 @@ public class ActivityAnalysis {
|
|||
|
||||
ActivityAmount previousAmount = null;
|
||||
GBActivitySample previousSample = null;
|
||||
for(GBActivitySample sample : samples) {
|
||||
for (GBActivitySample sample : samples) {
|
||||
ActivityAmount amount = null;
|
||||
switch (sample.getType()) {
|
||||
case GBActivitySample.TYPE_DEEP_SLEEP:
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
|
@ -132,6 +131,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper {
|
|||
/**
|
||||
* Returns all available activity samples from between the two timestamps (inclusive), of the given
|
||||
* provided and type(s).
|
||||
*
|
||||
* @param timestamp_from
|
||||
* @param timestamp_to
|
||||
* @param activityTypes ORed combination of #TYPE_DEEP_SLEEP, #TYPE_LIGHT_SLEEP, #TYPE_ACTIVITY
|
||||
|
@ -143,7 +143,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper {
|
|||
timestamp_to = Integer.MAX_VALUE; // dont know what happens when I use more than max of a signed int
|
||||
}
|
||||
ArrayList<GBActivitySample> GBActivitySampleList = new ArrayList<GBActivitySample>();
|
||||
final String where = "(provider=" + provider + " and timestamp>=" + timestamp_from + " and timestamp<=" + timestamp_to + getWhereClauseFor(activityTypes) +")";
|
||||
final String where = "(provider=" + provider + " and timestamp>=" + timestamp_from + " and timestamp<=" + timestamp_to + getWhereClauseFor(activityTypes) + ")";
|
||||
final String order = "timestamp";
|
||||
try (SQLiteDatabase db = this.getReadableDatabase()) {
|
||||
Cursor cursor = db.query(TABLE_GBACTIVITYSAMPLES, null, where, null, null, null, order);
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -7,10 +7,11 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
* Implementors provide the update from the prior schema
|
||||
* version to this version, and the downgrade from this schema
|
||||
* version to the next lower version.
|
||||
*
|
||||
* <p/>
|
||||
* Implementations must have a public, no-arg constructor.
|
||||
*/
|
||||
public interface DBUpdateScript {
|
||||
void upgradeSchema(SQLiteDatabase database);
|
||||
|
||||
void downgradeSchema(SQLiteDatabase database);
|
||||
}
|
||||
|
|
|
@ -3,9 +3,13 @@ package nodomain.freeyourgadget.gadgetbridge.database.schema;
|
|||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.*;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_INTENSITY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_PROVIDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TIMESTAMP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TYPE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||
|
||||
public class ActivityDBCreationScript {
|
||||
public void createSchema(SQLiteDatabase db) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
|||
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_GBACTIVITYSAMPLES;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_STEPS_PER_DAY;
|
||||
|
||||
/**
|
||||
* Upgrade and downgrade with DB versions <= 5 is not supported.
|
||||
|
|
|
@ -5,7 +5,10 @@ import android.database.sqlite.SQLiteDatabase;
|
|||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.*;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_PROVIDER;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_STEPS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_TIMESTAMP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.TABLE_STEPS_PER_DAY;
|
||||
|
||||
/**
|
||||
* Adds a table "STEPS_PER_DAY".
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.Calendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
|
|
|
@ -74,6 +74,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
//same as above, but remains untouched for the ack message
|
||||
public GregorianCalendar activityDataTimestampToAck = null;
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MiBandSupport.class);
|
||||
private volatile boolean telephoneRinging;
|
||||
private volatile boolean isLocatingDevice;
|
||||
|
@ -503,18 +504,18 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
|
||||
private byte[] getLatency(int minConnectionInterval, int maxConnectionInterval, int latency, int timeout, int advertisementInterval) {
|
||||
byte result[] = new byte[12];
|
||||
result[0] = (byte)(minConnectionInterval & 0xff);
|
||||
result[1] = (byte)(0xff & minConnectionInterval >> 8);
|
||||
result[2] = (byte)(maxConnectionInterval & 0xff);
|
||||
result[0] = (byte) (minConnectionInterval & 0xff);
|
||||
result[1] = (byte) (0xff & minConnectionInterval >> 8);
|
||||
result[2] = (byte) (maxConnectionInterval & 0xff);
|
||||
result[3] = (byte) (0xff & maxConnectionInterval >> 8);
|
||||
result[4] = (byte)(latency & 0xff);
|
||||
result[5] = (byte)(0xff & latency >> 8);
|
||||
result[6] = (byte)(timeout & 0xff);
|
||||
result[4] = (byte) (latency & 0xff);
|
||||
result[5] = (byte) (0xff & latency >> 8);
|
||||
result[6] = (byte) (timeout & 0xff);
|
||||
result[7] = (byte) (0xff & timeout >> 8);
|
||||
result[8] = 0;
|
||||
result[9] = 0;
|
||||
result[10] = (byte)(advertisementInterval & 0xff);
|
||||
result[11] = (byte)(0xff & advertisementInterval >> 8);
|
||||
result[10] = (byte) (advertisementInterval & 0xff);
|
||||
result[11] = (byte) (0xff & advertisementInterval >> 8);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -780,7 +781,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
|||
|
||||
//The last data chunk sent by the miband has always length 0.
|
||||
//When we ack this chunk, the transfer is done.
|
||||
if(getDevice().isBusy() && bytesTransferred==0) {
|
||||
if (getDevice().isBusy() && bytesTransferred == 0) {
|
||||
handleActivityFetchFinish();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class GadgetbridgePblSupport {
|
|||
break;
|
||||
case KEY_SAMPLES:
|
||||
byte[] samples = (byte[]) pair.second;
|
||||
LOG.info("got " + samples.length/2 + " samples");
|
||||
LOG.info("got " + samples.length / 2 + " samples");
|
||||
ByteBuffer samplesBuffer = ByteBuffer.wrap(samples);
|
||||
// TODO: read samples and put into database
|
||||
break;
|
||||
|
|
|
@ -11,6 +11,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
|||
public class FileUtils {
|
||||
/**
|
||||
* Copies the the given sourceFile to destFile, overwriting it, in case it exists.
|
||||
*
|
||||
* @param sourceFile
|
||||
* @param destFile
|
||||
* @throws IOException
|
||||
|
@ -30,6 +31,7 @@ public class FileUtils {
|
|||
|
||||
/**
|
||||
* Returns the existing external storage dir.
|
||||
*
|
||||
* @throws IOException when the directory is not available
|
||||
*/
|
||||
public static File getExternalFilesDir() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue