Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3850e02c authored by LuK1337's avatar LuK1337
Browse files

Recorder: Use getExternalFilesDir() for recording paths

Change-Id: I7bac305718ed64ceb535b3ca4678fbb41ec9417a
parent 36fb62bc
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -38,9 +38,6 @@ import java.util.concurrent.Semaphore;

class RecordingDevice extends EncoderDevice {
    private static final String LOGTAG = "RecordingDevice";
    private static final File RECORDINGS_DIR =
            new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES),
                    "ScreenRecords");
    private final boolean mRecordAudio;
    private final File mPath;

@@ -51,7 +48,8 @@ class RecordingDevice extends EncoderDevice {
        String videoDate = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault())
                .format(new Date());
        // the directory which holds all recording files
        mPath = new File(RECORDINGS_DIR, "ScreenRecord-" + videoDate + ".mp4");
        mPath = new File(context.getExternalFilesDir(Environment.DIRECTORY_MOVIES),
                "ScreenRecords/ScreenRecord-" + videoDate + ".mp4");
    }

    /**
+5 −7
Original line number Diff line number Diff line
@@ -61,9 +61,6 @@ public class SoundRecorderService extends Service {
            "soundrecorder_notification_channel";

    private static final String TAG = "SoundRecorderService";
    private static final File RECORDINGS_DIR =
            new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC),
                    "SoundRecords");
    private static final int SAMPLING_RATE = 44100;
    private static final int CHANNEL_IN = AudioFormat.CHANNEL_IN_DEFAULT;
    private static final int FORMAT = AudioFormat.ENCODING_PCM_16BIT;
@@ -214,11 +211,12 @@ public class SoundRecorderService extends Service {
    private File createNewAudioFile() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss",
                Locale.getDefault());
        File file = new File(RECORDINGS_DIR,
                "SoundRecord-" + dateFormat.format(new Date()) + EXTENSION);
        if (!RECORDINGS_DIR.exists()) {
        File file = new File(getExternalFilesDir(Environment.DIRECTORY_MUSIC),
                "SoundRecords/SoundRecord-" + dateFormat.format(new Date()) + EXTENSION);
        File recordingDir = file.getParentFile();
        if (!recordingDir.exists()) {
            //noinspection ResultOfMethodCallIgnored
            RECORDINGS_DIR.mkdirs();
            recordingDir.mkdirs();
        }
        return file;
    }