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

Commit 24864691 authored by Michael W's avatar Michael W Committed by Bruno Martins
Browse files

Recorder: Add possibility to delete last recording from notification

* What the title says

Change-Id: Ib2975077392716e7479e9067f1182b647b705579
parent 3438a233
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public class DialogActivity extends AppCompatActivity implements
    public static final String EXTRA_LAST_SCREEN = "lastScreenItem";
    public static final String EXTRA_LAST_SOUND = "lastSoundItem";
    public static final String EXTRA_SETTINGS_SCREEN = "settingsScreen";
    public static final String EXTRA_DELETE_LAST_RECORDING = "deleteLastItem";
    private static final int REQUEST_RECORD_AUDIO_PERMS = 213;
    private static final String TYPE_AUDIO = "audio/wav";
    private static final String TYPE_VIDEO = "video/mp4";
@@ -88,6 +89,11 @@ public class DialogActivity extends AppCompatActivity implements
        }

        animateAppareance();

        boolean deleteLastRecording = intent.getBooleanExtra(EXTRA_DELETE_LAST_RECORDING, false);
        if (deleteLastRecording) {
            deleteLastItem(isLastSound);
        }
    }

    @Override
+4 −0
Original line number Diff line number Diff line
@@ -235,6 +235,9 @@ public class ScreencastService extends Service {
        PendingIntent sharePIntent = PendingIntent.getActivity(this, 0,
                LastRecordHelper.getShareIntent(this, file, "video/mp4"),
                PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent deletePIntent = PendingIntent.getActivity(this, 0,
                LastRecordHelper.getDeleteIntent(this, false),
                PendingIntent.FLAG_CANCEL_CURRENT);

        long timeElapsed = SystemClock.elapsedRealtime() - mStartTime;
        LastRecordHelper.setLastItem(this, file, timeElapsed, false);
@@ -249,6 +252,7 @@ public class ScreencastService extends Service {
                        DateUtils.formatElapsedTime(timeElapsed / 1000)))
                .addAction(R.drawable.ic_play, getString(R.string.play), playPIntent)
                .addAction(R.drawable.ic_share, getString(R.string.share), sharePIntent)
                .addAction(R.drawable.ic_delete, getString(R.string.delete), deletePIntent)
                .setContentIntent(pi);
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -298,6 +298,9 @@ public class SoundRecorderService extends Service {
        PendingIntent sharePIntent = PendingIntent.getActivity(this, 0,
                LastRecordHelper.getShareIntent(this, mOutFilePath, "audio/wav"),
                PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent deletePIntent = PendingIntent.getActivity(this, 0,
                LastRecordHelper.getDeleteIntent(this, true),
                PendingIntent.FLAG_CANCEL_CURRENT);

        LastRecordHelper.setLastItem(this, mOutFilePath, mElapsedTime, true);

@@ -309,6 +312,7 @@ public class SoundRecorderService extends Service {
                        DateUtils.formatElapsedTime(mElapsedTime / 1000)))
                .addAction(R.drawable.ic_play, getString(R.string.play), playPIntent)
                .addAction(R.drawable.ic_share, getString(R.string.share), sharePIntent)
                .addAction(R.drawable.ic_delete, getString(R.string.delete), deletePIntent)
                .setContentIntent(pi)
                .build();

+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.net.Uri;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;

import org.lineageos.recorder.DialogActivity;
import org.lineageos.recorder.R;
import org.lineageos.recorder.screen.ScreencastService;
import org.lineageos.recorder.sounds.SoundRecorderService;
@@ -83,6 +84,16 @@ public class LastRecordHelper {
        return intent;
    }

    public static Intent getDeleteIntent(Context context, boolean isSound) {
        Intent intent = new Intent(context, DialogActivity.class);
        intent.putExtra(DialogActivity.EXTRA_TITLE,
                isSound ? R.string.sound_last_title : R.string.screen_last_title);
        intent.putExtra(DialogActivity.EXTRA_LAST_SCREEN, !isSound);
        intent.putExtra(DialogActivity.EXTRA_LAST_SOUND, isSound);
        intent.putExtra(DialogActivity.EXTRA_DELETE_LAST_RECORDING, true);
        return intent;
    }

    public static void setLastItem(Context context, String path, long duration,
                                   boolean isSound) {
        SharedPreferences prefs = context.getSharedPreferences(PREFS, 0);