transform google photos nonsense URI scheme to something usable when necessary

Fixes #3307
Closes #3375
// FREEBIE
This commit is contained in:
Rhodey Orbits 2015-06-08 20:56:13 -07:00 committed by Jake McGinty
parent 0f7f458ce0
commit cb3cf7789f

View file

@ -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)) {