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)); 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); this.binding.media.setAdapter(mMediaAdapter);
GridManager.setupLayoutManager(this, this.binding.media, R.dimen.media_size); 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(); account = contact.getAccount().getJid().asBareJid().toString();
} }
binding.detailsAccount.setText(getString(R.string.using_account, account)); 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.detailsContactBadge.setOnClickListener(this.onBadgeClick);
binding.detailsContactKeys.removeAllViews(); binding.detailsContactKeys.removeAllViews();
@ -426,7 +426,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
if (Config.supportOmemo() && axolotlService != null) { if (Config.supportOmemo() && axolotlService != null) {
final Collection<XmppAxolotlSession> sessions = axolotlService.findSessionsForContact(contact); final Collection<XmppAxolotlSession> sessions = axolotlService.findSessionsForContact(contact);
boolean anyActive = false; boolean anyActive = false;
for(XmppAxolotlSession session : sessions) { for (XmppAxolotlSession session : sessions) {
anyActive = session.getTrust().isActive(); anyActive = session.getTrust().isActive();
if (anyActive) { if (anyActive) {
break; break;
@ -434,7 +434,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
} }
boolean skippedInactive = false; boolean skippedInactive = false;
boolean showsInactive = false; boolean showsInactive = false;
for (final XmppAxolotlSession session :sessions) { for (final XmppAxolotlSession session : sessions) {
final FingerprintStatus trust = session.getTrust(); final FingerprintStatus trust = session.getTrust();
hasKeys |= !trust.isCompromised(); hasKeys |= !trust.isCompromised();
if (!trust.isActive() && anyActive) { if (!trust.isActive() && anyActive) {
@ -537,7 +537,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
public void onMediaLoaded(List<Attachment> attachments) { public void onMediaLoaded(List<Attachment> attachments) {
runOnUiThread(() -> { runOnUiThread(() -> {
int limit = GridManager.getCurrentColumnCount(binding.media); 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); 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.entities.Contact;
import eu.siacs.conversations.services.AppRTCAudioManager; import eu.siacs.conversations.services.AppRTCAudioManager;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
import eu.siacs.conversations.utils.PermissionUtils; import eu.siacs.conversations.utils.PermissionUtils;
import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection; import eu.siacs.conversations.xmpp.jingle.AbstractJingleConnection;
import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection; import eu.siacs.conversations.xmpp.jingle.JingleRtpConnection;
@ -248,6 +249,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
RtpEndUserState state = RtpEndUserState.valueOf(extraLastState); RtpEndUserState state = RtpEndUserState.valueOf(extraLastState);
updateButtonConfiguration(state); updateButtonConfiguration(state);
updateStateDisplay(state); updateStateDisplay(state);
updateProfilePicture(state);
} }
binding.with.setText(account.getRoster().getContact(with).getDisplayName()); binding.with.setText(account.getRoster().getContact(with).getDisplayName());
} }
@ -361,6 +363,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
updateVideoViews(currentState); updateVideoViews(currentState);
updateStateDisplay(currentState); updateStateDisplay(currentState);
updateButtonConfiguration(currentState); updateButtonConfiguration(currentState);
updateProfilePicture(currentState);
} }
private void reInitializeActivityWithRunningRapSession(final Account account, Jid with, String sessionId) { 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() { private Set<Media> getMedia() {
return requireRtpConnection().getMedia(); return requireRtpConnection().getMedia();
} }
@ -720,6 +737,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
updateStateDisplay(state); updateStateDisplay(state);
updateButtonConfiguration(state); updateButtonConfiguration(state);
updateVideoViews(state); updateVideoViews(state);
updateProfilePicture(state);
}); });
} else { } else {
Log.d(Config.LOGTAG, "received update for other rtp session"); Log.d(Config.LOGTAG, "received update for other rtp session");
@ -762,6 +780,7 @@ public class RtpSessionActivity extends XmppActivity implements XmppConnectionSe
runOnUiThread(() -> { runOnUiThread(() -> {
updateStateDisplay(state); updateStateDisplay(state);
updateButtonConfiguration(state); updateButtonConfiguration(state);
updateProfilePicture(state);
}); });
resetIntent(account, with, state, actionToMedia(currentIntent.getAction())); resetIntent(account, with, state, actionToMedia(currentIntent.getAction()));
} }

View File

@ -62,6 +62,22 @@
</android.support.design.widget.AppBarLayout> </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 <org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video" android:id="@+id/local_video"
@ -93,13 +109,14 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:alpha="0.7"
android:layout_margin="8dp" android:layout_margin="8dp"
android:alpha="0.7"
android:src="@drawable/ic_mic_off_black_24dp" android:src="@drawable/ic_mic_off_black_24dp"
android:tint="@color/white" android:tint="@color/white"
android:visibility="gone" /> android:visibility="gone" />
<RelativeLayout <RelativeLayout
android:id="@+id/button_row"
android:layout_width="288dp" android:layout_width="288dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"

View File

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

View File

@ -1,4 +1,5 @@
<resources> <resources>
<dimen name="publish_avatar_top_margin">24dp</dimen> <dimen name="publish_avatar_top_margin">24dp</dimen>
<dimen name="publish_avatar_size">192dp</dimen> <dimen name="publish_avatar_size">192dp</dimen>
<dimen name="incoming_call_radius">96dp</dimen>
</resources> </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_top_margin">8dp</dimen>
<dimen name="publish_avatar_size">96dp</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_on_status_message">32dp</dimen>
<dimen name="avatar">48dp</dimen> <dimen name="avatar">48dp</dimen>
<dimen name="avatar_on_details_screen_size">56dp</dimen> <dimen name="avatar_on_details_screen_size">56dp</dimen>