Skip to content

Commit

Permalink
more work on #330, get preference to work
Browse files Browse the repository at this point in the history
  • Loading branch information
n8fr8 committed Aug 20, 2018
1 parent 1711315 commit 3e83443
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/main/java/org/havenapp/main/PreferenceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class PreferenceManager {

private static final String CURRENT_EVENT_START_TIME = "current_event_start_time";

private static final String CONFIG_BASE_STORAGE = "config_base_storage";
public static final String CONFIG_BASE_STORAGE = "config_base_storage";
private static final String CONFIG_BASE_STORAGE_DEFAULT = "/phoneypot";

private Context context;
Expand Down Expand Up @@ -308,6 +308,12 @@ public String getDefaultMediaStoragePath() {
return appSharedPrefs.getString(CONFIG_BASE_STORAGE,CONFIG_BASE_STORAGE_DEFAULT) + File.separator + getCurrentSession(); //phoneypot is the old code name for Haven
}

public void setDefaultMediaStoragePath (String path)
{
prefsEditor.putString(CONFIG_BASE_STORAGE,path);
prefsEditor.commit();
}

public int getAudioLength ()
{
return 15000; //30 seconds
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/havenapp/main/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
}
break;
}
case PreferenceManager.CONFIG_BASE_STORAGE: {
setDefaultStoragePath();
break;
}
}
}

Expand All @@ -440,6 +444,11 @@ String getCountryCode() {
return "+" + String.valueOf(phoneUtil.getCountryCodeForRegion(Locale.getDefault().getCountry()));
}

private void setDefaultStoragePath () {
String defaultStoragePath = ((EditTextPreference) findPreference(PreferenceManager.CONFIG_BASE_STORAGE)).getText();
preferences.setDefaultMediaStoragePath(defaultStoragePath);
}

private void setPhoneNumber() {
boolean smsActive = ((SwitchPreferenceCompat) findPreference(PreferenceManager.SMS_ACTIVE)).isChecked();
String phoneNumber = ((EditTextPreference) findPreference(PreferenceManager.SMS_NUMBER)).getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class CameraViewHolder {
private MotionDetector task;

AndroidSequenceEncoder encoder;
private String videoFile;
private File videoFile;

//for managing bitmap processing
private RenderScript renderScript;
Expand Down Expand Up @@ -297,7 +297,7 @@ private void finishVideoEncoding ()
if (serviceMessenger != null) {
Message message = new Message();
message.what = EventTrigger.CAMERA_VIDEO;
message.getData().putString(MonitorService.KEY_PATH, videoFile);
message.getData().putString(MonitorService.KEY_PATH, videoFile.getAbsolutePath());
try {
serviceMessenger.send(message);
} catch (RemoteException e) {
Expand Down Expand Up @@ -330,9 +330,13 @@ private synchronized boolean recordVideo() {
if (doingVideoProcessing)
return false;
String ts1 = String.valueOf(new Date().getTime());
videoFile = Environment.getExternalStorageDirectory() + File.separator + prefs.getDefaultMediaStoragePath() + File.separator + ts1 + ".mp4";
File fileStoragePath = new File(Environment.getExternalStorageDirectory(),prefs.getDefaultMediaStoragePath());
fileStoragePath.mkdirs();

videoFile = new File(fileStoragePath, ts1 + ".mp4");

try {
encoder = AndroidSequenceEncoder.createSequenceEncoder(new File(videoFile),5);
encoder = AndroidSequenceEncoder.createSequenceEncoder(videoFile,5);

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

0 comments on commit 3e83443

Please sign in to comment.