aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/ui
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-09-26 20:33:09 +0200
committerChristian Schneppe <christian@pix-art.de>2018-09-26 20:33:09 +0200
commitced4191f362b789fd7a85710238b6f6c8e2ff776 (patch)
treefa54f7d2ac6fb15a78c456b23b45d48cf9f29c54 /src/main/java/de/pixart/messenger/ui
parentb2a122ec71c8c2af58ea6d99806d07d76efcb0f4 (diff)
introduce media browser activity
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java1
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java1
-rw-r--r--src/main/java/de/pixart/messenger/ui/MediaBrowserActivity.java77
3 files changed, 79 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index fd7c66c18..72168ab89 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -523,6 +523,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (this.mConversation != null) {
final int limit = GridManager.getCurrentColumnCount(this.binding.media);
xmppConnectionService.getAttachments(this.mConversation, limit, this);
+ this.binding.showMedia.setOnClickListener((v) -> MediaBrowserActivity.launch(this, mConversation));
updateView();
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index d488419d2..4e1e414fa 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
@@ -669,6 +669,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
final int limit = GridManager.getCurrentColumnCount(this.binding.media);
xmppConnectionService.getAttachments(account, contact.getJid().asBareJid(), limit, this);
+ this.binding.showMedia.setOnClickListener((v) -> MediaBrowserActivity.launch(this, contact));
populateView();
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/MediaBrowserActivity.java b/src/main/java/de/pixart/messenger/ui/MediaBrowserActivity.java
new file mode 100644
index 000000000..4b32b42ab
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/ui/MediaBrowserActivity.java
@@ -0,0 +1,77 @@
+package de.pixart.messenger.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.databinding.DataBindingUtil;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+
+import java.util.List;
+
+import de.pixart.messenger.R;
+import de.pixart.messenger.databinding.ActivityMediaBrowserBinding;
+import de.pixart.messenger.entities.Account;
+import de.pixart.messenger.entities.Contact;
+import de.pixart.messenger.entities.Conversation;
+import de.pixart.messenger.ui.adapter.MediaAdapter;
+import de.pixart.messenger.ui.interfaces.OnMediaLoaded;
+import de.pixart.messenger.ui.util.Attachment;
+import de.pixart.messenger.ui.util.GridManager;
+import rocks.xmpp.addr.Jid;
+
+
+public class MediaBrowserActivity extends XmppActivity implements OnMediaLoaded {
+
+ private ActivityMediaBrowserBinding binding;
+
+ private MediaAdapter mMediaAdapter;
+
+ public static void launch(Context context, Contact contact) {
+ launch(context, contact.getAccount(), contact.getJid().asBareJid().toEscapedString());
+ }
+
+ public static void launch(Context context, Conversation conversation) {
+ launch(context, conversation.getAccount(), conversation.getJid().asBareJid().toEscapedString());
+ }
+
+ private static void launch(Context context, Account account, String jid) {
+ final Intent intent = new Intent(context, MediaBrowserActivity.class);
+ intent.putExtra("account", account.getUuid());
+ intent.putExtra("jid", jid);
+ context.startActivity(intent);
+ }
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.binding = DataBindingUtil.setContentView(this, R.layout.activity_media_browser);
+ setSupportActionBar((Toolbar) binding.toolbar);
+ configureActionBar(getSupportActionBar());
+ mMediaAdapter = new MediaAdapter(this, R.dimen.media_size);
+ this.binding.media.setAdapter(mMediaAdapter);
+ GridManager.setupLayoutManager(this, this.binding.media, R.dimen.browser_media_size);
+
+ }
+
+ @Override
+ protected void refreshUiReal() {
+
+ }
+
+ @Override
+ void onBackendConnected() {
+ Intent intent = getIntent();
+ String account = intent == null ? null : intent.getStringExtra("account");
+ String jid = intent == null ? null : intent.getStringExtra("jid");
+ if (account != null && jid != null) {
+ xmppConnectionService.getAttachments(account, Jid.of(jid), 0, this);
+ }
+ }
+
+ @Override
+ public void onMediaLoaded(List<Attachment> attachments) {
+ runOnUiThread(() -> {
+ mMediaAdapter.setAttachments(attachments);
+ });
+ }
+} \ No newline at end of file