Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generator work, dependency updates
  • Loading branch information
audaciouscode committed Mar 3, 2017
1 parent 5a7bb83 commit bdde3fa
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 144 deletions.
18 changes: 9 additions & 9 deletions build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
}
}

Expand Down Expand Up @@ -45,14 +45,14 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-nearby:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.android.gms:play-services-awareness:10.0.1'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-maps:10.2.0'
compile 'com.google.android.gms:play-services-nearby:10.2.0'
compile 'com.google.android.gms:play-services-places:10.2.0'
compile 'com.google.android.gms:play-services-awareness:10.2.0'
compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'commons-io:commons-io:2.4'
Expand Down
Expand Up @@ -65,7 +65,7 @@ protected void onPause() {
}

@Override
public void onGeneratorUpdated(String identifier, Bundle data) {
public void onGeneratorUpdated(String identifier, long timestamp, Bundle data) {
final DataStreamActivity me = this;

this.runOnUiThread(new Runnable() {
Expand Down
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -105,6 +106,12 @@ public static String formatTimestamp(Context context, double timestamp) {

public abstract List<Bundle> fetchPayloads();

public Cursor queryHistory(String[] cols, String where, String[] args, String orderBy) {
Cursor c = new MatrixCursor(cols);

return c;
}

protected int getDatabaseVersion(SQLiteDatabase db) {
String where = "type = ? AND name = ?";
String[] args = { "table", Generator.TABLE_METADATA };
Expand Down
Expand Up @@ -237,9 +237,17 @@ public List<Class<? extends Generator>> activeGenerators() {
return active;
}

public void notifyGeneratorUpdated(String identifier, long timestamp, Bundle bundle) {
for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, timestamp, bundle);
}
}

public void notifyGeneratorUpdated(String identifier, Bundle bundle) {
long timestamp = System.currentTimeMillis();

for (GeneratorUpdatedListener listener : this.mGeneratorUpdatedListeners) {
listener.onGeneratorUpdated(identifier, bundle);
listener.onGeneratorUpdated(identifier, timestamp, bundle);
}
}

Expand Down Expand Up @@ -269,6 +277,6 @@ public void removeGeneratorUpdatedListener(Generators.GeneratorUpdatedListener l
}

public interface GeneratorUpdatedListener {
void onGeneratorUpdated(String identifier, Bundle data);
void onGeneratorUpdated(String identifier, long timestamp, Bundle data);
}
}

Large diffs are not rendered by default.

Expand Up @@ -9,6 +9,7 @@
import android.content.pm.PackageManager;
import android.content.res.ColorStateList;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -88,15 +89,15 @@ public class Location extends Generator implements GoogleApiClient.ConnectionCal
private static int DATABASE_VERSION = 1;

private static final String TABLE_HISTORY = "history";
private static final String HISTORY_OBSERVED = "observed";
private static final String HISTORY_LATITUDE = "latitude";
private static final String HISTORY_LONGITUDE = "longitude";
private static final String HISTORY_ALTITUDE = "altitude";
private static final String HISTORY_BEARING = "bearing";
private static final String HISTORY_SPEED = "speed";
private static final String HISTORY_PROVIDER = "provider";
private static final String HISTORY_LOCATION_TIMESTAMP = "location_timestamp";
private static final String HISTORY_ACCURACY = "accuracy";
public static final String HISTORY_OBSERVED = "observed";
public static final String HISTORY_LATITUDE = "latitude";
public static final String HISTORY_LONGITUDE = "longitude";
public static final String HISTORY_ALTITUDE = "altitude";
public static final String HISTORY_BEARING = "bearing";
public static final String HISTORY_SPEED = "speed";
public static final String HISTORY_PROVIDER = "provider";
public static final String HISTORY_LOCATION_TIMESTAMP = "location_timestamp";
public static final String HISTORY_ACCURACY = "accuracy";

public static Location getInstance(Context context) {
if (Location.sInstance == null) {
Expand Down Expand Up @@ -282,8 +283,6 @@ public void onConnectionFailed(ConnectionResult connectionResult) {

@Override
public void onLocationChanged(android.location.Location location) {
Log.e("PDK", "LOCATION CHANGED");

if (location == null)
return;

Expand Down Expand Up @@ -552,4 +551,8 @@ public void setUpdateInterval(long interval) {
this.stopGenerator();
this.startGenerator();
}

public Cursor queryHistory(String[] cols, String where, String[] args, String orderBy) {
return this.mDatabase.query(Location.TABLE_HISTORY, cols, where, args, null, null, orderBy);
}
}
Expand Up @@ -37,17 +37,18 @@ public class ScreenState extends Generator{
private static final String ENABLED = "com.audacious_software.passive_data_kit.generators.device.ScreenState.ENABLED";
private static final boolean ENABLED_DEFAULT = true;

private static final String STATE_DOZE = "doze";
private static final String STATE_DOZE_SUSPEND = "doze_suspend";
private static final String STATE_ON = "on";
private static final String STATE_OFF = "off";
private static final String STATE_UNKNOWN = "unknown";
public static final String STATE_DOZE = "doze";
public static final String STATE_DOZE_SUSPEND = "doze_suspend";
public static final String STATE_ON = "on";
public static final String STATE_OFF = "off";
public static final String STATE_UNKNOWN = "unknown";

private static final String DATABASE_PATH = "pdk-screen-state.sqlite";
private static final int DATABASE_VERSION = 2;
private static final String HISTORY_OBSERVED = "observed";
private static final String HISTORY_STATE = "state";
private static final String TABLE_HISTORY = "history";

public static final String HISTORY_OBSERVED = "observed";
public static final String HISTORY_STATE = "state";
public static final String TABLE_HISTORY = "history";

private static ScreenState sInstance = null;

Expand Down Expand Up @@ -439,4 +440,8 @@ public static long latestPointGenerated(Context context) {

return timestamp;
}

public Cursor queryHistory(String[] cols, String where, String[] args, String orderBy) {
return this.mDatabase.query(ScreenState.TABLE_HISTORY, cols, where, args, null, null, orderBy);
}
}
Expand Up @@ -424,10 +424,9 @@ public long transmittedSize() {
}

@Override
public void onGeneratorUpdated(String identifier, Bundle data) {
public void onGeneratorUpdated(String identifier, long timestamp, Bundle data) {
if (data.keySet().size() > 1) { // Only transmit non-empty bundles...
double now = (double) System.currentTimeMillis();
now = now / 1000; // Convert to seconds...
timestamp = timestamp / 1000; // Convert to seconds...

Generators generators = Generators.getInstance(this.mContext);

Expand All @@ -438,7 +437,7 @@ public void onGeneratorUpdated(String identifier, Bundle data) {
}

metadata.putString(Generator.IDENTIFIER, identifier);
metadata.putDouble(Generator.TIMESTAMP, now);
metadata.putDouble(Generator.TIMESTAMP, timestamp);
metadata.putString(Generator.GENERATOR, generators.getGeneratorFullName(identifier));
metadata.putString(Generator.SOURCE, generators.getSource());
metadata.putString(Generator.SOURCE, this.mUserId);
Expand Down

0 comments on commit bdde3fa

Please sign in to comment.