Skip to content

Commit

Permalink
Merge branch 'master' of github.com:audaciouscode/PassiveDataKit-Android
Browse files Browse the repository at this point in the history
  • Loading branch information
audaciouscode committed May 10, 2017
2 parents 24898e2 + 0fd0684 commit 95eca5e
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 17 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Expand Up @@ -48,11 +48,11 @@ android {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.google.android.gms:play-services-location:10.2.1'
compile 'com.google.android.gms:play-services-maps:10.2.1'
compile 'com.google.android.gms:play-services-nearby:10.2.1'
compile 'com.google.android.gms:play-services-places:10.2.1'
compile 'com.google.android.gms:play-services-awareness:10.2.1'
compile 'com.google.android.gms:play-services-location:10.2.4'
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.google.android.gms:play-services-nearby:10.2.4'
compile 'com.google.android.gms:play-services-places:10.2.4'
compile 'com.google.android.gms:play-services-awareness:10.2.4'
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
2 changes: 1 addition & 1 deletion res/layout/card_generator_app_event.xml
Expand Up @@ -25,7 +25,7 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_app_event"
<TextView android:text="@string/generator_app_events"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_height="24dp"
Expand Down
3 changes: 1 addition & 2 deletions res/values/generators.xml
Expand Up @@ -121,7 +121,6 @@
<string name="message_generator_device_battery_empty">No battery levels have been reported yet.</string>

<!-- App Event History -->
<string name="generator_app_event">App Event History</string>
<string name="generator_app_events">App Events History</string>
<string name="message_generator_device_app_event_empty">No app events have been logged yet.</string>

</resources>
Expand Up @@ -10,7 +10,6 @@
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 All @@ -27,7 +26,6 @@
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SwitchCompat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -114,7 +112,6 @@ public class Location extends Generator implements GoogleApiClient.ConnectionCal

private static Location sInstance = null;
private GoogleApiClient mGoogleApiClient = null;
private android.location.Location mLastLocation = null;
private long mUpdateInterval = 60000;

private SQLiteDatabase mDatabase = null;
Expand Down Expand Up @@ -657,8 +654,6 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
checked.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton compoundButton, final boolean checked) {
Log.e("PDK", "CHECK CHANGE!");

final CompoundButton.OnCheckedChangeListener me = this;

if (option == Location.ACCURACY_BEST) {
Expand Down Expand Up @@ -927,8 +922,25 @@ public android.location.Location getLastKnownLocation() {
return location;
}

if (this.mLastLocation != null) {
return this.mLastLocation;
android.location.Location lastLocation = null;

Cursor c = this.mDatabase.query(Location.TABLE_HISTORY, null, null, null, null, null, Location.HISTORY_OBSERVED + " DESC");

if (c.moveToNext()) {
double latitude = c.getDouble(c.getColumnIndex(Location.HISTORY_LATITUDE));
double longitude = c.getDouble(c.getColumnIndex(Location.HISTORY_LONGITUDE));

lastLocation = new android.location.Location("Passive-Data-Kit");
lastLocation.setLatitude(latitude);
lastLocation.setLongitude(longitude);
}

c.close();



if (lastLocation != null) {
return lastLocation;
}

LocationManager locations = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
Expand Down
Expand Up @@ -9,10 +9,13 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.TextView;

import com.audacious_software.passive_data_kit.PassiveDataKit;
import com.audacious_software.passive_data_kit.activities.DataDisclosureDetailActivity;
import com.audacious_software.passive_data_kit.activities.generators.DataPointViewHolder;
import com.audacious_software.passive_data_kit.activities.generators.GeneratorViewHolder;
import com.audacious_software.passive_data_kit.diagnostics.DiagnosticAction;
import com.audacious_software.passive_data_kit.generators.Generator;
import com.audacious_software.passive_data_kit.generators.Generators;
Expand Down Expand Up @@ -61,9 +64,11 @@ public static void start(final Context context) {
AppEvent.getInstance(context).startGenerator();
}

private void startGenerator() {
final AppEvent me = this;
public static String getGeneratorTitle(Context context) {
return context.getString(R.string.generator_app_events);
}

private void startGenerator() {
Generators.getInstance(this.mContext).registerCustomViewClass(AppEvent.GENERATOR_IDENTIFIER, AppEvent.class);

File path = PassiveDataKit.getGeneratorsStorage(this.mContext);
Expand Down Expand Up @@ -96,6 +101,16 @@ public static ArrayList<DiagnosticAction> diagnostics(Context context) {
return new ArrayList<>();
}

public static void bindDisclosureViewHolder(final GeneratorViewHolder holder) {
Class currentClass = new Object() { }.getClass().getEnclosingClass();

String identifier = currentClass.getCanonicalName();

TextView generatorLabel = (TextView) holder.itemView.findViewById(R.id.label_generator);

generatorLabel.setText(AppEvent.getGeneratorTitle(holder.itemView.getContext()));
}

public static void bindViewHolder(DataPointViewHolder holder) {
final Context context = holder.itemView.getContext();

Expand Down Expand Up @@ -222,4 +237,31 @@ public boolean logEvent(String eventName, Map<String, ? extends Object> eventDet

return false;
}

public static List<DataDisclosureDetailActivity.Action> getDisclosureActions(final Context context) {
List<DataDisclosureDetailActivity.Action> actions = new ArrayList<>();

DataDisclosureDetailActivity.Action disclosure = new DataDisclosureDetailActivity.Action();

disclosure.title = context.getString(R.string.label_data_collection_description);
disclosure.subtitle = context.getString(R.string.label_data_collection_description_more);

WebView disclosureView = new WebView(context);
disclosureView.loadUrl("file:///android_asset/html/passive_data_kit/generator_app_events_disclosure.html");

disclosure.view = disclosureView;

actions.add(disclosure);

return actions;
}

public static View getDisclosureDataView(final GeneratorViewHolder holder) {
final Context context = holder.itemView.getContext();

WebView disclosureView = new WebView(context);
disclosureView.loadUrl("file:///android_asset/html/passive_data_kit/generator_app_events_disclosure.html");

return disclosureView;
}
}

0 comments on commit 95eca5e

Please sign in to comment.