add 'show avatar' to context menu in chat view
to show a bigger avatar
This commit is contained in:
parent
21ddcc478f
commit
3f12418b60
7 changed files with 46 additions and 5 deletions
|
@ -237,14 +237,14 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
|
|||
startActivity(intent);
|
||||
});
|
||||
this.binding.detailsMucAvatar.setOnLongClickListener(v -> {
|
||||
ImageView view = new ImageView(ConferenceDetailsActivity.this);
|
||||
final ImageView view = new ImageView(ConferenceDetailsActivity.this);
|
||||
view.setAdjustViewBounds(true);
|
||||
view.setMaxHeight(R.dimen.avatar_big);
|
||||
view.setMaxWidth(R.dimen.avatar_big);
|
||||
view.setBackgroundColor(Color.WHITE);
|
||||
view.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
AvatarWorkerTask.loadAvatar(mConversation, view, R.dimen.avatar_big);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this);
|
||||
builder.setView(view);
|
||||
builder.create().show();
|
||||
return true;
|
||||
|
|
|
@ -557,14 +557,14 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
|
|||
AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size);
|
||||
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
|
||||
binding.detailsContactBadge.setOnLongClickListener(v -> {
|
||||
ImageView view = new ImageView(ContactDetailsActivity.this);
|
||||
final ImageView view = new ImageView(ContactDetailsActivity.this);
|
||||
view.setAdjustViewBounds(true);
|
||||
view.setMaxHeight(R.dimen.avatar_big);
|
||||
view.setMaxWidth(R.dimen.avatar_big);
|
||||
view.setBackgroundColor(Color.WHITE);
|
||||
view.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
AvatarWorkerTask.loadAvatar(mConversation, view, R.dimen.avatar_big);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this);
|
||||
builder.setView(view);
|
||||
builder.create().show();
|
||||
return true;
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.content.Intent;
|
|||
import android.content.IntentSender.SendIntentException;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
@ -46,6 +47,7 @@ import android.widget.AbsListView.OnScrollListener;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.AdapterContextMenuInfo;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
@ -101,6 +103,7 @@ import de.pixart.messenger.ui.adapter.MediaPreviewAdapter;
|
|||
import de.pixart.messenger.ui.adapter.MessageAdapter;
|
||||
import de.pixart.messenger.ui.util.ActivityResult;
|
||||
import de.pixart.messenger.ui.util.Attachment;
|
||||
import de.pixart.messenger.ui.util.AvatarWorkerTask;
|
||||
import de.pixart.messenger.ui.util.ConversationMenuConfigurator;
|
||||
import de.pixart.messenger.ui.util.DateSeparator;
|
||||
import de.pixart.messenger.ui.util.EditMessageActionModeCallback;
|
||||
|
@ -3141,6 +3144,18 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
popupMenu.inflate(R.menu.one_on_one_context);
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_avatar:
|
||||
final ImageView view = new ImageView(activity);
|
||||
view.setAdjustViewBounds(true);
|
||||
view.setMaxHeight(R.dimen.avatar_big);
|
||||
view.setMaxWidth(R.dimen.avatar_big);
|
||||
view.setBackgroundColor(Color.WHITE);
|
||||
view.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
AvatarWorkerTask.loadAvatar(contact, view, R.dimen.avatar_big);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(view);
|
||||
builder.create().show();
|
||||
break;
|
||||
case R.id.action_contact_details:
|
||||
activity.switchToContactDetails(message.getContact(), fingerprint);
|
||||
break;
|
||||
|
@ -3156,6 +3171,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
final Menu menu = popupMenu.getMenu();
|
||||
popupMenu.setOnMenuItemClickListener(item -> {
|
||||
switch (item.getItemId()) {
|
||||
|
||||
|
||||
case R.id.action_show_qr_code:
|
||||
activity.showQrCode(conversation.getAccount().getShareableUri());
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.pixart.messenger.ui.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.SpannableString;
|
||||
|
@ -14,6 +15,7 @@ import android.view.ContextMenu;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
|
@ -66,6 +68,8 @@ public final class MucDetailsContextMenuHelper {
|
|||
final MucOptions mucOptions = conversation.getMucOptions();
|
||||
final boolean isGroupChat = mucOptions.isPrivateAndNonAnonymous();
|
||||
MenuItem title = menu.findItem(R.id.title);
|
||||
MenuItem showAvatar = menu.findItem(R.id.action_show_avatar);
|
||||
showAvatar.setVisible(user != null);
|
||||
if (forceContextMenu && username != null) {
|
||||
SpannableStringBuilder menuTitle = new SpannableStringBuilder(username);
|
||||
menuTitle.setSpan(new ForegroundColorSpan(titleColor), 0, menuTitle.length(), 0);
|
||||
|
@ -102,7 +106,6 @@ public final class MucDetailsContextMenuHelper {
|
|||
final User self = conversation.getMucOptions().getSelf();
|
||||
addToRoster.setVisible(contact != null && !contact.showInRoster());
|
||||
showContactDetails.setVisible(contact == null || !contact.isSelf());
|
||||
|
||||
if ((activity instanceof ConferenceDetailsActivity || activity instanceof MucUsersActivity) && user.getRole() == MucOptions.Role.NONE) {
|
||||
invite.setVisible(true);
|
||||
}
|
||||
|
@ -173,6 +176,18 @@ public final class MucDetailsContextMenuHelper {
|
|||
final Account account = conversation.getAccount();
|
||||
final Contact contact = jid == null ? null : account.getRoster().getContact(jid);
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_show_avatar:
|
||||
final ImageView view = new ImageView(activity);
|
||||
view.setAdjustViewBounds(true);
|
||||
view.setMaxHeight(R.dimen.avatar_big);
|
||||
view.setMaxWidth(R.dimen.avatar_big);
|
||||
view.setBackgroundColor(Color.WHITE);
|
||||
view.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
AvatarWorkerTask.loadAvatar(user, view, R.dimen.avatar_big);
|
||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setView(view);
|
||||
builder.create().show();
|
||||
return true;
|
||||
case R.id.action_contact_details:
|
||||
if (contact != null) {
|
||||
activity.switchToContactDetails(contact, fingerprint);
|
||||
|
|
|
@ -6,6 +6,11 @@
|
|||
android:enabled="false"
|
||||
android:orderInCategory="1"
|
||||
android:visible="false" />
|
||||
<item
|
||||
android:id="@+id/action_show_avatar"
|
||||
android:orderInCategory="99"
|
||||
android:title="@string/show_avatar"
|
||||
android:visible="false" />
|
||||
<item
|
||||
android:id="@+id/highlight_in_muc"
|
||||
android:orderInCategory="100"
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_show_avatar"
|
||||
android:title="@string/show_avatar" />
|
||||
<item
|
||||
android:id="@+id/action_contact_details"
|
||||
android:title="@string/action_contact_details" />
|
||||
|
|
|
@ -1003,4 +1003,5 @@
|
|||
<string name="pref_use_colored_muc_names_summary">Colorize nicknames in group chats or channels like default avatar backgrounds.</string>
|
||||
<string name="pref_use_colored_muc_names">Colorize nicknames</string>
|
||||
<string name="show_videos_images_only">Only images/videos</string>
|
||||
<string name="show_avatar">Show avatar</string>
|
||||
</resources>
|
||||
|
|
Reference in a new issue