From 542e962be9db3cf7c2a58d9dbd0c58bdf7aec553 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 18 Jun 2018 12:05:58 -0700 Subject: [PATCH] Fixed crash when ScribbleView failed to save. Previously, if an operation failed, we set the result to "null". However, this was a mistake. Setting the result at all assumes success. Instead, we need to set an exception so the ListenableFuture knows that the operation failed. --- res/values/strings.xml | 3 +++ .../thoughtcrime/securesms/scribbles/ScribbleActivity.java | 3 +++ .../thoughtcrime/securesms/scribbles/widget/ScribbleView.java | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index a6f2536b3a..8e5af928a8 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -584,6 +584,9 @@ Add ringtone Unable to add custom ringtone + + Failed to save image changes + Begin typing to search for conversations, messages, and contacts. No results found for \'%s\' diff --git a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java index ec9d083218..4004ef4d6d 100644 --- a/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java +++ b/src/org/thoughtcrime/securesms/scribbles/ScribbleActivity.java @@ -14,6 +14,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; import android.view.View; +import android.widget.Toast; import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity; import org.thoughtcrime.securesms.R; @@ -242,6 +243,8 @@ public class ScribbleActivity extends PassphraseRequiredActionBarActivity implem @Override public void onFailure(ExecutionException e) { Log.w(TAG, e); + Toast.makeText(ScribbleActivity.this, R.string.ScribbleActivity_save_failure, Toast.LENGTH_SHORT).show(); + finish(); } }); } diff --git a/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java b/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java index d0e04376d5..ed1009b6e8 100644 --- a/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java +++ b/src/org/thoughtcrime/securesms/scribbles/widget/ScribbleView.java @@ -98,7 +98,7 @@ public class ScribbleView extends FrameLayout { final boolean isLowMemory = Util.isLowMemory(context); if (imageUri == null) { - future.set(null); + future.setException(new IllegalStateException("No image URI.")); return future; } @@ -126,7 +126,7 @@ public class ScribbleView extends FrameLayout { @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { - future.set(null); + future.setException(new Throwable("Failed to load image.")); } });