Skip to content

armgit / haven

Public Imported from GitHub
0

Haven is for people who need a way to protect their personal spaces and possessions without compromising their own privacy, through an Android app and on-device sensors

major progress on #15 with data persistence and log UI

n8fr8d078907dfb8f
diff --git a/build.gradle b/build.gradle
index c234b39..70cba95 100644
--- a/build.gradle
+++ b/build.gradle
@@ -48,5 +48,9 @@ android {
dependencies {
compile 'com.android.support:support-v4:25.0.0'
compile 'com.github.satyan:sugar:1.5'
+ compile 'com.android.support:appcompat-v7:25.3.0'
+ compile 'com.android.support:design:25.3.0'
+ compile 'com.android.support:cardview-v7:25.3.0'
+
}
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 6e8c83f..beb64ec 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -23,7 +23,7 @@
android:name="com.orm.SugarApp"
>
<activity
- android:name=".StartActivity"
+ android:name=".ListActivity"
android:label="@string/title_activity_start"
android:windowSoftInputMode="stateHidden"
>
@@ -32,6 +32,14 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+
+ <activity
+ android:name=".StartActivity"
+ android:label="@string/title_activity_start"
+ android:windowSoftInputMode="stateHidden"
+ >
+ </activity>
+
<activity
android:label="@string/app_name"
android:name=".MonitorActivity"
diff --git a/src/main/java/info/guardianproject/phoneypot/CameraFragment.java b/src/main/java/info/guardianproject/phoneypot/CameraFragment.java
index d612f9d..99d9270 100644
--- a/src/main/java/info/guardianproject/phoneypot/CameraFragment.java
+++ b/src/main/java/info/guardianproject/phoneypot/CameraFragment.java
@@ -27,7 +27,7 @@ public final class CameraFragment extends Fragment {
private Preview preview;
- private ImageView oldImage;
+// private ImageView oldImage;
private ImageView newImage;
@Override
@@ -57,7 +57,7 @@ public final class CameraFragment extends Fragment {
preview = new Preview(getActivity());
((FrameLayout) getActivity().findViewById(R.id.preview)).addView(preview);
- oldImage = (ImageView) getActivity().findViewById(R.id.old_image);
+ // oldImage = (ImageView) getActivity().findViewById(R.id.old_image);
newImage = (ImageView) getActivity().findViewById(R.id.new_image);
preview.addListener(new MotionAsyncTask.MotionListener() {
@@ -72,7 +72,7 @@ public final class CameraFragment extends Fragment {
rotation = 270;
reflex = true;
}
- oldImage.setImageBitmap(ImageCodec.rotate(oldBitmap, rotation, reflex));
+ // oldImage.setImageBitmap(ImageCodec.rotate(oldBitmap, rotation, reflex));
newImage.setImageBitmap(ImageCodec.rotate(newBitmap, rotation, reflex));
}
});
diff --git a/src/main/java/info/guardianproject/phoneypot/ListActivity.java b/src/main/java/info/guardianproject/phoneypot/ListActivity.java
new file mode 100644
index 0000000..79df882
--- /dev/null
+++ b/src/main/java/info/guardianproject/phoneypot/ListActivity.java
@@ -0,0 +1,226 @@
+package info.guardianproject.phoneypot;
+
+import android.support.design.widget.FloatingActionButton;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.RecyclerView;
+
+import info.guardianproject.phoneypot.model.Event;
+import info.guardianproject.phoneypot.ui.EventAdapter;
+
+
+import android.annotation.SuppressLint;
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.graphics.drawable.DrawableCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.helper.ItemTouchHelper;
+import android.util.Log;
+import android.view.View;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import info.guardianproject.phoneypot.R;
+
+/**
+ * Created by n8fr8 on 4/16/17.
+ */
+
+public class ListActivity extends AppCompatActivity {
+
+ RecyclerView recyclerView;
+ FloatingActionButton fab;
+
+ EventAdapter adapter;
+ List<Event> events = new ArrayList<>();
+
+ long initialCount;
+
+ int modifyPos = -1;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_list);
+ Log.d("Main", "onCreate");
+
+ recyclerView = (RecyclerView) findViewById(R.id.main_list);
+ fab = (FloatingActionButton) findViewById(R.id.fab);
+
+ /**
+ StaggeredGridLayoutManager gridLayoutManager =
+ new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
+ gridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
+
+ recyclerView.setLayoutManager(gridLayoutManager);**/
+
+ LinearLayoutManager llm = new LinearLayoutManager(this);
+ recyclerView.setLayoutManager(llm);
+
+ initialCount = Event.count(Event.class);
+
+ if (savedInstanceState != null)
+ modifyPos = savedInstanceState.getInt("modify");
+
+
+ if (initialCount >= 0) {
+
+ events = Event.listAll(Event.class);
+
+ adapter = new EventAdapter(ListActivity.this, events);
+ recyclerView.setAdapter(adapter);
+
+
+ }
+
+ // tinting FAB icon
+
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
+
+ Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_ring_volume_black_24dp);
+ drawable = DrawableCompat.wrap(drawable);
+ DrawableCompat.setTint(drawable, Color.WHITE);
+ DrawableCompat.setTintMode(drawable, PorterDuff.Mode.SRC_IN);
+
+ fab.setImageDrawable(drawable);
+
+ }
+
+
+ fab.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ Intent i = new Intent(ListActivity.this, StartActivity.class);
+ startActivity(i);
+
+ }
+ });
+
+
+ // Handling swipe to delete
+ ItemTouchHelper.SimpleCallback simpleCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
+
+ @Override
+ public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
+ return false;
+ }
+
+ @Override
+ public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
+ //Remove swiped item from list and notify the RecyclerView
+
+ final int position = viewHolder.getAdapterPosition();
+ final Event event = events.get(viewHolder.getAdapterPosition());
+ events.remove(viewHolder.getAdapterPosition());
+ adapter.notifyItemRemoved(position);
+
+ event.delete();
+ initialCount -= 1;
+
+ Snackbar.make(recyclerView, "Event deleted", Snackbar.LENGTH_SHORT)
+ .setAction("UNDO", new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ event.save();
+ events.add(position, event);
+ adapter.notifyItemInserted(position);
+ initialCount += 1;
+
+ }
+ })
+ .show();
+ }
+
+ };
+
+ ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleCallback);
+ itemTouchHelper.attachToRecyclerView(recyclerView);
+
+
+ adapter.SetOnItemClickListener(new EventAdapter.OnItemClickListener() {
+ @Override
+ public void onItemClick(View view, int position) {
+
+ /**
+ Log.d("Main", "click");
+
+ Intent i = new Intent(ListActivity.this, AddNoteActivity.class);
+ i.putExtra("isEditing", true);
+ i.putExtra("note_title", notes.get(position).title);
+ i.putExtra("note", notes.get(position).note);
+ i.putExtra("note_time", notes.get(position).time);
+
+ modifyPos = position;
+
+ startActivity(i);**/
+ }
+ });
+
+
+// List<Note> notes = Note.findWithQuery(Note.class, "Select title from Note where title = ?", "%note%");
+// if (notes.size() > 0)
+// Log.d("Notes", "note: " + notes.get(0).title);
+
+
+ }
+
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+
+ outState.putInt("modify", modifyPos);
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+
+ modifyPos = savedInstanceState.getInt("modify");
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+
+ final long newCount = Event.count(Event.class);
+
+ if (newCount > initialCount) {
+
+ // Just load the last added note (new)
+ Event event = Event.last(Event.class);
+
+ events.add(event);
+ adapter.notifyItemInserted((int) newCount);
+
+ initialCount = newCount;
+ }
+
+ if (modifyPos != -1) {
+ //Event.set(modifyPos, Event.listAll(Event.class).get(modifyPos));
+ adapter.notifyItemChanged(modifyPos);
+ }
+
+ }
+
+ @SuppressLint("SimpleDateFormat")
+ public static String getDateFormat(long date) {
+ return new SimpleDateFormat("dd MMM yyyy").format(new Date(date));
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java b/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
index e81df6d..4f727b4 100644
--- a/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
+++ b/src/main/java/info/guardianproject/phoneypot/MonitorActivity.java
@@ -71,7 +71,7 @@ public class MonitorActivity extends FragmentActivity {
*/
private void close() {
Intent intent = new Intent(
- getApplicationContext(), StartActivity.class);
+ getApplicationContext(), ListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
stopService(new Intent(this, MonitorService.class));
diff --git a/src/main/java/info/guardianproject/phoneypot/StartActivity.java b/src/main/java/info/guardianproject/phoneypot/StartActivity.java
index b7ed61d..91899a3 100644
--- a/src/main/java/info/guardianproject/phoneypot/StartActivity.java
+++ b/src/main/java/info/guardianproject/phoneypot/StartActivity.java
@@ -22,6 +22,8 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
@@ -34,7 +36,7 @@ import android.widget.EditText;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Spinner;
-public class StartActivity extends Activity {
+public class StartActivity extends AppCompatActivity {
private PreferenceManager preferences = null;
@@ -43,6 +45,10 @@ public class StartActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
+
+ Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
preferences = new PreferenceManager(this.getApplicationContext());
/*
diff --git a/src/main/java/info/guardianproject/phoneypot/model/Event.java b/src/main/java/info/guardianproject/phoneypot/model/Event.java
index a4cd638..596d6bc 100644
--- a/src/main/java/info/guardianproject/phoneypot/model/Event.java
+++ b/src/main/java/info/guardianproject/phoneypot/model/Event.java
@@ -4,6 +4,7 @@ import com.orm.SugarRecord;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
/**
* Created by n8fr8 on 4/16/17.
@@ -11,10 +12,8 @@ import java.util.Date;
public class Event extends SugarRecord {
- private Date mStartTime;
-
- private ArrayList<EventTrigger> mEventTriggers;
-
+ Date mStartTime;
+ ArrayList<EventTrigger> mEventTriggers;
public final static long EVENT_WINDOW_TIME = 1000 * 60; //1 minutes
public Event ()
@@ -23,11 +22,29 @@ public class Event extends SugarRecord {
mEventTriggers = new ArrayList<>();
}
+ public Date getStartTime ()
+ {
+ return mStartTime;
+ }
+
public void addEventTrigger (EventTrigger eventTrigger)
{
mEventTriggers.add(eventTrigger);
+ eventTrigger.setEventId(getId());
}
+ public ArrayList<EventTrigger> getEventTriggers ()
+ {
+ if (mEventTriggers.size() == 0) {
+ List<EventTrigger> eventTriggers = EventTrigger.find(EventTrigger.class, "M_EVENT_ID = ?", getId() + "");
+
+ for (EventTrigger et : eventTriggers)
+ mEventTriggers.add(et);
+
+ }
+
+ return mEventTriggers;
+ }
/**
* Are we within the time window of this event, or should we start a new event?
*/
@@ -36,6 +53,6 @@ public class Event extends SugarRecord {
if (mEventTriggers.size() == 0)
return now.getTime() - mStartTime.getTime() <= EVENT_WINDOW_TIME;
else
- return now.getTime() <= mEventTriggers.get(mEventTriggers.size()-1).getTriggerTime().getTime();
+ return now.getTime() - mEventTriggers.get(mEventTriggers.size()-1).getTriggerTime().getTime() <= EVENT_WINDOW_TIME;
}
}
diff --git a/src/main/java/info/guardianproject/phoneypot/model/EventTrigger.java b/src/main/java/info/guardianproject/phoneypot/model/EventTrigger.java
index b11e14f..861a34c 100644
--- a/src/main/java/info/guardianproject/phoneypot/model/EventTrigger.java
+++ b/src/main/java/info/guardianproject/phoneypot/model/EventTrigger.java
@@ -10,20 +10,38 @@ import java.util.Date;
public class EventTrigger extends SugarRecord {
- public enum TriggerType {
- CAMERA, SOUND, ACCEL
- }
+ int mType;
+ Date mTime;
+ long mEventId;
+
+
+ /**
+ * Acceleration detected message
+ */
+ public static final int ACCELEROMETER = 0;
- public TriggerType mType;
- public Date mTime;
+ /**
+ * Camera motion detected message
+ */
+ public static final int CAMERA = 1;
- public EventTrigger (TriggerType type)
+ /**
+ * Mic noise detected message
+ */
+ public static final int MICROPHONE = 2;
+
+
+ public EventTrigger ()
{
mTime = new Date();
+ }
+
+ public void setType (int type)
+ {
mType = type;
}
- public TriggerType getType ()
+ public int getType ()
{
return mType;
}
@@ -32,4 +50,9 @@ public class EventTrigger extends SugarRecord {
{
return mTime;
}
+
+ public void setEventId (long eventId)
+ {
+ mEventId = eventId;
+ }
}
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java b/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
index 8fa711c..76a2008 100644
--- a/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
+++ b/src/main/java/info/guardianproject/phoneypot/sensors/media/AudioRecorderTask.java
@@ -123,50 +123,7 @@ public class AudioRecorderTask extends Thread {
recording = false;
MicrophoneTaskFactory.restartSampling();
-
- /*
- * Uploading the audio
- */
- Log.i("AudioRecorderTask", "Trying to upload");
- /**
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost request = new HttpPost(
- Remote.HOST+
- Remote.PHONES+"/"+phoneId+
- Remote.UPLOAD_AUDIO);
-
- Log.i("AudioRecorderTask",
- "URI: "+Remote.HOST+
- Remote.PHONES+"/"+phoneId+
- Remote.UPLOAD_AUDIO);
-
- MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
- File audio = new File(audioPath);
- reqEntity.addPart("audio", new FileBody(audio, "audio/mp3"));
- request.setEntity(reqEntity);
-
- request.setHeader("access_token", accessToken);
-
- try {
- HttpResponse response = httpclient.execute(request);
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
- StringBuilder builder = new StringBuilder();
- for (String line = null; (line = reader.readLine()) != null;) {
- builder.append(line).append("\n");
- }
-
- Log.i("AudioRecorderTask", "Response:\n"+builder.toString());
-
- if (response.getStatusLine().getStatusCode() != 200) {
- Log.i("AudioRecorderTask", "Error uploading audio: "+audioPath);
- throw new HttpException();
- }
- } catch (Exception e) {
- Log.e("DataUploaderTask", "Error uploading audio: "+audioPath);
- }
- **/
}
}
diff --git a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
index 96665df..9123861 100644
--- a/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
+++ b/src/main/java/info/guardianproject/phoneypot/sensors/motion/Preview.java
@@ -42,6 +42,7 @@ import android.view.WindowManager;
import android.widget.Toast;
import info.guardianproject.phoneypot.PreferenceManager;
+import info.guardianproject.phoneypot.model.EventTrigger;
import info.guardianproject.phoneypot.sensors.media.MotionAsyncTask;
import info.guardianproject.phoneypot.service.MonitorService;
@@ -266,7 +267,7 @@ public class Preview extends SurfaceView implements SurfaceHolder.Callback {
Log.i("MotionListener", "Motion detected");
if (serviceMessenger!=null) {
Message message = new Message();
- message.what = MonitorService.CAMERA_MESSAGE;
+ message.what = EventTrigger.CAMERA;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
newBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
diff --git a/src/main/java/info/guardianproject/phoneypot/service/AccelerometerMonitor.java b/src/main/java/info/guardianproject/phoneypot/service/AccelerometerMonitor.java
index 3448835..17598f6 100644
--- a/src/main/java/info/guardianproject/phoneypot/service/AccelerometerMonitor.java
+++ b/src/main/java/info/guardianproject/phoneypot/service/AccelerometerMonitor.java
@@ -16,6 +16,7 @@ import android.os.RemoteException;
import android.util.Log;
import info.guardianproject.phoneypot.PreferenceManager;
+import info.guardianproject.phoneypot.model.EventTrigger;
/**
* Created by n8fr8 on 3/10/17.
@@ -128,7 +129,7 @@ public class AccelerometerMonitor implements SensorEventListener {
remainingAlertPeriod = maxAlertPeriod;
Message message = new Message();
- message.what = MonitorService.ACCELEROMETER_MESSAGE;
+ message.what = EventTrigger.ACCELEROMETER;
try {
if (serviceMessenger != null) {
diff --git a/src/main/java/info/guardianproject/phoneypot/service/MicrophoneMonitor.java b/src/main/java/info/guardianproject/phoneypot/service/MicrophoneMonitor.java
index 0c2218a..c684787 100644
--- a/src/main/java/info/guardianproject/phoneypot/service/MicrophoneMonitor.java
+++ b/src/main/java/info/guardianproject/phoneypot/service/MicrophoneMonitor.java
@@ -15,6 +15,7 @@ import android.os.RemoteException;
import android.util.Log;
import info.guardianproject.phoneypot.PreferenceManager;
+import info.guardianproject.phoneypot.model.EventTrigger;
import info.guardianproject.phoneypot.sensors.media.MicSamplerTask;
import info.guardianproject.phoneypot.sensors.media.MicrophoneTaskFactory;
@@ -114,7 +115,7 @@ public final class MicrophoneMonitor implements MicSamplerTask.MicListener {
if (averageDB > NOISE_THRESHOLD) {
Message message = new Message();
- message.what = MonitorService.MICROPHONE_MESSAGE;
+ message.what = EventTrigger.MICROPHONE;
try {
if (serviceMessenger != null)
serviceMessenger.send(message);
diff --git a/src/main/java/info/guardianproject/phoneypot/service/MonitorService.java b/src/main/java/info/guardianproject/phoneypot/service/MonitorService.java
index d600469..b670de2 100644
--- a/src/main/java/info/guardianproject/phoneypot/service/MonitorService.java
+++ b/src/main/java/info/guardianproject/phoneypot/service/MonitorService.java
@@ -38,21 +38,6 @@ public class MonitorService extends Service {
* To show a notification on service start
*/
private NotificationManager manager;
-
- /**
- * Acceleration detected message
- */
- public static final int ACCELEROMETER_MESSAGE = 0;
-
- /**
- * Camera motion detected message
- */
- public static final int CAMERA_MESSAGE = 1;
-
- /**
- * Mic noise detected message
- */
- public static final int MICROPHONE_MESSAGE = 2;
/**
* True only if service has been alerted by the accelerometer
@@ -205,6 +190,8 @@ public class MonitorService extends Service {
{
mLastEvent = new Event();
isNewEvent = true;
+ mLastEvent.save();
+
}
else if (!mLastEvent.insideEventWindow(now))
{
@@ -216,20 +203,10 @@ public class MonitorService extends Service {
isNewEvent = true;
}
- EventTrigger eventTrigger = null;
- switch (alertType) {
- case MonitorService.ACCELEROMETER_MESSAGE:
- eventTrigger = new EventTrigger(EventTrigger.TriggerType.ACCEL);
- break;
- case MonitorService.MICROPHONE_MESSAGE:
- eventTrigger = new EventTrigger(EventTrigger.TriggerType.SOUND);
- break;
- case MonitorService.CAMERA_MESSAGE:
- eventTrigger = new EventTrigger(EventTrigger.TriggerType.CAMERA);
- break;
- }
-
+ EventTrigger eventTrigger = new EventTrigger();
+ eventTrigger.setType(alertType);
mLastEvent.addEventTrigger(eventTrigger);
+ eventTrigger.save();
/*
* If SMS mode is on we send an SMS alert to the specified
@@ -246,7 +223,6 @@ public class MonitorService extends Service {
}
- mLastEvent.save();
}
diff --git a/src/main/java/info/guardianproject/phoneypot/ui/EventAdapter.java b/src/main/java/info/guardianproject/phoneypot/ui/EventAdapter.java
new file mode 100644
index 0000000..1d54325
--- /dev/null
+++ b/src/main/java/info/guardianproject/phoneypot/ui/EventAdapter.java
@@ -0,0 +1,85 @@
+package info.guardianproject.phoneypot.ui;
+
+import android.content.Context;
+import android.provider.ContactsContract;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import java.util.List;
+
+import info.guardianproject.phoneypot.R;
+import info.guardianproject.phoneypot.model.Event;
+
+/**
+ * Created by n8fr8 on 4/16/17.
+ */
+
+public class EventAdapter extends RecyclerView.Adapter<EventAdapter.EventVH> {
+
+ Context context;
+ List<Event> events;
+
+ OnItemClickListener clickListener;
+
+ public EventAdapter(Context context, List<Event> events) {
+ this.context = context;
+ this.events = events;
+
+ }
+
+
+ @Override
+ public EventVH onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.event_item, parent, false);
+ EventVH viewHolder = new EventVH(view);
+ return viewHolder;
+ }
+
+ @Override
+ public void onBindViewHolder(EventVH holder, int position) {
+
+ Event event = events.get(position);
+
+ String title = event.getStartTime().toLocaleString();
+ String desc = event.getEventTriggers().size() + " triggered events";
+
+ holder.title.setText(title);
+ holder.note.setText(desc);
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return events.size();
+ }
+
+ class EventVH extends RecyclerView.ViewHolder implements View.OnClickListener {
+ TextView title, note;
+
+ public EventVH(View itemView) {
+ super(itemView);
+
+ title = (TextView) itemView.findViewById(R.id.event_item_title);
+ note = (TextView) itemView.findViewById(R.id.event_item_desc);
+
+ itemView.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ clickListener.onItemClick(v, getAdapterPosition());
+ }
+ }
+
+ public interface OnItemClickListener {
+ public void onItemClick(View view, int position);
+ }
+
+ public void SetOnItemClickListener(final OnItemClickListener itemClickListener) {
+ this.clickListener = itemClickListener;
+ }
+
+}
diff --git a/src/main/res/drawable-hdpi/ic_ring_volume_black_24dp.png b/src/main/res/drawable-hdpi/ic_ring_volume_black_24dp.png
new file mode 100644
index 0000000..5815733
Binary files /dev/null and b/src/main/res/drawable-hdpi/ic_ring_volume_black_24dp.png differ
diff --git a/src/main/res/drawable-mdpi/ic_ring_volume_black_24dp.png b/src/main/res/drawable-mdpi/ic_ring_volume_black_24dp.png
new file mode 100644
index 0000000..77c4fe9
Binary files /dev/null and b/src/main/res/drawable-mdpi/ic_ring_volume_black_24dp.png differ
diff --git a/src/main/res/drawable-xhdpi/ic_ring_volume_black_24dp.png b/src/main/res/drawable-xhdpi/ic_ring_volume_black_24dp.png
new file mode 100644
index 0000000..799eca4
Binary files /dev/null and b/src/main/res/drawable-xhdpi/ic_ring_volume_black_24dp.png differ
diff --git a/src/main/res/drawable-xxhdpi/ic_ring_volume_black_24dp.png b/src/main/res/drawable-xxhdpi/ic_ring_volume_black_24dp.png
new file mode 100644
index 0000000..94baac9
Binary files /dev/null and b/src/main/res/drawable-xxhdpi/ic_ring_volume_black_24dp.png differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_ring_volume_black_24dp.png b/src/main/res/drawable-xxxhdpi/ic_ring_volume_black_24dp.png
new file mode 100644
index 0000000..9bd31d7
Binary files /dev/null and b/src/main/res/drawable-xxxhdpi/ic_ring_volume_black_24dp.png differ
diff --git a/src/main/res/layout/activity_list.xml b/src/main/res/layout/activity_list.xml
new file mode 100644
index 0000000..3989b6f
--- /dev/null
+++ b/src/main/res/layout/activity_list.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ tools:context="info.guardianproject.phoneypot.ListActivity">
+
+ <android.support.design.widget.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/appbar_height"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <android.support.design.widget.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ app:contentScrim="?attr/colorPrimary"
+ app:expandedTitleMarginBottom="32dp"
+ app:expandedTitleMarginEnd="64dp"
+ app:expandedTitleMarginStart="48dp"
+ app:layout_scrollFlags="scroll|exitUntilCollapsed"
+ app:title="@string/app_name">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+
+ </android.support.design.widget.CollapsingToolbarLayout>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <android.support.v7.widget.RecyclerView
+ android:id="@+id/main_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:listitem="@layout/event_item"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/fab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|end"
+ android:layout_margin="@dimen/fab_margin"
+ android:src="@drawable/ic_phone_alert"
+ android:tint="@android:color/white" />
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/src/main/res/layout/activity_start.xml b/src/main/res/layout/activity_start.xml
index 41c223c..a25eb4e 100644
--- a/src/main/res/layout/activity_start.xml
+++ b/src/main/res/layout/activity_start.xml
@@ -1,7 +1,16 @@
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
<LinearLayout
android:orientation="vertical"
@@ -104,6 +113,5 @@
/>
-
</LinearLayout>
-</ScrollView>
\ No newline at end of file
+</LinearLayout>
\ No newline at end of file
diff --git a/src/main/res/layout/camera_fragment.xml b/src/main/res/layout/camera_fragment.xml
index 92bdbf6..d24bd94 100644
--- a/src/main/res/layout/camera_fragment.xml
+++ b/src/main/res/layout/camera_fragment.xml
@@ -7,29 +7,17 @@
<FrameLayout android:id="@+id/preview"
android:layout_centerHorizontal="true"
- android:layout_width="150dp"
- android:layout_height="200dp">
+ android:layout_width="1dp"
+ android:layout_height="1dp">
</FrameLayout>
-
- <ImageView
- android:src="@drawable/ic_launcher"
- android:id="@+id/old_image"
- android:layout_alignParentLeft="true"
- android:layout_width="150dp"
- android:layout_height="200dp"
- android:paddingLeft="20dp"
- android:layout_below="@id/preview"
- />
<ImageView
android:id="@+id/new_image"
android:src="@drawable/ic_launcher"
android:layout_alignParentRight="true"
- android:layout_width="150dp"
- android:layout_height="200dp"
- android:layout_alignRight="@id/old_image"
- android:paddingRight="20dp"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
android:layout_below="@id/preview"
/>
diff --git a/src/main/res/layout/event_item.xml b/src/main/res/layout/event_item.xml
new file mode 100644
index 0000000..48aa7cb
--- /dev/null
+++ b/src/main/res/layout/event_item.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/note_item"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/activity_margin_half"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?attr/selectableItemBackground"
+ android:orientation="vertical"
+ android:padding="@dimen/activity_margin_half">
+
+ <TextView
+ android:id="@+id/event_item_title"
+ style="@style/TextAppearance.AppCompat.Title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ tools:text="Title" />
+
+ <TextView
+ android:id="@+id/event_item_desc"
+ style="@style/TextAppearance.AppCompat.Body1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="@dimen/activity_margin_half"
+ android:alpha="0.54"
+ android:ellipsize="end"
+ android:maxLines="6"
+ android:paddingBottom="@dimen/activity_margin_half"
+ android:textColor="@android:color/black"
+ tools:text="Description" />
+
+ </LinearLayout>
+
+</android.support.v7.widget.CardView>
\ No newline at end of file
diff --git a/src/main/res/menu/monitor_activity.xml b/src/main/res/menu/monitor_activity.xml
index 4e3c4f3..0a00b6d 100644
--- a/src/main/res/menu/monitor_activity.xml
+++ b/src/main/res/menu/monitor_activity.xml
@@ -1,6 +1,7 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_settings"
android:title="@string/menu_stop"
android:orderInCategory="100"
- android:showAsAction="never" />
+ app:showAsAction="never" />
</menu>
diff --git a/src/main/res/menu/monitor_start.xml b/src/main/res/menu/monitor_start.xml
index d1bfef5..6b0e5df 100644
--- a/src/main/res/menu/monitor_start.xml
+++ b/src/main/res/menu/monitor_start.xml
@@ -1,6 +1,7 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/menu_start"
android:title="@string/menu_start"
android:orderInCategory="100"
- android:showAsAction="always|withText" />
+ app:showAsAction="always|withText" />
</menu>
diff --git a/src/main/res/values-v11/styles.xml b/src/main/res/values-v11/styles.xml
deleted file mode 100644
index d408cbc..0000000
--- a/src/main/res/values-v11/styles.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<resources>
-
- <style name="AppTheme" parent="android:Theme.Holo.Light" />
-
-</resources>
\ No newline at end of file
diff --git a/src/main/res/values-v14/styles.xml b/src/main/res/values-v14/styles.xml
deleted file mode 100644
index 1c089a7..0000000
--- a/src/main/res/values-v14/styles.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<resources>
-
- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
-
-</resources>
\ No newline at end of file
diff --git a/src/main/res/values/colors.xml b/src/main/res/values/colors.xml
new file mode 100644
index 0000000..6882703
--- /dev/null
+++ b/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#838c8f</color>
+ <color name="colorPrimaryDark">#324753</color>
+ <color name="colorAccent">#E56139</color>
+</resources>
\ No newline at end of file
diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..f53d98c
--- /dev/null
+++ b/src/main/res/values/dimens.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <!-- Default screen margins, per the Android Design guidelines. -->
+ <dimen name="activity_horizontal_margin">16dp</dimen>
+ <dimen name="activity_vertical_margin">16dp</dimen>
+ <dimen name="fab_margin">16dp</dimen>
+ <dimen name="appbar_height">192dp</dimen>
+
+
+ <dimen name="statusbar_toolbar_height">80dp</dimen>
+ <dimen name="appbar_height_offset">136dp</dimen>
+ <dimen name="activity_margin_half">8dp</dimen>
+
+</resources>
\ No newline at end of file
diff --git a/src/main/res/values/styles.xml b/src/main/res/values/styles.xml
index 4dba0d0..a43cd56 100644
--- a/src/main/res/values/styles.xml
+++ b/src/main/res/values/styles.xml
@@ -1,5 +1,18 @@
<resources>
- <style name="AppTheme" parent="android:Theme.Light" />
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+
+ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
+
+ <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
\ No newline at end of file