diff options
Diffstat (limited to 'src/main/java/de')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java | 28 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java | 100 |
2 files changed, 91 insertions, 37 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 580a61686..01fdb7c0e 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -3,6 +3,8 @@ package de.pixart.messenger.ui; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.graphics.Color; +import android.graphics.Point; import android.graphics.PorterDuff; import android.os.Bundle; import android.text.Editable; @@ -13,6 +15,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.widget.ImageView; import android.widget.Toast; import androidx.appcompat.app.AlertDialog; @@ -234,6 +237,18 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers intent.putExtra("uuid", mConversation.getUuid()); startActivity(intent); }); + this.binding.detailsMucAvatar.setOnLongClickListener(v -> { + 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); + AvatarWorkerTask.loadAvatar(mConversation, view, R.dimen.avatar_big); + AlertDialog.Builder builder = new AlertDialog.Builder(ConferenceDetailsActivity.this); + builder.setView(view); + builder.create().show(); + return true; + }); this.mAdvancedMode = getPreferences().getBoolean("advanced_muc_mode", false); this.binding.mucInfoMore.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE); this.binding.notificationStatusButton.setOnClickListener(this.mNotifyStatusClickListener); @@ -277,6 +292,17 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers binding.mediaWrapper.setVisibility(Compatibility.hasStoragePermission(this) ? View.VISIBLE : View.GONE); } + private boolean canChangeMUCAvatar() { + final MucOptions mucOptions = mConversation.getMucOptions(); + if (!mucOptions.hasVCards()) { + return false; + } else if (!mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { + return false; + } else { + return true; + } + } + @Override public boolean onOptionsItemSelected(MenuItem menuItem) { if (MenuDoubleTabUtil.shouldIgnoreTap()) { @@ -491,7 +517,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.detailsAccount.setVisibility(View.GONE); } //todo add edit overlay to avatar and change layout - AvatarWorkerTask.loadAvatar(mConversation, binding.detailsMucAvatar, R.dimen.avatar_big); + AvatarWorkerTask.loadAvatar(mConversation, binding.detailsMucAvatar, R.dimen.avatar_on_details_screen_size, canChangeMUCAvatar()); AvatarWorkerTask.loadAvatar(mConversation.getAccount(), binding.yourPhoto, R.dimen.avatar_on_details_screen_size); String roomName = mucOptions.getName(); diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index 295153dc3..e7ff8996b 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.graphics.Color; import android.graphics.PorterDuff; import android.net.Uri; import android.os.Bundle; @@ -23,6 +24,7 @@ import android.view.View.OnClickListener; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; @@ -81,6 +83,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp private Conversation mConversation; ActivityContactDetailsBinding binding; private MediaAdapter mMediaAdapter; + private boolean mAdvancedMode = false; private DialogInterface.OnClickListener removeFromRoster = new DialogInterface.OnClickListener() { @Override @@ -270,7 +273,6 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } } this.messageFingerprint = getIntent().getStringExtra("fingerprint"); - this.binding = DataBindingUtil.setContentView(this, R.layout.activity_contact_details); setSupportActionBar((Toolbar) binding.toolbar); configureActionBar(getSupportActionBar()); @@ -326,43 +328,60 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp case R.id.action_share_uri: shareLink(false); break; - case R.id.action_edit_contact: - Uri systemAccount = contact.getSystemAccount(); - if (systemAccount == null) { - quickEdit(contact.getServerName(), R.string.contact_name, value -> { - contact.setServerName(value); - ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact); - populateView(); - return null; - }, true); - } else { - Intent intent = new Intent(Intent.ACTION_EDIT); - intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE); - intent.putExtra("finishActivityOnSaveCompleted", true); - try { - startActivity(intent); - overridePendingTransition(R.animator.fade_in, R.animator.fade_out); - } catch (ActivityNotFoundException e) { - Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show(); - } - } - break; case R.id.action_block: BlockContactDialog.show(this, contact); break; case R.id.action_unblock: BlockContactDialog.show(this, contact); break; + case R.id.action_advanced_mode: + this.mAdvancedMode = !menuItem.isChecked(); + menuItem.setChecked(this.mAdvancedMode); + getPreferences().edit().putBoolean("advanced_mode", mAdvancedMode).apply(); + invalidateOptionsMenu(); + refreshUi(); + break; } return super.onOptionsItemSelected(menuItem); } + private void editContact() { + Uri systemAccount = contact.getSystemAccount(); + if (systemAccount == null) { + quickEdit(contact.getServerName(), R.string.contact_name, value -> { + contact.setServerName(value); + ContactDetailsActivity.this.xmppConnectionService.pushContactToServer(contact); + populateView(); + return null; + }, true); + } else { + Intent intent = new Intent(Intent.ACTION_EDIT); + intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE); + intent.putExtra("finishActivityOnSaveCompleted", true); + try { + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } catch (ActivityNotFoundException e) { + Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show(); + } + } + } + + @Override + public boolean onPrepareOptionsMenu(Menu menu) { + MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode); + menuItemAdvancedMode.setChecked(mAdvancedMode); + if (mConversation == null) { + return true; + } + return true; + } + @Override public boolean onCreateOptionsMenu(final Menu menu) { getMenuInflater().inflate(R.menu.contact_details, menu); MenuItem block = menu.findItem(R.id.action_block); MenuItem unblock = menu.findItem(R.id.action_unblock); - MenuItem edit = menu.findItem(R.id.action_edit_contact); if (contact == null) { return true; } @@ -377,9 +396,6 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp unblock.setVisible(false); block.setVisible(false); } - if (!contact.showInRoster()) { - edit.setVisible(false); - } return super.onCreateOptionsMenu(menu); } @@ -408,7 +424,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp ab.setDisplayShowCustomEnabled(true); TextView abtitle = findViewById(android.R.id.text1); TextView absubtitle = findViewById(android.R.id.text2); - abtitle.setText(EmojiWrapper.transform(contact.getDisplayName())); + abtitle.setText(R.string.contact_details); abtitle.setSelected(true); abtitle.setClickable(false); absubtitle.setVisibility(View.GONE); @@ -418,11 +434,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp invalidateOptionsMenu(); setTitle(contact.getDisplayName()); - if (contact.getServer().toString().toLowerCase().equals(accountJid.getDomain().toLowerCase())) { - binding.contactDisplayName.setText(contact.getDisplayName()); - } else { - binding.contactDisplayName.setText(contact.getJid().toString()); - } + binding.contactDisplayName.setText(contact.getDisplayName()); + this.binding.jid.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE); if (contact.showInRoster()) { binding.detailsSendPresence.setVisibility(View.VISIBLE); binding.detailsReceivePresence.setVisibility(View.VISIBLE); @@ -431,7 +444,10 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.addContactButton.getBackground().setColorFilter(getWarningButtonColor(), PorterDuff.Mode.MULTIPLY); binding.detailsSendPresence.setOnCheckedChangeListener(null); binding.detailsReceivePresence.setOnCheckedChangeListener(null); - + binding.editContactNameButton.setVisibility(View.VISIBLE); + binding.editContactNameButton.setOnClickListener(view -> { + editContact(); + }); binding.addContactButton.setOnClickListener(view -> { final AlertDialog.Builder deleteFromRosterDialog = new AlertDialog.Builder(ContactDetailsActivity.this); deleteFromRosterDialog.setNegativeButton(getString(R.string.cancel), null) @@ -509,6 +525,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp binding.detailsSendPresence.setOnCheckedChangeListener(this.mOnSendCheckedChange); binding.detailsReceivePresence.setOnCheckedChangeListener(this.mOnReceiveCheckedChange); } else { + binding.editContactNameButton.setVisibility(View.GONE); binding.addContactButton.setVisibility(View.VISIBLE); binding.addContactButton.setText(getString(R.string.add_contact)); binding.addContactButton.getBackground().clearColorFilter(); @@ -537,7 +554,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp } } - binding.detailsContactjid.setText(IrregularUnicodeDetector.style(this, contact.getJid())); + binding.jid.setText(IrregularUnicodeDetector.style(this, contact.getJid())); String account; if (Config.DOMAIN_LOCK != null) { account = contact.getAccount().getJid().getLocal(); @@ -545,9 +562,20 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp account = contact.getAccount().getJid().asBareJid().toString(); } binding.detailsAccount.setText(getString(R.string.using_account, account)); - AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_big); + 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); + view.setAdjustViewBounds(true); + view.setMaxHeight(R.dimen.avatar_big); + view.setMaxWidth(R.dimen.avatar_big); + view.setBackgroundColor(Color.WHITE); + AvatarWorkerTask.loadAvatar(mConversation, view, R.dimen.avatar_big); + AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this); + builder.setView(view); + builder.create().show(); + return true; + }); if (xmppConnectionService.multipleAccounts()) { binding.detailsAccount.setVisibility(View.VISIBLE); } else { |