diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-06-30 15:36:42 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-06-30 15:36:42 +0200 |
commit | 01eb94ef997c22f9de46894d06be8ee8a87beb66 (patch) | |
tree | 67c16222d6f093d88c3e3a07934ac0bf2fbbc079 /src/main/java/eu/siacs/conversations/ui | |
parent | 80912a71d7238bcd08d52caf26666b9b3865cd8d (diff) |
add share button to image/video view
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java index e59df4d28..aa58a673b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java @@ -10,6 +10,8 @@ import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; +import android.webkit.MimeTypeMap; +import android.widget.ImageButton; import android.widget.ImageView; import android.widget.Toast; @@ -27,11 +29,13 @@ import uk.co.senab.photoview.PhotoViewAttacher; public class ShowFullscreenMessageActivity extends Activity { + private ConversationActivity activity; PhotoView mImage; FullscreenVideoLayout mVideo; ImageView mFullscreenbutton; Uri mFileUri; File mFile; + ImageButton mFAB; @Override @@ -55,6 +59,36 @@ public class ShowFullscreenMessageActivity extends Activity { mImage = (PhotoView) findViewById(R.id.message_image_view); mVideo = (FullscreenVideoLayout) findViewById(R.id.message_video_view); mFullscreenbutton = (ImageView) findViewById(R.id.vcv_img_fullscreen); + + mFAB = (ImageButton) findViewById(R.id.imageButton); + mFAB.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mVideo.reset(); + shareWith(mFileUri); + } + }); + } + + private void shareWith(Uri mFileUri) { + Intent share = new Intent(Intent.ACTION_SEND); + share.setType(getMimeType(mFileUri.toString())); + share.putExtra(Intent.EXTRA_STREAM, Uri.parse(mFileUri.toString())); + startActivity(Intent.createChooser(share, getString(R.string.share_with))); + } + + public static String getMimeType(String path) { + try { + String type = null; + String extension = path.substring(path.lastIndexOf(".") + 1, path.length()); + if (extension != null) { + type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); + } + return type; + } catch (Exception e) { + e.printStackTrace(); + } + return null; } @Override @@ -82,11 +116,6 @@ public class ShowFullscreenMessageActivity extends Activity { } } - @Override - protected void onPause() { - super.onPause(); - } - private void DisplayImage(File file) { final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage); mImage.setVisibility(View.VISIBLE); |