change avatar size in details screens depedning on screen width

This commit is contained in:
Daniel Gultsch 2018-06-23 19:00:23 +02:00
parent a934054038
commit a623e6f70a
11 changed files with 22 additions and 17 deletions

View File

@ -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());

View File

@ -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();

View File

@ -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);
}

View File

@ -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);
}

View File

@ -37,8 +37,8 @@
<QuickContactBadge
android:id="@+id/details_contact_badge"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_width="@dimen/avatar_on_details_screen_size"
android:layout_height="@dimen/avatar_on_details_screen_size"
android:layout_alignParentTop="true"
android:scaleType="centerCrop"/>

View File

@ -40,8 +40,8 @@
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/avater"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_width="@dimen/avatar_on_details_screen_size"
android:layout_height="@dimen/avatar_on_details_screen_size"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/avatar_item_distance"
android:contentDescription="@string/account_image_description"

View File

@ -43,8 +43,8 @@
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/your_photo"
android:layout_width="72dp"
android:layout_height="72dp"
android:layout_width="@dimen/avatar_on_details_screen_size"
android:layout_height="@dimen/avatar_on_details_screen_size"
android:layout_alignParentStart="true"
app:riv_corner_radius="2dp"
android:layout_marginEnd="@dimen/avatar_item_distance"/>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="elv_undo_bottom_offset">63dp</dimen> <!-- 48dp + 15dp -->
</resources>

View File

@ -4,4 +4,5 @@
<dimen name="fineprint_size">12sp</dimen>
<dimen name="swipe_handle_size">48dp</dimen>
<dimen name="audio_player_width">288dp</dimen>
<dimen name="avatar_on_details_screen_size">72dp</dimen>
</resources>

View File

@ -1,4 +1,4 @@
<resources>
<dimen name="activity_horizontal_margin">32dp</dimen>
<dimen name="swipe_handle_size">72dp</dimen>
<dimen name="avatar_on_details_screen_size">96dp</dimen>
</resources>

View File

@ -15,6 +15,7 @@
<dimen name="publish_avatar_top_margin">8dp</dimen>
<dimen name="publish_avatar_size">96dp</dimen>
<dimen name="avatar_on_details_screen_size">56dp</dimen>
<dimen name="input_label_vertical_spacing">4dp</dimen>
<dimen name="input_label_horizontal_spacing">4dp</dimen>