mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-12 21:19:25 +01:00
Remove/document deprecated stuff
This commit is contained in:
parent
e139840fee
commit
ae2df2580c
@ -1,40 +1,24 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.database;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.schema.ActivityDBCreationScript;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.schema.SchemaMigration;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.DATABASE_NAME;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.database.DBConstants.KEY_CUSTOM_SHORT;
|
||||
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;
|
||||
|
||||
// TODO: can be removed entirely
|
||||
/**
|
||||
* @deprecated can be removed entirely, only used for backwards compatibility
|
||||
*/
|
||||
public class ActivityDatabaseHandler extends SQLiteOpenHelper implements DBHandler {
|
||||
|
||||
private static final int DATABASE_VERSION = 7;
|
||||
|
@ -2,12 +2,12 @@ package nodomain.freeyourgadget.gadgetbridge.database;
|
||||
|
||||
/**
|
||||
* TODO: Legacy, can be removed once migration support for old ActivityDatabase is removed
|
||||
* @deprecated only for backwards compatibility
|
||||
*/
|
||||
public class DBConstants {
|
||||
public static final String DATABASE_NAME = "ActivityDatabase";
|
||||
|
||||
public static final String TABLE_GBACTIVITYSAMPLES = "GBActivitySamples";
|
||||
public static final String TABLE_STEPS_PER_DAY = "StepsPerDay";
|
||||
|
||||
public static final String KEY_TIMESTAMP = "timestamp";
|
||||
public static final String KEY_PROVIDER = "provider";
|
||||
|
@ -1,101 +0,0 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.impl;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
||||
/**
|
||||
* Can be removed entirely together with ActivityDatabaseHandler
|
||||
*/
|
||||
public class GBActivitySample implements ActivitySample {
|
||||
private final int timestamp;
|
||||
private final SampleProvider provider;
|
||||
private final int intensity;
|
||||
private final int steps;
|
||||
private final int type;
|
||||
private int customValue;
|
||||
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type) {
|
||||
this(provider, timestamp, intensity, steps, type, 0);
|
||||
}
|
||||
|
||||
public GBActivitySample(SampleProvider provider, int timestamp, int intensity, int steps, int type, int customValue) {
|
||||
this.timestamp = timestamp;
|
||||
this.provider = provider;
|
||||
this.intensity = intensity;
|
||||
this.steps = steps;
|
||||
this.customValue = customValue;
|
||||
this.type = type;
|
||||
validate();
|
||||
}
|
||||
|
||||
private void validate() {
|
||||
if (steps < 0) {
|
||||
throw new IllegalArgumentException("steps must be >= 0");
|
||||
}
|
||||
if (intensity < 0) {
|
||||
throw new IllegalArgumentException("intensity must be >= 0");
|
||||
}
|
||||
if (timestamp < 0) {
|
||||
throw new IllegalArgumentException("timestamp must be >= 0");
|
||||
}
|
||||
if (customValue < 0) {
|
||||
throw new IllegalArgumentException("customValue must be >= 0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleProvider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawIntensity() {
|
||||
return intensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getIntensity() {
|
||||
return getProvider().normalizeIntensity(getRawIntensity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSteps() {
|
||||
return steps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeartRate() {
|
||||
return customValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeartRate(int value) {
|
||||
customValue = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRawKind() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getKind() {
|
||||
return getProvider().normalizeType(getRawKind());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GBActivitySample{" +
|
||||
"timestamp=" + DateTimeUtils.formatDateTime(DateTimeUtils.parseTimeStamp(timestamp)) +
|
||||
", intensity=" + getIntensity() +
|
||||
", steps=" + getSteps() +
|
||||
", type=" + getKind() +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user