Show our own devices in security view
This commit is contained in:
parent
3f7d43aa2a
commit
795bd0b04d
5 changed files with 75 additions and 108 deletions
|
@ -18,6 +18,11 @@ Group changes to describe their impact on the project, as follows:
|
||||||
- Added sample application to help developpers getting started with our SDK
|
- Added sample application to help developpers getting started with our SDK
|
||||||
- Added picture in picture feature if supported instead of video overlay
|
- Added picture in picture feature if supported instead of video overlay
|
||||||
- Added camera preview as dialer's background on tablets
|
- Added camera preview as dialer's background on tablets
|
||||||
|
- Contact section in the settings
|
||||||
|
|
||||||
|
## Changed
|
||||||
|
- Call statistics are now available for each call & conference
|
||||||
|
- Added our own devices in LIME encrypted chatrooms' security view
|
||||||
|
|
||||||
## [4.1.0] - 2019-05-03
|
## [4.1.0] - 2019-05-03
|
||||||
|
|
||||||
|
@ -173,6 +178,3 @@ Group changes to describe their impact on the project, as follows:
|
||||||
- Crashes Android 6/7 at starting
|
- Crashes Android 6/7 at starting
|
||||||
- Permissions issues
|
- Permissions issues
|
||||||
- Layout of tablet views
|
- Layout of tablet views
|
||||||
|
|
||||||
### Changed
|
|
||||||
- management of the view for displaying call statistics
|
|
||||||
|
|
|
@ -71,10 +71,10 @@ public class CallStatsAdapter extends BaseExpandableListAdapter {
|
||||||
view = inflater.inflate(R.layout.call_stats_child, viewGroup, false);
|
view = inflater.inflate(R.layout.call_stats_child, viewGroup, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// filling the view
|
// filling the view
|
||||||
holder = new CallStatsChildViewHolder(view, mContext);
|
holder = new CallStatsChildViewHolder(view, mContext);
|
||||||
view.setTag(holder);
|
view.setTag(holder);
|
||||||
holder.setCall(mCalls.get(groupPosition));
|
holder.setCall(mCalls.get(groupPosition));
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,9 +157,11 @@ public class ChatMessagesFragment extends Fragment
|
||||||
if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
if (mChatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt())) {
|
||||||
ParticipantDevice[] devices =
|
ParticipantDevice[] devices =
|
||||||
mChatRoom.getParticipants()[0].getDevices();
|
mChatRoom.getParticipants()[0].getDevices();
|
||||||
if (devices.length == 1) {
|
// Only start a call automatically if both ourselves and the remote
|
||||||
oneParticipantOneDevice = true;
|
// have 1 device exactly, otherwise show devices list.
|
||||||
}
|
oneParticipantOneDevice =
|
||||||
|
devices.length == 1
|
||||||
|
&& mChatRoom.getMe().getDevices().length == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LinphonePreferences.instance().isLimeSecurityPopupEnabled()) {
|
if (LinphonePreferences.instance().isLimeSecurityPopupEnabled()) {
|
||||||
|
|
|
@ -39,16 +39,13 @@ import org.linphone.views.ContactAvatar;
|
||||||
class DevicesAdapter extends BaseExpandableListAdapter {
|
class DevicesAdapter extends BaseExpandableListAdapter {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private List<Participant> mParticipants;
|
private List<Participant> mParticipants;
|
||||||
private boolean mOnlyDisplayChildsAsGroups;
|
|
||||||
|
|
||||||
public DevicesAdapter(Context context) {
|
public DevicesAdapter(Context context) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mParticipants = new ArrayList<>();
|
mParticipants = new ArrayList<>();
|
||||||
mOnlyDisplayChildsAsGroups = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateListItems(List<Participant> participants, boolean childsAsGroups) {
|
public void updateListItems(List<Participant> participants) {
|
||||||
mOnlyDisplayChildsAsGroups = childsAsGroups;
|
|
||||||
mParticipants = participants;
|
mParticipants = participants;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -56,26 +53,48 @@ class DevicesAdapter extends BaseExpandableListAdapter {
|
||||||
@Override
|
@Override
|
||||||
public View getGroupView(
|
public View getGroupView(
|
||||||
int groupPosition, boolean isExpanded, View view, ViewGroup viewGroup) {
|
int groupPosition, boolean isExpanded, View view, ViewGroup viewGroup) {
|
||||||
if (mOnlyDisplayChildsAsGroups) {
|
Participant participant = (Participant) getGroup(groupPosition);
|
||||||
ParticipantDevice device = (ParticipantDevice) getGroup(groupPosition);
|
|
||||||
|
|
||||||
DeviceChildViewHolder holder = null;
|
// Group position 0 is reserved for ME participant & devices
|
||||||
if (view != null) {
|
DeviceGroupViewHolder holder = null;
|
||||||
Object possibleHolder = view.getTag();
|
if (view != null) {
|
||||||
if (possibleHolder instanceof DeviceChildViewHolder) {
|
Object possibleHolder = view.getTag();
|
||||||
holder = (DeviceChildViewHolder) possibleHolder;
|
if (possibleHolder instanceof DeviceGroupViewHolder) {
|
||||||
}
|
holder = (DeviceGroupViewHolder) possibleHolder;
|
||||||
} else {
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
|
||||||
view = inflater.inflate(R.layout.chat_device_cell_as_group, viewGroup, false);
|
|
||||||
}
|
|
||||||
if (holder == null) {
|
|
||||||
holder = new DeviceChildViewHolder(view);
|
|
||||||
view.setTag(holder);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||||
|
view = inflater.inflate(R.layout.chat_device_group, viewGroup, false);
|
||||||
|
}
|
||||||
|
if (holder == null) {
|
||||||
|
holder = new DeviceGroupViewHolder(view);
|
||||||
|
view.setTag(holder);
|
||||||
|
}
|
||||||
|
|
||||||
holder.deviceName.setText(device.getName());
|
Address participantAddress = participant.getAddress();
|
||||||
|
LinphoneContact contact =
|
||||||
|
ContactsManager.getInstance().findContactFromAddress(participantAddress);
|
||||||
|
if (contact != null) {
|
||||||
|
ContactAvatar.displayAvatar(
|
||||||
|
contact, participant.getSecurityLevel(), holder.avatarLayout);
|
||||||
|
holder.participantName.setText(contact.getFullName());
|
||||||
|
} else {
|
||||||
|
String displayName = LinphoneUtils.getAddressDisplayName(participantAddress);
|
||||||
|
ContactAvatar.displayAvatar(
|
||||||
|
displayName, participant.getSecurityLevel(), holder.avatarLayout);
|
||||||
|
holder.participantName.setText(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.sipUri.setText(participantAddress.asStringUriOnly());
|
||||||
|
if (!mContext.getResources().getBoolean(R.bool.show_sip_uri_in_chat)) {
|
||||||
|
holder.sipUri.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getChildrenCount(groupPosition) == 1) {
|
||||||
|
holder.securityLevel.setVisibility(View.VISIBLE);
|
||||||
|
holder.groupExpander.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
ParticipantDevice device = (ParticipantDevice) getChild(groupPosition, 0);
|
||||||
ChatRoomSecurityLevel level = device.getSecurityLevel();
|
ChatRoomSecurityLevel level = device.getSecurityLevel();
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case Safe:
|
case Safe:
|
||||||
|
@ -91,67 +110,10 @@ class DevicesAdapter extends BaseExpandableListAdapter {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Participant participant = (Participant) getGroup(groupPosition);
|
holder.securityLevel.setVisibility(View.GONE);
|
||||||
|
holder.groupExpander.setVisibility(View.VISIBLE);
|
||||||
DeviceGroupViewHolder holder = null;
|
holder.groupExpander.setImageResource(
|
||||||
if (view != null) {
|
isExpanded ? R.drawable.chevron_list_open : R.drawable.chevron_list_close);
|
||||||
Object possibleHolder = view.getTag();
|
|
||||||
if (possibleHolder instanceof DeviceGroupViewHolder) {
|
|
||||||
holder = (DeviceGroupViewHolder) possibleHolder;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
|
||||||
view = inflater.inflate(R.layout.chat_device_group, viewGroup, false);
|
|
||||||
}
|
|
||||||
if (holder == null) {
|
|
||||||
holder = new DeviceGroupViewHolder(view);
|
|
||||||
view.setTag(holder);
|
|
||||||
}
|
|
||||||
|
|
||||||
Address participantAddress = participant.getAddress();
|
|
||||||
LinphoneContact contact =
|
|
||||||
ContactsManager.getInstance().findContactFromAddress(participantAddress);
|
|
||||||
if (contact != null) {
|
|
||||||
ContactAvatar.displayAvatar(
|
|
||||||
contact, participant.getSecurityLevel(), holder.avatarLayout);
|
|
||||||
holder.participantName.setText(contact.getFullName());
|
|
||||||
} else {
|
|
||||||
String displayName = LinphoneUtils.getAddressDisplayName(participantAddress);
|
|
||||||
ContactAvatar.displayAvatar(
|
|
||||||
displayName, participant.getSecurityLevel(), holder.avatarLayout);
|
|
||||||
holder.participantName.setText(displayName);
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.sipUri.setText(participantAddress.asStringUriOnly());
|
|
||||||
if (!mContext.getResources().getBoolean(R.bool.show_sip_uri_in_chat)) {
|
|
||||||
holder.sipUri.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getChildrenCount(groupPosition) == 1) {
|
|
||||||
holder.securityLevel.setVisibility(View.VISIBLE);
|
|
||||||
holder.groupExpander.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
ParticipantDevice device = (ParticipantDevice) getChild(groupPosition, 0);
|
|
||||||
ChatRoomSecurityLevel level = device.getSecurityLevel();
|
|
||||||
switch (level) {
|
|
||||||
case Safe:
|
|
||||||
holder.securityLevel.setImageResource(R.drawable.security_2_indicator);
|
|
||||||
break;
|
|
||||||
case Encrypted:
|
|
||||||
holder.securityLevel.setImageResource(R.drawable.security_1_indicator);
|
|
||||||
break;
|
|
||||||
case ClearText:
|
|
||||||
case Unsafe:
|
|
||||||
default:
|
|
||||||
holder.securityLevel.setImageResource(R.drawable.security_alert_indicator);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
holder.securityLevel.setVisibility(View.GONE);
|
|
||||||
holder.groupExpander.setVisibility(View.VISIBLE);
|
|
||||||
holder.groupExpander.setImageResource(
|
|
||||||
isExpanded ? R.drawable.chevron_list_open : R.drawable.chevron_list_close);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
@ -199,32 +161,27 @@ class DevicesAdapter extends BaseExpandableListAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupCount() {
|
public int getGroupCount() {
|
||||||
if (mParticipants.isEmpty()) return 0;
|
return mParticipants.size();
|
||||||
return mOnlyDisplayChildsAsGroups
|
|
||||||
? mParticipants.get(0).getDevices().length
|
|
||||||
: mParticipants.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getChildrenCount(int groupPosition) {
|
public int getChildrenCount(int groupPosition) {
|
||||||
if (mParticipants.isEmpty()) return 0;
|
if (groupPosition >= mParticipants.size()) return 0;
|
||||||
return mOnlyDisplayChildsAsGroups
|
return mParticipants.get(groupPosition).getDevices().length;
|
||||||
? 0
|
|
||||||
: mParticipants.get(groupPosition).getDevices().length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getGroup(int groupPosition) {
|
public Object getGroup(int groupPosition) {
|
||||||
if (mParticipants.isEmpty()) return null;
|
if (groupPosition >= mParticipants.size()) return null;
|
||||||
return mOnlyDisplayChildsAsGroups
|
return mParticipants.get(groupPosition);
|
||||||
? mParticipants.get(0).getDevices()[groupPosition]
|
|
||||||
: mParticipants.get(groupPosition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getChild(int groupPosition, int childPosition) {
|
public Object getChild(int groupPosition, int childPosition) {
|
||||||
if (mParticipants.isEmpty()) return null;
|
if (groupPosition >= mParticipants.size()) return null;
|
||||||
return mParticipants.get(groupPosition).getDevices()[childPosition];
|
ParticipantDevice[] devices = mParticipants.get(groupPosition).getDevices();
|
||||||
|
if (devices.length == 0 || childPosition >= devices.length) return null;
|
||||||
|
return devices[childPosition];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,7 @@ import android.widget.ExpandableListView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.contacts.ContactsManager;
|
import org.linphone.contacts.ContactsManager;
|
||||||
|
@ -38,6 +38,7 @@ import org.linphone.core.ChatRoom;
|
||||||
import org.linphone.core.ChatRoomCapabilities;
|
import org.linphone.core.ChatRoomCapabilities;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.Factory;
|
import org.linphone.core.Factory;
|
||||||
|
import org.linphone.core.Participant;
|
||||||
import org.linphone.core.ParticipantDevice;
|
import org.linphone.core.ParticipantDevice;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.LinphoneUtils;
|
||||||
|
|
||||||
|
@ -173,8 +174,13 @@ public class DevicesFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mRoom != null && mRoom.getNbParticipants() > 0) {
|
if (mRoom != null && mRoom.getNbParticipants() > 0) {
|
||||||
mOnlyDisplayChilds = mRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt());
|
ArrayList<Participant> participantLists = new ArrayList<>();
|
||||||
mAdapter.updateListItems(Arrays.asList(mRoom.getParticipants()), mOnlyDisplayChilds);
|
// Group position 0 is reserved for ME participant & devices
|
||||||
|
participantLists.add(mRoom.getMe());
|
||||||
|
for (Participant participant : mRoom.getParticipants()) {
|
||||||
|
participantLists.add(participant);
|
||||||
|
}
|
||||||
|
mAdapter.updateListItems(participantLists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue