render contact’s avatar during incoming call

This commit is contained in:
Daniel Gultsch 2020-04-20 13:41:50 +02:00
parent 187dff3df9
commit 23d1ee5e41
8 changed files with 53 additions and 6 deletions

View File

@ -207,7 +207,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
});
binding.addContactButton.setOnClickListener(v -> showAddToRosterDialog(contact));
mMediaAdapter = new MediaAdapter(this,R.dimen.media_size);
mMediaAdapter = new MediaAdapter(this, R.dimen.media_size);
this.binding.media.setAdapter(mMediaAdapter);
GridManager.setupLayoutManager(this, this.binding.media, R.dimen.media_size);
}
@ -416,7 +416,7 @@ 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_on_details_screen_size);
AvatarWorkerTask.loadAvatar(contact, binding.detailsContactBadge, R.dimen.avatar_on_details_screen_size);
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
binding.detailsContactKeys.removeAllViews();
@ -426,7 +426,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (Config.supportOmemo() && axolotlService != null) {
final Collection<XmppAxolotlSession> sessions = axolotlService.findSessionsForContact(contact);
boolean anyActive = false;
for(XmppAxolotlSession session : sessions) {
for (XmppAxolotlSession session : sessions) {
anyActive = session.getTrust().isActive();
if (anyActive) {
break;
@ -434,7 +434,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
boolean skippedInactive = false;
boolean showsInactive = false;
for (final XmppAxolotlSession session :sessions) {
for (final XmppAxolotlSession session : sessions) {
final FingerprintStatus trust = session.getTrust();
hasKeys |= !trust.isCompromised();
if (!trust.isActive() && anyActive) {
@ -537,7 +537,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
public void onMediaLoaded(List<Attachment> attachments) {
runOnUiThread(() -> {
int limit = GridManager.getCurrentColumnCount(binding.media);
mMediaAdapter.setAttachments(attachments.subList(0, Math.min(limit,attachments.size())));
mMediaAdapter.setAttachments(attachments.subList(0, Math.min(limit, attachments.size())));
binding.mediaWrapper.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
});

View File

@ -37,6 +37,7 @@ import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.utils.PermissionUtils;
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
@ -248,6 +249,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
RtpEndUserState state = RtpEndUserState.valueOf(extraLastState);
updateButtonConfiguration(state);
updateStateDisplay(state);
updateProfilePicture(state);
}
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
}
@ -361,6 +363,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
updateVideoViews(currentState);
updateStateDisplay(currentState);
updateButtonConfiguration(currentState);
updateProfilePicture(currentState);
}
private void reInitializeActivityWithRunningRapSession(final Account account, Jid with, String sessionId) {
@ -427,6 +430,20 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
}
}
private void updateProfilePicture(final RtpEndUserState state) {
if (state == RtpEndUserState.INCOMING_CALL || state == RtpEndUserState.ACCEPTING_CALL) {
final boolean show = getResources().getBoolean(R.bool.show_avatar_incoming_call);
if (show) {
binding.contactPhoto.setVisibility(View.VISIBLE);
AvatarWorkerTask.loadAvatar(getWith(), binding.contactPhoto, R.dimen.publish_avatar_size);
} else {
binding.contactPhoto.setVisibility(View.GONE);
}
} else {
binding.contactPhoto.setVisibility(View.GONE);
}
}
private Set<Media> getMedia() {
return requireRtpConnection().getMedia();
}
@ -720,6 +737,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
updateStateDisplay(state);
updateButtonConfiguration(state);
updateVideoViews(state);
updateProfilePicture(state);
});
} else {
Log.d(Config.LOGTAG, "received update for other rtp session");
@ -762,6 +780,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
runOnUiThread(() -> {
updateStateDisplay(state);
updateButtonConfiguration(state);
updateProfilePicture(state);
});
resetIntent(account, with, state, actionToMedia(currentIntent.getAction()));
}

View File

@ -62,6 +62,22 @@
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button_row"
android:layout_below="@id/app_bar_layout"
android:gravity="center"
android:orientation="horizontal">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/contact_photo"
android:layout_width="@dimen/publish_avatar_size"
android:layout_height="@dimen/publish_avatar_size"
app:riv_corner_radius="@dimen/incoming_call_radius" />
</LinearLayout>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video"
@ -93,13 +109,14 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:alpha="0.7"
android:layout_margin="8dp"
android:alpha="0.7"
android:src="@drawable/ic_mic_off_black_24dp"
android:tint="@color/white"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/button_row"
android:layout_width="288dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"

View File

@ -1,4 +1,5 @@
<resources>
<dimen name="publish_avatar_top_margin">16dp</dimen>
<dimen name="publish_avatar_size">128dp</dimen>
<dimen name="incoming_call_radius">64dp</dimen>
</resources>

View File

@ -1,4 +1,5 @@
<resources>
<dimen name="publish_avatar_top_margin">24dp</dimen>
<dimen name="publish_avatar_size">192dp</dimen>
<dimen name="incoming_call_radius">96dp</dimen>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="show_avatar_incoming_call">false</bool>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="show_avatar_incoming_call">true</bool>
</resources>

View File

@ -19,6 +19,7 @@
<dimen name="publish_avatar_top_margin">8dp</dimen>
<dimen name="publish_avatar_size">96dp</dimen>
<dimen name="incoming_call_radius">48dp</dimen>
<dimen name="avatar_on_status_message">32dp</dimen>
<dimen name="avatar">48dp</dimen>
<dimen name="avatar_on_details_screen_size">56dp</dimen>