diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-06-29 23:43:32 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-06-29 23:46:49 +0200 |
commit | 45f773d5bd488a9851dc1255b24ff451cee92db9 (patch) | |
tree | b32f8114ca02e0018093793d1b2f42b90ae489c1 /src | |
parent | c2a5f95da78918032a4cd71aac53d0c14f69fbef (diff) |
scale text size if topic is long
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java | 16 | ||||
-rw-r--r-- | src/main/res/values/styles.xml | 4 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 09f3d8467..8e8178609 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -51,7 +51,9 @@ import de.pixart.messenger.services.XmppConnectionService.OnConversationUpdate; import de.pixart.messenger.services.XmppConnectionService.OnMucRosterUpdate; import de.pixart.messenger.ui.util.MyLinkify; import de.pixart.messenger.ui.util.SoftKeyboardUtils; +import de.pixart.messenger.utils.EmojiWrapper; import de.pixart.messenger.utils.MenuDoubleTabUtil; +import de.pixart.messenger.utils.StylingHelper; import de.pixart.messenger.utils.TimeframeUtils; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; @@ -313,6 +315,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.editMucNameButton.setOnClickListener(this::onMucEditButtonClicked); this.binding.mucEditTitle.addTextChangedListener(this); this.binding.mucEditSubject.addTextChangedListener(this); + this.binding.mucEditSubject.addTextChangedListener(new StylingHelper.MessageEditorStyler(this.binding.mucEditSubject)); } @Override @@ -661,19 +664,25 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.binding.yourPhoto.setImageBitmap(avatarService().get(mConversation.getAccount(), getPixel(48))); 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(mConversation.getName()); + 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)) { SpannableStringBuilder spannable = new SpannableStringBuilder(subject); + StylingHelper.format(spannable, this.binding.mucSubject.getCurrentTextColor()); MyLinkify.addLinks(spannable, false); - this.binding.mucSubject.setText(spannable); + this.binding.mucSubject.setText(EmojiWrapper.transform(spannable)); + 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 { @@ -909,6 +918,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/res/values/styles.xml b/src/main/res/values/styles.xml index 6346dfcc0..3f693fccc 100644 --- a/src/main/res/values/styles.xml +++ b/src/main/res/values/styles.xml @@ -23,6 +23,10 @@ <item name="android:textColorLink">?android:textColorPrimary</item> </style> + <style name="TextAppearance.Conversations.Body1.Linkified" parent="TextAppearance.AppCompat.Body1"> + <item name="android:textSize">?TextSizeBody1</item> + </style> + <style name="TextAppearance.Conversations.Caption" parent="TextAppearance.AppCompat.Caption"> <item name="android:textSize">?TextSizeCaption</item> </style> |