From cb3cf7789ff8d5b90ca69c73764b92c82e41b9d9 Mon Sep 17 00:00:00 2001 From: Rhodey Orbits Date: Mon, 8 Jun 2015 20:56:13 -0700 Subject: [PATCH] transform google photos nonsense URI scheme to something usable when necessary Fixes #3307 Closes #3375 // FREEBIE --- .../thoughtcrime/securesms/ShareActivity.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/ShareActivity.java b/src/org/thoughtcrime/securesms/ShareActivity.java index 275911c527..0acb3f7801 100644 --- a/src/org/thoughtcrime/securesms/ShareActivity.java +++ b/src/org/thoughtcrime/securesms/ShareActivity.java @@ -31,6 +31,8 @@ import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.util.DynamicLanguage; import org.thoughtcrime.securesms.util.DynamicTheme; +import java.net.URLDecoder; + import ws.com.google.android.mms.ContentType; /** @@ -115,10 +117,23 @@ public class ShareActivity extends PassphraseRequiredActionBarActivity startActivity(intent); } + private Uri getStreamExtra() { + Uri streamUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + if (streamUri.getAuthority().equals("com.google.android.apps.photos.contentprovider") && + streamUri.toString().endsWith("/ACTUAL")) + { + String[] parts = streamUri.toString().split("/"); + if (parts.length > 3) { + return Uri.parse(URLDecoder.decode(parts[parts.length - 2])); + } + } + return streamUri; + } + private Intent getBaseShareIntent(final Class target) { final Intent intent = new Intent(this, target); final String textExtra = getIntent().getStringExtra(Intent.EXTRA_TEXT); - final Uri streamExtra = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); + final Uri streamExtra = getStreamExtra(); final String type = streamExtra != null ? getMimeType(streamExtra) : getIntent().getType(); if (ContentType.isImageType(type)) {