Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Code cleanup - removing logging statements, etc.
* Wired up initial disclosure views for App Events generator
  • Loading branch information
audaciouscode committed May 7, 2017
1 parent 3577db9 commit 0fd0684
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 16 deletions.
2 changes: 2 additions & 0 deletions res/values/generators.xml
Expand Up @@ -116,4 +116,6 @@

<string name="message_generator_phone_calls_empty">No phone calls have been made or received on this device.</string>

<!-- App Event Resources -->
<string name="generator_app_events">Application Events</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 @@ -317,8 +315,6 @@ public void onLocationChanged(android.location.Location location) {
if (location == null)
return;

Log.e("PDK", "LOCATION CHANGED: " + location);

long now = System.currentTimeMillis();

final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this.mContext);
Expand Down Expand Up @@ -658,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 @@ -946,13 +940,9 @@ public android.location.Location getLastKnownLocation() {


if (lastLocation != null) {
Log.e("PDK", "RETURNING LAST SAVED LOCATION: " + lastLocation);

return lastLocation;
}

Log.e("PDK", "FETCHING LOCATION");

LocationManager locations = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);

android.location.Location last = null;
Expand All @@ -962,12 +952,8 @@ public android.location.Location getLastKnownLocation() {

last = locations.getLastKnownLocation(LocationManager.GPS_PROVIDER);

Log.e("PDK", "GPS LAST: " + last);

if (last == null) {
last = locations.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

Log.e("PDK", "NET LAST: " + last);
}
}

Expand Down
Expand Up @@ -9,9 +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 @@ -60,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 @@ -95,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 @@ -436,4 +452,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 0fd0684

Please sign in to comment.