Treat groups with only 1 child as child directly in chat room devices fragment

This commit is contained in:
Sylvain Berfini 2019-04-12 16:53:49 +02:00
parent d3fbc2939e
commit 80090b3efe
4 changed files with 44 additions and 3 deletions

View file

@ -28,12 +28,13 @@ import org.linphone.R;
class DeviceGroupViewHolder {
public final RelativeLayout avatarLayout;
public final TextView participantName, sipUri;
public final ImageView groupExpander;
public final ImageView groupExpander, securityLevel;
public DeviceGroupViewHolder(View v) {
avatarLayout = v.findViewById(R.id.avatar_layout);
participantName = v.findViewById(R.id.name);
sipUri = v.findViewById(R.id.sipUri);
groupExpander = v.findViewById(R.id.dropdown);
securityLevel = v.findViewById(R.id.device_security_level);
}
}

View file

@ -33,6 +33,7 @@ import org.linphone.core.Address;
import org.linphone.core.ChatRoomSecurityLevel;
import org.linphone.core.Participant;
import org.linphone.core.ParticipantDevice;
import org.linphone.core.tools.Log;
import org.linphone.utils.LinphoneUtils;
import org.linphone.views.ContactAvatar;
@ -127,9 +128,32 @@ class DevicesAdapter extends BaseExpandableListAdapter {
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;
}

View file

@ -103,6 +103,13 @@ public class DevicesFragment extends Fragment {
(ParticipantDevice) mAdapter.getGroup(groupPosition);
CallManager.getInstance().inviteAddress(device.getAddress(), true);
return true;
} else {
if (mAdapter.getChildrenCount(groupPosition) == 1) {
ParticipantDevice device =
(ParticipantDevice) mAdapter.getChild(groupPosition, 0);
CallManager.getInstance().inviteAddress(device.getAddress(), true);
return true;
}
}
return false;
}

View file

@ -53,6 +53,15 @@
</LinearLayout>
<ImageView
android:id="@+id/device_security_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:src="@drawable/security_alert_indicator" />
<ImageView
android:id="@id/dropdown"
android:layout_width="wrap_content"