Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generator work.
* Implemented most of the device battery generator.
* Created placeholder files for Accelerometer and Ambient Light.
  • Loading branch information
audaciouscode committed Apr 17, 2017
1 parent 4879ee6 commit 24898e2
Show file tree
Hide file tree
Showing 10 changed files with 480 additions and 222 deletions.
63 changes: 63 additions & 0 deletions res/layout/card_generator_app_event.xml
@@ -0,0 +1,63 @@
<?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="#607D8B"
android:padding="8dp"
android:baselineAligned="false">
<ImageView android:src="@drawable/ic_screen_state"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_app_event"
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">
<TextView android:id="@+id/card_app_event_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_device_app_event_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
63 changes: 63 additions & 0 deletions res/layout/card_generator_device_battery.xml
@@ -0,0 +1,63 @@
<?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="#607D8B"
android:padding="8dp"
android:baselineAligned="false">
<ImageView android:src="@drawable/ic_screen_state"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginRight="8dp" />
<TextView android:text="@string/generator_device_battery"
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">
<TextView android:id="@+id/card_last_battery_level"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
<TextView android:id="@+id/card_empty"
android:text="@string/message_generator_device_battery_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
3 changes: 3 additions & 0 deletions res/values/databases.xml
Expand Up @@ -16,4 +16,7 @@
<!-- App Events Generator -->
<string name="pdk_generator_app_events_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, event_name TEXT, event_details TEXT);</string>

<!-- Battery Generator -->
<string name="pdk_generator_device_battery_create_history_table">CREATE TABLE history(_id INTEGER PRIMARY KEY AUTOINCREMENT, fetched INTEGER, transmitted INTEGER, observed INTEGER, health TEXT, level INTERGER, plugged TEXT, present INTEGER, scale INTEGER, temperature INTEGER, voltage INTEGER, technology TEXT, status TEXT);</string>

</resources>
8 changes: 8 additions & 0 deletions res/values/generators.xml
Expand Up @@ -116,4 +116,12 @@

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

<!-- Device Battery -->
<string name="generator_device_battery">Device Battery</string>
<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="message_generator_device_app_event_empty">No app events have been logged yet.</string>

</resources>
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;

Expand Down Expand Up @@ -36,6 +37,8 @@ public DataPointViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Method fetchView = generatorClass.getDeclaredMethod("fetchView", ViewGroup.class);
View view = (View) fetchView.invoke(null, parent);

Log.e("PDK", "GENERATOR CLASS: " + generatorClass);

return new DataPointViewHolder(view);
} catch (NoSuchMethodException e1) {
Logger.getInstance(parent.getContext()).logThrowable(e1);
Expand Down Expand Up @@ -67,6 +70,8 @@ public void onBindViewHolder(final DataPointViewHolder holder, int position) {

Method bindViewHolder = generatorClass.getDeclaredMethod("bindViewHolder", DataPointViewHolder.class);

Log.e("PDK", "GENERATOR CLASS: " + generatorClass);

bindViewHolder.invoke(null, holder);
} catch (NoSuchMethodException e1) {
Logger.getInstance(holder.itemView.getContext()).logThrowable(e1);
Expand Down
Expand Up @@ -233,6 +233,9 @@ public List<Class<? extends Generator>> activeGenerators() {
for (String className : this.mActiveGenerators) {
try {
active.add((Class<? extends Generator>) Class.forName(className));

Log.e("PDK", "ACTIVE GENERATOR CLASS: " + className);

} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 24898e2

Please sign in to comment.