From a623e6f70a25ef2f11f49ad7349ee4390bec8075 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 23 Jun 2018 19:00:23 +0200 Subject: [PATCH] change avatar size in details screens depedning on screen width --- .../conversations/ui/ConferenceDetailsActivity.java | 11 +++++++++-- .../conversations/ui/ContactDetailsActivity.java | 2 +- .../siacs/conversations/ui/EditAccountActivity.java | 2 +- .../ui/PublishProfilePictureActivity.java | 4 ++-- src/main/res/layout/activity_contact_details.xml | 4 ++-- src/main/res/layout/activity_edit_account.xml | 4 ++-- src/main/res/layout/activity_muc_details.xml | 4 ++-- src/main/res/values-v21/dimens.xml | 4 ---- src/main/res/values-w384dp/dimens.xml | 1 + src/main/res/values-w585dp/dimens.xml | 2 +- src/main/res/values/dimens.xml | 1 + 11 files changed, 22 insertions(+), 17 deletions(-) delete mode 100644 src/main/res/values-v21/dimens.xml diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 65bd4e3e8..74a765b9a 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -610,16 +610,20 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.editMucNameButton.setVisibility((self.getAffiliation().ranks(MucOptions.Affiliation.OWNER) || mucOptions.canChangeSubject()) ? View.VISIBLE : View.GONE); this.binding.detailsAccount.setText(getString(R.string.using_account, account)); this.binding.jid.setText(mConversation.getJid().asBareJid().toEscapedString()); - this.binding.yourPhoto.setImageBitmap(avatarService().get(mConversation, getPixel(72))); + this.binding.yourPhoto.setImageBitmap(avatarService().get(mConversation,(int) getResources().getDimension(R.dimen.avatar_on_details_screen_size))); String roomName = mucOptions.getName(); String subject = mucOptions.getSubject(); + final boolean hasTitle; if (printableValue(roomName)) { this.binding.mucTitle.setText(roomName); this.binding.mucTitle.setVisibility(View.VISIBLE); + hasTitle = true; } else if (!printableValue(subject)) { this.binding.mucTitle.setText(EmojiWrapper.transform(mConversation.getName())); + hasTitle = true; this.binding.mucTitle.setVisibility(View.VISIBLE); } else { + hasTitle = false; this.binding.mucTitle.setVisibility(View.GONE); } if (printableValue(subject)) { @@ -627,7 +631,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers StylingHelper.format(spannable, this.binding.mucSubject.getCurrentTextColor()); MyLinkify.addLinks(spannable, false); this.binding.mucSubject.setText(EmojiWrapper.transform(spannable)); - this.binding.mucSubject.setTextAppearance(this,subject.length() > 120 ? R.style.TextAppearance_Conversations_Body1_Linkified : R.style.TextAppearance_Conversations_Subhead); + this.binding.mucSubject.setTextAppearance(this,subject.length() > (hasTitle ? 128 : 196) ? R.style.TextAppearance_Conversations_Body1_Linkified : R.style.TextAppearance_Conversations_Subhead); this.binding.mucSubject.setAutoLinkMask(0); this.binding.mucSubject.setVisibility(View.VISIBLE); } else { @@ -816,6 +820,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers @Override public void afterTextChanged(Editable s) { + if (mConversation == null) { + return; + } final MucOptions mucOptions = mConversation.getMucOptions(); if (this.binding.mucEditor.getVisibility() == View.VISIBLE) { boolean subjectChanged = changed(binding.mucEditSubject.getEditableText().toString(), mucOptions.getSubject()); diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 3c08d8234..bc40dfe36 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -374,7 +374,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp account = contact.getAccount().getJid().asBareJid().toString(); } binding.detailsAccount.setText(getString(R.string.using_account, account)); - binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, getPixel(72))); + binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, (int) getResources().getDimension(R.dimen.avatar_on_details_screen_size))); binding.detailsContactBadge.setOnClickListener(this.onBadgeClick); binding.detailsContactKeys.removeAllViews(); diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 858dc513f..a141ac9ff 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -952,7 +952,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (!mInitMode) { this.mAvatar.setVisibility(View.VISIBLE); - this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, getPixel(72))); + this.mAvatar.setImageBitmap(avatarService().get(this.mAccount, (int) getResources().getDimension(R.dimen.avatar_on_details_screen_size))); } else { this.mAvatar.setVisibility(View.GONE); } diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index 50b76c3b2..9df669923 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -170,10 +170,10 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC Bitmap bm = null; if (uri == null) { - bm = avatarService().get(account, getPixel(192)); + bm = avatarService().get(account, (int) getResources().getDimension(R.dimen.publish_avatar_size)); } else { try { - bm = xmppConnectionService.getFileBackend().cropCenterSquare(uri, getPixel(192)); + bm = xmppConnectionService.getFileBackend().cropCenterSquare(uri, (int) getResources().getDimension(R.dimen.publish_avatar_size)); } catch (Exception e) { Log.d(Config.LOGTAG, "unable to load bitmap into image view", e); } diff --git a/src/main/res/layout/activity_contact_details.xml b/src/main/res/layout/activity_contact_details.xml index c08f5fdb2..b93a8afac 100644 --- a/src/main/res/layout/activity_contact_details.xml +++ b/src/main/res/layout/activity_contact_details.xml @@ -37,8 +37,8 @@ diff --git a/src/main/res/layout/activity_edit_account.xml b/src/main/res/layout/activity_edit_account.xml index 2467705a3..8762b8360 100644 --- a/src/main/res/layout/activity_edit_account.xml +++ b/src/main/res/layout/activity_edit_account.xml @@ -40,8 +40,8 @@ diff --git a/src/main/res/values-v21/dimens.xml b/src/main/res/values-v21/dimens.xml deleted file mode 100644 index 8bc8f3f7b..000000000 --- a/src/main/res/values-v21/dimens.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - 63dp - \ No newline at end of file diff --git a/src/main/res/values-w384dp/dimens.xml b/src/main/res/values-w384dp/dimens.xml index 006fb2f33..86df5d1ea 100644 --- a/src/main/res/values-w384dp/dimens.xml +++ b/src/main/res/values-w384dp/dimens.xml @@ -4,4 +4,5 @@ 12sp 48dp 288dp + 72dp diff --git a/src/main/res/values-w585dp/dimens.xml b/src/main/res/values-w585dp/dimens.xml index be1f92391..11ed983bc 100644 --- a/src/main/res/values-w585dp/dimens.xml +++ b/src/main/res/values-w585dp/dimens.xml @@ -1,4 +1,4 @@ 32dp - 72dp + 96dp diff --git a/src/main/res/values/dimens.xml b/src/main/res/values/dimens.xml index 583b2b676..b71d67ce3 100644 --- a/src/main/res/values/dimens.xml +++ b/src/main/res/values/dimens.xml @@ -15,6 +15,7 @@ 8dp 96dp + 56dp 4dp 4dp