forked from mirror/monocles_chat_clean
update fork #128
4 changed files with 50 additions and 15 deletions
Show audio/video call options in call log
commit
1b63d669b5
|
|
@ -41,6 +41,7 @@ public class CallsFragment extends Fragment implements CallsAdapter.OnCallAgainC
|
|||
private CallsAdapter adapter;
|
||||
private List<Message> calls = new ArrayList<>();
|
||||
private Message mPendingCall;
|
||||
private boolean mPendingVideoCall;
|
||||
|
||||
private static final int REQUEST_START_AUDIO_CALL = 0x213;
|
||||
private static final int REQUEST_START_VIDEO_CALL = 0x214;
|
||||
|
|
@ -112,9 +113,10 @@ public class CallsFragment extends Fragment implements CallsAdapter.OnCallAgainC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCallAgainClick(Message call) {
|
||||
public void onCallAgainClick(Message call, boolean isVideoCall) {
|
||||
mPendingCall = call;
|
||||
if (call.getBody().contains("video")) {
|
||||
mPendingVideoCall = isVideoCall;
|
||||
if (isVideoCall) {
|
||||
checkPermissionAndTriggerVideoCall();
|
||||
} else {
|
||||
checkPermissionAndTriggerAudioCall();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
|
@ -26,7 +27,7 @@ public class CallsAdapter extends RecyclerView.Adapter<CallsAdapter.CallViewHold
|
|||
private final XmppConnectionService xmppConnectionService;
|
||||
|
||||
public interface OnCallAgainClickListener {
|
||||
void onCallAgainClick(Message call);
|
||||
void onCallAgainClick(Message call, boolean isVideoCall);
|
||||
}
|
||||
|
||||
public CallsAdapter(List<Message> calls, OnCallAgainClickListener listener, XmppConnectionService xmppConnectionService) {
|
||||
|
|
@ -71,11 +72,25 @@ public class CallsAdapter extends RecyclerView.Adapter<CallsAdapter.CallViewHold
|
|||
}
|
||||
|
||||
public void bind(final Message call, final OnCallAgainClickListener listener, final XmppConnectionService xmppConnectionService) {
|
||||
AvatarWorkerTask.loadAvatar(call.getConversation().getContact(), avatar, R.dimen.avatar_story_size);
|
||||
AvatarWorkerTask.loadAvatar(call.getConversation().getContact(), avatar, R.dimen.bubble_avatar_size);
|
||||
contactName.setText(call.getConversation().getContact().getDisplayName());
|
||||
callInfo.setText(UIHelper.getMessagePreview(xmppConnectionService, call).first);
|
||||
callDate.setText(UIHelper.readableTimeDifference(itemView.getContext(), call.getTimeSent(), false));
|
||||
callAgainButton.setOnClickListener(v -> listener.onCallAgainClick(call));
|
||||
callAgainButton.setOnClickListener(v -> {
|
||||
PopupMenu popup = new PopupMenu(v.getContext(), v);
|
||||
popup.getMenuInflater().inflate(R.menu.call_again_context, popup.getMenu());
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.action_voice_call) {
|
||||
listener.onCallAgainClick(call, false);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.action_video_call) {
|
||||
listener.onCallAgainClick(call, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
popup.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
android:padding="14dp">
|
||||
|
||||
<eu.siacs.conversations.ui.widget.AvatarView
|
||||
android:id="@+id/avatar"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
|
@ -30,24 +30,31 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginEnd="4dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/call_info"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
/>
|
||||
android:layout_marginEnd="4dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="2dp"
|
||||
android:layout_height="2dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="?android:attr/textColorPrimary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/call_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
android:layout_marginStart="4dp"
|
||||
android:layout_marginEnd="4dp" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
11
src/main/res/menu/call_again_context.xml
Normal file
11
src/main/res/menu/call_again_context.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_voice_call"
|
||||
android:title="@string/audio_call"
|
||||
android:icon="@drawable/ic_call_24dp" />
|
||||
<item
|
||||
android:id="@+id/action_video_call"
|
||||
android:title="@string/video_call"
|
||||
android:icon="@drawable/ic_videocam_24dp"/>
|
||||
</menu>
|
||||
Loading…
Add table
Add a link
Reference in a new issue