aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-05-28 22:17:22 +0200
committerChristian Schneppe <christian@pix-art.de>2016-05-28 22:17:22 +0200
commit5ec8a55ba51aa60862ec77eecb017257105fac80 (patch)
tree5988834eb4dd0ce1af72b61dd3d8e29b1d044b83
parentb6025f3506ee5adf5ccf42cefd9c3ff57d9ff1a1 (diff)
parent679ac2ea21709d3a4b0e80bdebe740beceac274d (diff)
Merge branch 'refs/heads/internal-Image/Video-Viewer'
-rw-r--r--build.gradle11
-rw-r--r--src/main/AndroidManifest.xml6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ShowFullscreenMessageActivity.java110
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java28
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java72
-rw-r--r--src/main/res/layout/activity_fullscreen_message.xml20
-rw-r--r--src/main/res/values/ids.xml2
7 files changed, 210 insertions, 39 deletions
diff --git a/build.gradle b/build.gradle
index 3374f3604..b380223bb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,6 +17,12 @@ repositories {
mavenCentral()
}
+allprojects {
+ repositories {
+ maven { url "https://jitpack.io" }
+ }
+}
+
configurations {
playstoreCompile
}
@@ -25,7 +31,6 @@ dependencies {
compile project(':libs:MemorizingTrustManager')
compile project(':libs:audiowife')
-
playstoreCompile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'org.sufficientlysecure:openpgp-api:10.0'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
@@ -48,6 +53,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
compile 'com.android.support:multidex:1.0.1'
compile 'com.github.bumptech.glide:glide:3.5.2'
+ compile 'com.github.chrisbanes:PhotoView:1.2.6'
+ compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
compile 'com.google.android.gms:play-services-location:9.0.0'
compile 'com.google.android.gms:play-services-maps:9.0.0'
}
@@ -66,7 +73,7 @@ android {
minSdkVersion 14
targetSdkVersion 23
versionCode 144
- versionName "1.12.3"
+ versionName "1.12.4"
archivesBaseName += "-$versionName"
applicationId "eu.siacs.conversations"
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 1310816c4..a2acd1d38 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -29,6 +29,7 @@
android:label="@string/app_name"
android:theme="@style/ConversationsTheme"
android:name="android.support.multidex.MultiDexApplication"
+ android:largeHeap="true"
tools:replace="android:label">
<service android:name=".services.XmppConnectionService"/>
@@ -202,6 +203,11 @@
</intent-filter>
</activity>
<activity
+ android:name=".ui.ShowFullscreenMessageActivity"
+ android:configChanges="orientation|screenSize">
+
+ </activity>
+ <activity
android:name=".ui.TrustKeysActivity"
android:label="@string/trust_omemo_fingerprints"
android:windowSoftInputMode="stateAlwaysHidden" />
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
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index faa314752..0cefe1d2d 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -1193,18 +1193,22 @@ public abstract class XmppActivity extends Activity {
return xmppConnectionService.getAvatarService();
}
- public void loadBitmap(Message message, ImageView imageView) {
- File bm;
- bm = xmppConnectionService.getFileBackend().getFile(message, true);
- Glide.with(this)
- .load(bm)
- .override(400, 400)
- .fitCenter()
- //.centerCrop()
- .diskCacheStrategy(DiskCacheStrategy.RESULT)
- .into(imageView);
+ public void loadBitmap(Message message, ImageView imageView) {
+ File bm;
+ bm = xmppConnectionService.getFileBackend().getFile(message, true);
+ try {
+ Glide.with(this)
+ .load(bm)
+ .override(400, 400)
+ .fitCenter()
+ //.centerCrop()
+ .diskCacheStrategy(DiskCacheStrategy.RESULT)
+ .into(imageView);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- }
+ }
public void loadVideoPreview(Message message, ImageView imageView) {
File vp = xmppConnectionService.getFileBackend().getFile(message, true);
@@ -1214,7 +1218,7 @@ public abstract class XmppActivity extends Activity {
retriever.setDataSource(this, Uri.fromFile(vp));
String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
long microSecond = Long.parseLong(time);
- int duration = (int) microSecond / 2; //preview at half of video
+ int duration = (int) Math.ceil(microSecond / 2); //preview at half of video
BitmapPool bitmapPool = Glide.get(getApplicationContext()).getBitmapPool();
VideoBitmapDecoder videoBitmapDecoder = new VideoBitmapDecoder(duration);
FileDescriptorBitmapDecoder fileDescriptorBitmapDecoder = new FileDescriptorBitmapDecoder(videoBitmapDecoder, bitmapPool, DecodeFormat.PREFER_ARGB_8888);
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 8fe1d029a..54cf97933 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -51,6 +51,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Message.FileParams;
import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.ui.ConversationActivity;
+import eu.siacs.conversations.ui.ShowFullscreenMessageActivity;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.UIHelper;
@@ -746,31 +747,52 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return view;
}
- public void openDownloadable(Message message) {
- DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
- if (!file.exists()) {
- Toast.makeText(activity,R.string.file_deleted,Toast.LENGTH_SHORT).show();
- return;
- }
- Intent openIntent = new Intent(Intent.ACTION_VIEW);
- String mime = file.getMimeType();
- if (mime == null) {
- mime = "*/*";
- }
- openIntent.setDataAndType(Uri.fromFile(file), mime);
- PackageManager manager = activity.getPackageManager();
- List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
- if (infos.size() == 0) {
- openIntent.setDataAndType(Uri.fromFile(file),"*/*");
- }
- try {
- getContext().startActivity(openIntent);
- return;
- } catch (ActivityNotFoundException e) {
- //ignored
- }
- Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
- }
+ public void openDownloadable(Message message) {
+ DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
+ if (!file.exists()) {
+ Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ String mime = file.getMimeType();
+
+ if (mime.startsWith("image/")) {
+ Intent intent = new Intent(getContext(), ShowFullscreenMessageActivity.class);
+ intent.putExtra("image", Uri.fromFile(file));
+ try {
+ activity.startActivity(intent);
+ return;
+ } catch (ActivityNotFoundException e) {
+ //ignored
+ }
+ } else if (mime.startsWith("video/")) {
+ Intent intent = new Intent(getContext(), ShowFullscreenMessageActivity.class);
+ intent.putExtra("video", Uri.fromFile(file));
+ try {
+ activity.startActivity(intent);
+ return;
+ } catch (ActivityNotFoundException e) {
+ //ignored
+ }
+ }
+ Intent openIntent = new Intent(Intent.ACTION_VIEW);
+ if (mime == null) {
+ mime = "*/*";
+ }
+ openIntent.setDataAndType(Uri.fromFile(file), mime);
+ PackageManager manager = activity.getPackageManager();
+ List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
+ if (infos.size() == 0) {
+ openIntent.setDataAndType(Uri.fromFile(file), "*/*");
+ }
+ try {
+ getContext().startActivity(openIntent);
+ return;
+ } catch (ActivityNotFoundException e) {
+ //ignored
+ }
+ Toast.makeText(activity, R.string.no_application_found_to_open_file, Toast.LENGTH_SHORT).show();
+
+ }
public void showLocation(Message message) {
for(Intent intent : GeoHelper.createGeoIntentsFromMessage(message)) {
diff --git a/src/main/res/layout/activity_fullscreen_message.xml b/src/main/res/layout/activity_fullscreen_message.xml
new file mode 100644
index 000000000..183513196
--- /dev/null
+++ b/src/main/res/layout/activity_fullscreen_message.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:background="@android:color/black">
+
+ <uk.co.senab.photoview.PhotoView
+ android:id="@id/message_image_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:adjustViewBounds="true"
+ android:visibility="gone" />
+
+ <com.github.rtoshiro.view.video.FullscreenVideoLayout
+ android:id="@id/message_video_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone" />
+</LinearLayout> \ No newline at end of file
diff --git a/src/main/res/values/ids.xml b/src/main/res/values/ids.xml
index 76c3940b0..75f75673b 100644
--- a/src/main/res/values/ids.xml
+++ b/src/main/res/values/ids.xml
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="snackbar_location_message" type="id" />
+ <item name="message_image_view" type="id" />
+ <item name="message_video_view" type="id" />
</resources> \ No newline at end of file