Search in sources :

Example 1 with PersistentBlobProvider

use of org.thoughtcrime.securesms.providers.PersistentBlobProvider in project Signal-Android by WhisperSystems.

the class ScribbleActivity method onSave.

@Override
public void onSave() {
    ListenableFuture<Bitmap> future = scribbleView.getRenderedImage();
    future.addListener(new ListenableFuture.Listener<Bitmap>() {

        @Override
        public void onSuccess(Bitmap result) {
            PersistentBlobProvider provider = PersistentBlobProvider.getInstance(ScribbleActivity.this);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            result.compress(Bitmap.CompressFormat.JPEG, 80, baos);
            byte[] data = baos.toByteArray();
            baos = null;
            result = null;
            Uri uri = provider.create(masterSecret, data, ContentType.IMAGE_JPEG);
            Intent intent = new Intent();
            intent.setData(uri);
            setResult(RESULT_OK, intent);
            finish();
        }

        @Override
        public void onFailure(ExecutionException e) {
            Log.w(TAG, e);
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) ListenableFuture(org.thoughtcrime.securesms.util.concurrent.ListenableFuture) Intent(android.content.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PersistentBlobProvider(org.thoughtcrime.securesms.providers.PersistentBlobProvider) ExecutionException(java.util.concurrent.ExecutionException) Uri(android.net.Uri)

Aggregations

Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ExecutionException (java.util.concurrent.ExecutionException)1 PersistentBlobProvider (org.thoughtcrime.securesms.providers.PersistentBlobProvider)1 ListenableFuture (org.thoughtcrime.securesms.util.concurrent.ListenableFuture)1