2626
2727import org .havenapp .main .sensors .motion .LuminanceMotionDetector ;
2828
29+ import java .io .File ;
30+ import java .util .Date ;
31+
2932
3033public class PreferenceManager {
3134
@@ -86,6 +89,8 @@ public class PreferenceManager {
8689
8790 public static final String DISABLE_BATTERY_OPT = "config_battery_optimizations" ;
8891
92+ private static final String CURRENT_EVENT_START_TIME = "current_event_start_time" ;
93+
8994 private Context context ;
9095
9196 public PreferenceManager (Context context ) {
@@ -293,7 +298,7 @@ public String getSMSText() {
293298
294299 public String getImagePath ()
295300 {
296- return "/phoneypot" ;
301+ return getDefaultMediaStoragePath () ;
297302 }
298303
299304 public int getMaxImages ()
@@ -303,7 +308,11 @@ public int getMaxImages ()
303308
304309 public String getAudioPath ()
305310 {
306- return "/phoneypot" ; //phoneypot is the old code name for Haven
311+ return getDefaultMediaStoragePath ();
312+ }
313+
314+ private String getDefaultMediaStoragePath () {
315+ return "/phoneypot" + File .separator + getCurrentSession (); //phoneypot is the old code name for Haven
307316 }
308317
309318 public int getAudioLength ()
@@ -338,4 +347,26 @@ public int getHeartbeatNotificationTimeMs () {
338347 return appSharedPrefs .getInt (HEARTBEAT_MONITOR_DELAY ,300000 );
339348 }
340349
350+ /**
351+ * Set the {@link org.havenapp.main.model.Event#mStartTime} for the ongoing event.
352+ * Sets a string with the format {@link Utils#DATE_TIME_PATTERN}
353+ * representing current date and time for the key {@link #CURRENT_EVENT_START_TIME}.
354+ *
355+ * @param startTime the {@link org.havenapp.main.model.Event#mStartTime} for an
356+ * {@link org.havenapp.main.model.Event}
357+ */
358+ public void setCurrentSession (Date startTime ) {
359+ prefsEditor .putString (CURRENT_EVENT_START_TIME , Utils .getDateTime (startTime ));
360+ prefsEditor .commit ();
361+ }
362+
363+ /**
364+ * Get the {@link org.havenapp.main.model.Event#mStartTime} for the ongoing event.
365+ *
366+ * @return the string corresponding to pref key {@link #CURRENT_EVENT_START_TIME}.
367+ * Default value is unknown_session.
368+ */
369+ private String getCurrentSession () {
370+ return appSharedPrefs .getString (CURRENT_EVENT_START_TIME , "unknown_session" );
371+ }
341372}
0 commit comments