Skip to content

Commit

Permalink
Overhauled data generator data storage.
Browse files Browse the repository at this point in the history
* Added text-messaging data generator.
  • Loading branch information
audaciouscode committed Dec 13, 2016
1 parent bb50e09 commit 1c1cc49
Show file tree
Hide file tree
Showing 28 changed files with 1,554 additions and 492 deletions.
1 change: 1 addition & 0 deletions AndroidManifest.xml
Expand Up @@ -4,6 +4,7 @@
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_SMS" />
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme">
<activity android:name="com.audacious_software.passive_data_kit.activities.generators.MicrosoftBandAuthActivity" android:label="@string/app_name" />
<activity android:name="com.audacious_software.passive_data_kit.activities.generators.RequestPermissionActivity" android:label="@string/app_name" />
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

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

Expand All @@ -17,7 +17,7 @@ repositories {

android {
compileSdkVersion 25
buildToolsVersion "25"
buildToolsVersion "25.0.2"

useLibrary 'org.apache.http.legacy'

Expand Down Expand Up @@ -53,6 +53,7 @@ android {
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.google.maps.android:android-maps-utils:0.4'
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'commons-io:commons-io:2.4'
compile 'commons-codec:commons-codec:1.10'
Expand Down
Binary file added res/drawable-hdpi/ic_text_messages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-mdpi/ic_text_messages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xhdpi/ic_text_messages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxhdpi/ic_text_messages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/drawable-xxxhdpi/ic_text_messages.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions res/drawable/ic_location_heatmap_marker.xml
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="8dp" android:height="8dp" />
<solid android:color="#80D50000" />
</shape>
30 changes: 18 additions & 12 deletions res/layout/card_generator_location_google.xml
Expand Up @@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
Expand Down Expand Up @@ -42,24 +43,29 @@
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<FrameLayout android:orientation="horizontal"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="240dp">
android:layout_height="200dp">
<com.google.android.gms.maps.MapView android:id="@+id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#757575"
app:mapType="hybrid"
app:liteMode="true" />
<TextView android:id="@+id/generator_location_description"
android:layout_width="match_parent"
android:background="#757575" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/pdk_google_location_map_type_hybrid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@android:color/white"
android:background="#C0000000"
android:padding="8dp">
</TextView>
android:layout_gravity="bottom|right"
android:layout_marginRight="6dp"
android:layout_marginBottom="104dp" />
</FrameLayout>
<!-- <TextView android:id="@+id/generator_location_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@android:color/white"
android:background="#33691E"
android:padding="8dp">
</TextView> -->
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
9 changes: 8 additions & 1 deletion res/layout/card_generator_phone_calls.xml
Expand Up @@ -41,7 +41,8 @@
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
<LinearLayout android:id="@+id/card_content"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
Expand Down Expand Up @@ -150,6 +151,12 @@
android:layout_marginBottom="8dp"/>
</LinearLayout>
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_phone_calls_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
9 changes: 8 additions & 1 deletion res/layout/card_generator_screen_state.xml
Expand Up @@ -41,7 +41,8 @@
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
<LinearLayout android:id="@+id/card_content"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
Expand Down Expand Up @@ -138,6 +139,12 @@
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_screen_state_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
134 changes: 134 additions & 0 deletions res/layout/card_generator_text_messages.xml
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="4dp"
android:layout_margin="8dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#9C27B0"
android:padding="8dp"
android:baselineAligned="false">
<ImageView android:src="@drawable/ic_text_messages"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_text_messages"
android:gravity="center_vertical|start"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_weight="1"
android:textSize="16sp"
android:textStyle="bold"
android:textColor="@android:color/white" />
<TextView android:id="@+id/generator_data_point_date"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:textSize="12sp"
android:textColor="@android:color/white"
android:layout_marginRight="8dp"/>
</LinearLayout>
<LinearLayout android:id="@+id/card_content"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/chart_text_messages"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_marginRight="16dp"/>
<LinearLayout android:orientation="vertical"
android:layout_width="100dp"
android:layout_height="120dp">
<View android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="40dp" />
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<View android:layout_width="16dp"
android:layout_marginRight="4dp"
android:layout_height="16dp"
android:background="@color/generator_text_messages_incoming" />
<TextView android:text="@string/generator_text_messages_incoming_label"
android:layout_width="wrap_content"
android:textSize="12sp"
android:layout_height="16dp" />
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp">
<View android:layout_width="16dp"
android:layout_marginRight="4dp"
android:layout_height="16dp"
android:background="@color/generator_text_messages_outgoing" />
<TextView android:text="@string/generator_text_messages_outgoing_label"
android:layout_width="wrap_content"
android:textSize="12sp"
android:layout_height="16dp" />
</LinearLayout>
<View android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="40dp" />
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<TextView android:text="@string/generator_text_messages_latest_text_message_label"
android:textStyle="bold"
android:textSize="12sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/field_latest_text_message"
android:textSize="13sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
<TextView android:text="@string/generator_text_messages_length_label"
android:textStyle="bold"
android:textSize="12sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/field_length"
android:textSize="13sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
<TextView android:text="@string/generator_text_messages_direction_label"
android:textStyle="bold"
android:textSize="12sp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView android:id="@+id/field_direction"
android:textSize="13sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"/>
</LinearLayout>
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_text_messages_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
15 changes: 15 additions & 0 deletions res/values/databases.xml
@@ -0,0 +1,15 @@
<resources>
<string name="pdk_generator_create_version_table">CREATE TABLE metadata(key TEXT, value TEXT, last_updated INTEGER);</string>

<!-- Location Generator -->
<string name="pdk_generator_location_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, latitude REAL, longitude REAL, altitude REAL, bearing REAL, speed REAL, provider TEXT, location_timestamp INTEGER, accuracy REAL);</string>

<!-- Screen State Generator -->
<string name="pdk_generator_screen_state_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, state TEXT);</string>

<!-- Phone Calls Generator -->
<string name="pdk_generator_phone_calls_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, duration INTEGER, call_type TEXT, number TEXT, post_dial_digits TEXT, via_number TEXT, is_new INTEGER, pulled_externally INTEGER, country_iso TEXT, data_usage INTEGER, geocoded_location TEXT, is_video INTEGER, presentation TEXT, is_read INTEGER);</string>

<!-- Phone Calls Generator -->
<string name="pdk_generator_text_messages_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, direction TEXT, length INTEGER, body TEXT, number_name TEXT, number TEXT);</string>
</resources>
27 changes: 27 additions & 0 deletions res/values/generators.xml
Expand Up @@ -3,6 +3,7 @@
<item>com.audacious_software.passive_data_kit.generators.device.Location</item>
<item>com.audacious_software.passive_data_kit.generators.device.ScreenState</item>
<item>com.audacious_software.passive_data_kit.generators.communication.PhoneCalls</item>
<item>com.audacious_software.passive_data_kit.generators.communication.TextMessages</item>
<item>com.audacious_software.passive_data_kit.generators.wearables.MicrosoftBand</item>
<item>com.audacious_software.passive_data_kit.generators.services.GoogleAwareness</item>
</string-array>
Expand Down Expand Up @@ -45,6 +46,30 @@

<!-- Screen State Resources -->
<string name="generator_screen_state">Screen State</string>
<string name="legend_screen_state_on_pdk">On</string>
<string name="legend_screen_state_off_pdk">Off</string>
<string name="legend_screen_state_doze_pdk">Doze</string>
<string name="legend_screen_state_unknown_pdk">Unknown</string>
<string name="label_legend_pdk">Legend: </string>
<string name="message_generator_screen_state_empty">No screen state changes have been observed yet.</string>

<!-- Phone Call Resources -->
<string name="generator_text_messages">SMS Text Messages</string>
<string name="generator_text_messages_incoming_label">Incoming</string>
<string name="generator_text_messages_outgoing_label">Outgoing</string>
<string name="generator_text_messages_other_label">Other</string>

<color name="generator_text_messages_incoming">#3F51B5</color>
<color name="generator_text_messages_outgoing">#4CAF50</color>
<color name="generator_text_messages_other">#9E9E9E</color>

<string name="generator_text_messages_latest_text_message_label">Latest Text Message</string>
<string name="generator_text_messages_length_label">Length</string>
<string name="generator_text_messages_direction_label">Direction</string>
<string name="generator_text_messages_length_format">%1$d chars.</string>

<string name="message_generator_text_messages_empty">No text messages have been sent or received on this device.</string>
<string name="diagnostic_sms_log_permission_required">Please all the app permission to access your text messages to gather and report your messaging activity statistics.</string>

<!-- Phone Call Resources -->
<string name="generator_phone_calls">Phone Calls</string>
Expand All @@ -63,4 +88,6 @@
<string name="generator_phone_calls_direction_label">Direction</string>
<string name="generator_phone_calls_duration_format">%1$.2f min.</string>

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

</resources>
6 changes: 1 addition & 5 deletions res/values/strings.xml
Expand Up @@ -14,10 +14,6 @@

<string name="label_today_pdk">Today</string>

<string name="legend_screen_state_on_pdk">On</string>
<string name="legend_screen_state_off_pdk">Off</string>
<string name="legend_screen_state_doze_pdk">Doze</string>
<string name="legend_screen_state_unknown_pdk">Unknown</string>
<string name="label_legend_pdk">Legend: </string>
<string name="label_never_pdk">Never</string>
</resources>

15 changes: 15 additions & 0 deletions src/com/audacious_software/passive_data_kit/PassiveDataKit.java
Expand Up @@ -5,9 +5,13 @@
import com.audacious_software.passive_data_kit.diagnostics.DiagnosticAction;
import com.audacious_software.passive_data_kit.generators.Generators;

import java.io.File;
import java.util.ArrayList;

public class PassiveDataKit {
private static final String STORAGE_PATH = "passive-data-kit";
private static final String GENERATORS_PATH = "generators";

private Context mContext = null;
private boolean mStarted = false;

Expand All @@ -30,6 +34,17 @@ public static ArrayList<DiagnosticAction> diagnostics(Context context)
return actions;
}

public static File getGeneratorsStorage(Context context) {
File path = new File(context.getFilesDir(), PassiveDataKit.STORAGE_PATH);
path = new File(path, PassiveDataKit.GENERATORS_PATH);

if (path.exists() == false) {
path.mkdirs();
}

return path;
}

private static class PassiveDataKitHolder {
public static PassiveDataKit instance = new PassiveDataKit();
}
Expand Down

0 comments on commit 1c1cc49

Please sign in to comment.