summaryrefslogtreecommitdiff
path: root/java/com/android/dialer
diff options
context:
space:
mode:
authormaxwelb <maxwelb@google.com>2017-07-19 09:56:50 -0700
committerEric Erfanian <erfanian@google.com>2017-07-25 16:42:53 +0000
commit193c724dda95d6ac29b2ab90483080099986977f (patch)
tree0fc3a551043204e1999be49165eb69ace60db74b /java/com/android/dialer
parent09b15491c67ac56d344a70309dc7b9c19de0ded2 (diff)
Move CallComposerActivity's DialerExecutor to onCreate
As per the documentation, DialerExecutors.createUiTaskBuilder is meant to be called in onCreate. As a side effect of this change, if at some point we support sending both an image and text at the same time, the code will not work. This is not currently planned, so this CL stays simple, rather than adding the complexity of plumbing the old MultimediaData through CopyAndResizeImageWorker. Bug: 63714992 Test: CallComposerActivityIntegrationTest, manually placed EC call PiperOrigin-RevId: 162498272 Change-Id: I710e94284b2235684a27afbfa12ea8ddef0690de
Diffstat (limited to 'java/com/android/dialer')
-rw-r--r--java/com/android/dialer/callcomposer/CallComposerActivity.java50
1 files changed, 28 insertions, 22 deletions
diff --git a/java/com/android/dialer/callcomposer/CallComposerActivity.java b/java/com/android/dialer/callcomposer/CallComposerActivity.java
index 7ca759dc0..ddc1e87f8 100644
--- a/java/com/android/dialer/callcomposer/CallComposerActivity.java
+++ b/java/com/android/dialer/callcomposer/CallComposerActivity.java
@@ -32,6 +32,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
+import android.support.v4.util.Pair;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.support.v7.app.AppCompatActivity;
@@ -56,6 +57,7 @@ import com.android.dialer.callintent.CallIntentBuilder;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.common.UiUtil;
+import com.android.dialer.common.concurrent.DialerExecutor;
import com.android.dialer.common.concurrent.DialerExecutors;
import com.android.dialer.common.concurrent.ThreadUtil;
import com.android.dialer.configprovider.ConfigProviderBindings;
@@ -139,6 +141,7 @@ public class CallComposerActivity extends AppCompatActivity
private FrameLayout background;
private LinearLayout windowContainer;
+ private DialerExecutor<Uri> copyAndResizeExecutor;
private FastOutSlowInInterpolator interpolator;
private boolean shouldAnimateEntrance = true;
private boolean inFullscreenMode;
@@ -207,6 +210,29 @@ public class CallComposerActivity extends AppCompatActivity
});
setMediaIconSelected(currentIndex);
+
+ copyAndResizeExecutor =
+ DialerExecutors.createUiTaskBuilder(
+ getFragmentManager(),
+ "copyAndResizeImageToSend",
+ new CopyAndResizeImageWorker(this.getApplicationContext()))
+ .onSuccess(this::onCopyAndResizeImageSuccess)
+ .onFailure(this::onCopyAndResizeImageFailure)
+ .build();
+ }
+
+ private void onCopyAndResizeImageSuccess(Pair<File, String> output) {
+ Uri shareableUri =
+ FileProvider.getUriForFile(
+ CallComposerActivity.this, Constants.get().getFileProviderAuthority(), output.first);
+
+ placeRCSCall(
+ MultimediaData.builder().setImage(grantUriPermission(shareableUri), output.second));
+ }
+
+ private void onCopyAndResizeImageFailure(Throwable throwable) {
+ // TODO(b/34279096) - gracefully handle message failure
+ LogUtil.e("CallComposerActivity.onCopyAndResizeImageFailure", "copy Failed", throwable);
}
@Override
@@ -332,28 +358,8 @@ public class CallComposerActivity extends AppCompatActivity
GalleryComposerFragment galleryComposerFragment = (GalleryComposerFragment) fragment;
// If the current data is not a copy, make one.
if (!galleryComposerFragment.selectedDataIsCopy()) {
- DialerExecutors.createUiTaskBuilder(
- getFragmentManager(),
- "copyAndResizeImageToSend",
- new CopyAndResizeImageWorker(this.getApplicationContext()))
- .onSuccess(
- output -> {
- Uri shareableUri =
- FileProvider.getUriForFile(
- CallComposerActivity.this,
- Constants.get().getFileProviderAuthority(),
- output.first);
-
- builder.setImage(grantUriPermission(shareableUri), output.second);
- placeRCSCall(builder);
- })
- .onFailure(
- throwable -> {
- // TODO(b/34279096) - gracefully handle message failure
- LogUtil.e("CallComposerActivity.onCopyFailed", "copy Failed", throwable);
- })
- .build()
- .executeParallel(galleryComposerFragment.getGalleryData().getFileUri());
+ copyAndResizeExecutor.executeParallel(
+ galleryComposerFragment.getGalleryData().getFileUri());
} else {
Uri shareableUri =
FileProvider.getUriForFile(