From 0fd068470b242753550ef825e0584cc80d7a2fbf Mon Sep 17 00:00:00 2001 From: "Chris J. Karr" Date: Sat, 6 May 2017 21:11:45 -0500 Subject: [PATCH] Code cleanup - removing logging statements, etc. * Wired up initial disclosure views for App Events generator --- res/values/generators.xml | 2 + .../generators/device/Location.java | 14 ------ .../generators/diagnostics/AppEvent.java | 47 ++++++++++++++++++- 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/res/values/generators.xml b/res/values/generators.xml index a6e8f0e..58c12fc 100755 --- a/res/values/generators.xml +++ b/res/values/generators.xml @@ -116,4 +116,6 @@ No phone calls have been made or received on this device. + + Application Events \ No newline at end of file diff --git a/src/com/audacious_software/passive_data_kit/generators/device/Location.java b/src/com/audacious_software/passive_data_kit/generators/device/Location.java index c008de5..8d65c12 100755 --- a/src/com/audacious_software/passive_data_kit/generators/device/Location.java +++ b/src/com/audacious_software/passive_data_kit/generators/device/Location.java @@ -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; @@ -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; @@ -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); @@ -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) { @@ -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; @@ -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); } } diff --git a/src/com/audacious_software/passive_data_kit/generators/diagnostics/AppEvent.java b/src/com/audacious_software/passive_data_kit/generators/diagnostics/AppEvent.java index e92d291..329b5c3 100755 --- a/src/com/audacious_software/passive_data_kit/generators/diagnostics/AppEvent.java +++ b/src/com/audacious_software/passive_data_kit/generators/diagnostics/AppEvent.java @@ -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; @@ -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); @@ -95,6 +101,16 @@ public static ArrayList 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(); @@ -436,4 +452,31 @@ public boolean logEvent(String eventName, Map eventDet return false; } + + public static List getDisclosureActions(final Context context) { + List 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; + } }