use of net.iGap.adapter.items.cells.TextCell in project iGap-Android by KianIranian-STDG.
the class FragmentShowMember method showMemberDialog.
private void showMemberDialog(StructContactInfo contactInfo) {
if (contactInfo.peerId == AccountManager.getInstance().getCurrentUser().getId())
return;
if (realmRoomAccess != null) {
TextCell adminRights = null;
TextCell permission = null;
TextCell removeView = null;
LinearLayout dialogRootView = new LinearLayout(getContext());
dialogRootView.setOrientation(LinearLayout.VERTICAL);
dialogRootView.setBackgroundColor(Theme.getInstance().getRootColor(dialogRootView.getContext()));
if (!contactInfo.isOwner() && realmRoomAccess.isCanAddNewAdmin()) {
adminRights = new TextCell(dialogRootView.getContext(), true);
adminRights.setTextColor(Theme.getInstance().getTitleTextColor(dialogRootView.getContext()));
adminRights.setValue(contactInfo.isAdmin() ? getResources().getString(R.string.edit_admin_rights) : getResources().getString(R.string.set_admin));
dialogRootView.addView(adminRights, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 52));
}
if (!contactInfo.isAdmin() && roomType == GROUP) {
permission = new TextCell(dialogRootView.getContext(), true);
permission.setTextColor(Theme.getInstance().getTitleTextColor(dialogRootView.getContext()));
permission.setValue(getResources().getString(R.string.edit_rights));
dialogRootView.addView(permission, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 52));
}
if (!contactInfo.isOwner() && realmRoomAccess.isCanBanMember()) {
removeView = new TextCell(dialogRootView.getContext(), false);
removeView.setTextColor(dialogRootView.getContext().getResources().getColor(R.color.red));
removeView.setValue(getResources().getString(R.string.remove_user));
dialogRootView.addView(removeView, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, 52));
}
Dialog dialog = new MaterialDialog.Builder(dialogRootView.getContext()).customView(dialogRootView, false).build();
if (removeView != null) {
removeView.setOnClickListener(v -> {
kickMember(contactInfo.peerId);
dialog.dismiss();
});
}
if (adminRights != null) {
adminRights.setOnClickListener(v -> {
openChatEditRightsFragment(realmRoom, contactInfo, contactInfo.isAdmin() ? 1 : 0);
dialog.dismiss();
});
}
if (permission != null) {
permission.setOnClickListener(v -> {
openChatEditRightsFragment(realmRoom, contactInfo, 2);
dialog.dismiss();
});
}
if (dialogRootView.getChildCount() > 0)
dialog.show();
}
}
Aggregations