aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java98
-rw-r--r--src/main/res/drawable-hdpi/ic_open_in_new_white_24dp.pngbin0 -> 312 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_open_in_new_white_24dp.pngbin0 -> 292 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_open_in_new_white_24dp.pngbin0 -> 488 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_open_in_new_white_24dp.pngbin0 -> 546 bytes
-rw-r--r--src/main/res/drawable-xxxhdpi/ic_open_in_new_white_24dp.pngbin0 -> 1204 bytes
-rw-r--r--src/main/res/layout/activity_media_viewer.xml48
-rw-r--r--src/main/res/menu/media_viewer.xml5
8 files changed, 67 insertions, 84 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java
index 2f2dcdf97..f3bdbaadb 100644
--- a/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/MediaViewerActivity.java
@@ -7,6 +7,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
+import android.databinding.DataBindingUtil;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
@@ -31,6 +32,8 @@ import android.widget.Toast;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.github.rtoshiro.view.video.FullscreenVideoLayout;
+import com.leinardi.android.speeddial.SpeedDialActionItem;
+import com.leinardi.android.speeddial.SpeedDialView;
import java.io.File;
import java.io.FileNotFoundException;
@@ -40,28 +43,27 @@ import java.util.List;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
+import de.pixart.messenger.databinding.ActivityMediaViewerBinding;
import de.pixart.messenger.persistance.FileBackend;
import de.pixart.messenger.utils.ExifHelper;
import de.pixart.messenger.utils.MimeUtils;
import pl.droidsonroids.gif.GifImageView;
+import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.persistance.FileBackend.close;
public class MediaViewerActivity extends XmppActivity {
Integer oldOrientation;
- SubsamplingScaleImageView mImage;
- GifImageView mGIF;
- FullscreenVideoLayout mVideo;
ImageView mFullscreenbutton;
Uri mFileUri;
File mFile;
- FloatingActionButton fab;
int height = 0;
int width = 0;
int rotation = 0;
boolean isImage = false;
boolean isVideo = false;
+ private ActivityMediaViewerBinding binding;
public static String getMimeType(String path) {
try {
@@ -80,6 +82,7 @@ public class MediaViewerActivity extends XmppActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ this.binding = DataBindingUtil.setContentView(this, R.layout.activity_media_viewer);
this.mTheme = findTheme();
setTheme(this.mTheme);
@@ -97,56 +100,27 @@ public class MediaViewerActivity extends XmppActivity {
getWindow().setAttributes(layout);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.activity_media_viewer);
- mImage = findViewById(R.id.message_image_view);
- mGIF = findViewById(R.id.message_gif_view);
- mVideo = findViewById(R.id.message_video_view);
mFullscreenbutton = findViewById(R.id.vcv_img_fullscreen);
- fab = findViewById(R.id.fab);
- fab.setOnClickListener(v -> {
- PopupMenu popup = new PopupMenu(MediaViewerActivity.this, v);
- popup.inflate(R.menu.media_viewer);
- final Menu menu = popup.getMenu();
- MenuItem delete = menu.findItem(R.id.action_delete);
- MenuItem open = menu.findItem(R.id.action_open);
- Log.d(Config.LOGTAG, "Path = " + mFile.toString());
- if (mFile == null || !mFile.toString().startsWith("/") || mFile.toString().contains(FileBackend.getConversationsDirectory("null"))) {
- delete.setVisible(true);
- } else {
- delete.setVisible(false);
- }
- if (isVideo) {
- if (isDarkTheme()) {
- open.setIcon(R.drawable.ic_video_white_24dp);
- } else {
- open.setIcon(R.drawable.ic_video_black_24dp);
- }
- } else if (isImage) {
- if (isDarkTheme()) {
- open.setIcon(R.drawable.ic_image_white_24dp);
- } else {
- open.setIcon(R.drawable.ic_image_black_24dp);
- }
- }
- popup.setOnMenuItemClickListener(item -> {
- switch (item.getItemId()) {
- case R.id.action_share:
- share();
- break;
- case R.id.action_open:
- open();
- break;
- case R.id.action_delete:
+ binding.speedDial.inflate(R.menu.media_viewer);
+ binding.speedDial.setOnActionSelectedListener(actionItem -> {
+ switch (actionItem.getId()) {
+ case R.id.action_share:
+ share();
+ break;
+ case R.id.action_open:
+ open();
+ break;
+ /*
+ case R.id.action_delete:
+ if (mFile == null || !mFile.toString().startsWith("/") || mFile.toString().contains(FileBackend.getConversationsDirectory("null"))) {
deleteFile();
- break;
- default:
- return false;
- }
- return true;
- });
- MenuPopupHelper menuHelper = new MenuPopupHelper(MediaViewerActivity.this, (MenuBuilder) menu, v);
- menuHelper.setForceShowIcon(true);
- menuHelper.show();
+ }
+ break;
+ */
+ default:
+ return false;
+ }
+ return false;
});
}
@@ -262,11 +236,11 @@ public class MediaViewerActivity extends XmppActivity {
}
try {
if (gif) {
- mGIF.setVisibility(View.VISIBLE);
- mGIF.setImageURI(FileUri);
+ binding.messageGifView.setVisibility(View.VISIBLE);
+ binding.messageGifView.setImageURI(FileUri);
} else {
- mImage.setVisibility(View.VISIBLE);
- mImage.setImage(ImageSource.uri(FileUri));
+ binding.messageImageView.setVisibility(View.VISIBLE);
+ binding.messageImageView.setImage(ImageSource.uri(FileUri));
}
} catch (Exception e) {
Toast.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show();
@@ -296,10 +270,10 @@ public class MediaViewerActivity extends XmppActivity {
rotateScreen(width, height, rotation);
}
try {
- mVideo.setVisibility(View.VISIBLE);
- mVideo.setVideoURI(uri);
+ binding.messageVideoView.setVisibility(View.VISIBLE);
+ binding.messageVideoView.setVideoURI(uri);
mFullscreenbutton.setVisibility(View.INVISIBLE);
- mVideo.setShouldAutoplay(true);
+ binding.messageVideoView.setShouldAutoplay(true);
} catch (IOException e) {
Toast.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show();
@@ -348,13 +322,13 @@ public class MediaViewerActivity extends XmppActivity {
}
getWindow().setAttributes(layout);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- mVideo.setShouldAutoplay(true);
+ binding.messageVideoView.setShouldAutoplay(true);
super.onResume();
}
@Override
public void onPause() {
- mVideo.reset();
+ binding.messageVideoView.reset();
WindowManager.LayoutParams layout = getWindow().getAttributes();
if (useMaxBrightness()) {
layout.screenBrightness = -1;
@@ -367,7 +341,7 @@ public class MediaViewerActivity extends XmppActivity {
@Override
public void onStop() {
- mVideo.reset();
+ binding.messageVideoView.reset();
WindowManager.LayoutParams layout = getWindow().getAttributes();
if (useMaxBrightness()) {
layout.screenBrightness = -1;
diff --git a/src/main/res/drawable-hdpi/ic_open_in_new_white_24dp.png b/src/main/res/drawable-hdpi/ic_open_in_new_white_24dp.png
new file mode 100644
index 000000000..c48104c3f
--- /dev/null
+++ b/src/main/res/drawable-hdpi/ic_open_in_new_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-mdpi/ic_open_in_new_white_24dp.png b/src/main/res/drawable-mdpi/ic_open_in_new_white_24dp.png
new file mode 100644
index 000000000..56aa52136
--- /dev/null
+++ b/src/main/res/drawable-mdpi/ic_open_in_new_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xhdpi/ic_open_in_new_white_24dp.png b/src/main/res/drawable-xhdpi/ic_open_in_new_white_24dp.png
new file mode 100644
index 000000000..ae0d6fc21
--- /dev/null
+++ b/src/main/res/drawable-xhdpi/ic_open_in_new_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxhdpi/ic_open_in_new_white_24dp.png b/src/main/res/drawable-xxhdpi/ic_open_in_new_white_24dp.png
new file mode 100644
index 000000000..8236c23f1
--- /dev/null
+++ b/src/main/res/drawable-xxhdpi/ic_open_in_new_white_24dp.png
Binary files differ
diff --git a/src/main/res/drawable-xxxhdpi/ic_open_in_new_white_24dp.png b/src/main/res/drawable-xxxhdpi/ic_open_in_new_white_24dp.png
new file mode 100644
index 000000000..e27a66906
--- /dev/null
+++ b/src/main/res/drawable-xxxhdpi/ic_open_in_new_white_24dp.png
Binary files differ
diff --git a/src/main/res/layout/activity_media_viewer.xml b/src/main/res/layout/activity_media_viewer.xml
index 42db37b86..463145662 100644
--- a/src/main/res/layout/activity_media_viewer.xml
+++ b/src/main/res/layout/activity_media_viewer.xml
@@ -1,44 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@android:color/black"
- android:orientation="vertical">
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
- <FrameLayout
- android:id="@+id/frameLayout"
+ <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_alignParentTop="true"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true">
+ android:background="@android:color/black"
+ android:orientation="vertical">
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
- android:id="@id/message_image_view"
+ android:id="@+id/messageImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:visibility="gone" />
<pl.droidsonroids.gif.GifImageView
- android:id="@id/message_gif_view"
+ android:id="@+id/messageGifView"
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:id="@+id/messageVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
- <android.support.design.widget.FloatingActionButton
- android:id="@+id/fab"
+ <com.leinardi.android.speeddial.SpeedDialOverlayLayout
+ android:id="@+id/overlay"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_below="@id/tab_layout"
+ android:background="?color_background_overlay" />
+
+ <com.leinardi.android.speeddial.SpeedDialView
+ android:id="@+id/speed_dial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="right|top"
- android:layout_margin="16dp"
- android:src="@drawable/ic_menu_white_24dp" />
- </FrameLayout>
-</RelativeLayout> \ No newline at end of file
+ android:layout_alignParentEnd="true"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentBottom="true"
+ app:backgroundTint="?attr/colorAccent"
+ app:sdMainFabClosedBackgroundColor="?attr/colorAccent"
+ app:sdMainFabClosedSrc="@drawable/ic_menu_white_24dp"
+ app:sdMainFabOpenedBackgroundColor="?attr/colorAccent"
+ app:sdMainFabOpenedSrc="@drawable/ic_close_white_24dp"
+ app:sdOverlayLayout="@id/overlay" />
+ </RelativeLayout>
+</layout> \ No newline at end of file
diff --git a/src/main/res/menu/media_viewer.xml b/src/main/res/menu/media_viewer.xml
index c3898c79b..99a62a2a1 100644
--- a/src/main/res/menu/media_viewer.xml
+++ b/src/main/res/menu/media_viewer.xml
@@ -2,16 +2,17 @@
<item
android:id="@+id/action_share"
- android:icon="?attr/icon_share"
+ android:icon="@drawable/ic_share_white_24dp"
android:orderInCategory="10"
android:title="@string/share" />
<item
android:id="@+id/action_open"
+ android:icon="@drawable/ic_open_in_new_white_24dp"
android:orderInCategory="20"
android:title="@string/action_open" />
<item
android:id="@+id/action_delete"
- android:icon="?attr/icon_delete"
+ android:icon="@drawable/ic_delete_white_24dp"
android:orderInCategory="30"
android:title="@string/action_delete" />
</menu> \ No newline at end of file