diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java b/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java new file mode 100644 index 000000000..1f2ba9291 --- /dev/null +++ b/src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java @@ -0,0 +1,110 @@ +package eu.siacs.conversations.ui; + +import android.app.Activity; +import android.content.Intent; +import android.content.res.Configuration; +import android.graphics.Bitmap; +import android.net.Uri; +import android.os.Bundle; +import android.view.View; +import android.view.Window; +import android.widget.ImageView; +import android.widget.Toast; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.request.animation.GlideAnimation; +import com.bumptech.glide.request.target.BitmapImageViewTarget; +import com.github.rtoshiro.view.video.FullscreenVideoLayout; + +import java.io.File; +import java.io.IOException; + +import eu.siacs.conversations.R; +import uk.co.senab.photoview.PhotoView; +import uk.co.senab.photoview.PhotoViewAttacher; + +public class ShowFullscreenMessageActivity extends Activity { + + PhotoView mImage; + FullscreenVideoLayout mVideo; + ImageView mFullscreenbutton; + Uri mFileUri; + File mFile; + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + getWindow().requestFeature(Window.FEATURE_ACTION_BAR); + getActionBar().hide(); + setContentView(R.layout.activity_fullscreen_message); + mImage = (PhotoView) findViewById(R.id.message_image_view); + mVideo = (FullscreenVideoLayout) findViewById(R.id.message_video_view); + mFullscreenbutton = (ImageView) findViewById(R.id.vcv_img_fullscreen); + } + + @Override + protected void onResume() { + super.onResume(); + Intent intent = getIntent(); + + if (intent != null) { + if (intent.hasExtra("image")) { + mFileUri = intent.getParcelableExtra("image"); + mFile = new File(mFileUri.getPath()); + if (mFileUri != null) { + DisplayImage(mFile); + } else { + Toast.makeText(ShowFullscreenMessageActivity.this, getString(R.string.file_deleted), Toast.LENGTH_SHORT).show(); + } + } else if (intent.hasExtra("video")) { + mFileUri = intent.getParcelableExtra("video"); + if (mFileUri != null) { + DisplayVideo(mFileUri); + } else { + Toast.makeText(ShowFullscreenMessageActivity.this, getString(R.string.file_deleted), Toast.LENGTH_SHORT).show(); + } + } + } + } + + @Override + protected void onPause() { + super.onPause(); + } + + private void DisplayImage(File file) { + final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage); + mImage.setVisibility(View.VISIBLE); + try { + Glide.with(this) + .load(file) + .asBitmap() + .into(new BitmapImageViewTarget(mImage) { + @Override + public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { + super.onResourceReady(resource, glideAnimation); + mAttacher.update(); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void DisplayVideo(Uri uri) { + try { + mVideo.setVisibility(View.VISIBLE); + mVideo.setVideoURI(uri); + mFullscreenbutton.setVisibility(View.INVISIBLE); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + } +}
\ No newline at end of file |