use of org.telegram.ui.Components.CheckBoxSquare in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCallActivity method onLeaveClick.
public static void onLeaveClick(Context context, Runnable onLeave, boolean fromOverlayWindow) {
VoIPService service = VoIPService.getSharedInstance();
if (service == null) {
return;
}
TLRPC.Chat currentChat = service.getChat();
ChatObject.Call call = service.groupCall;
long selfId = service.getSelfId();
if (!ChatObject.canManageCalls(currentChat)) {
processOnLeave(call, false, selfId, onLeave);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (ChatObject.isChannelOrGiga(currentChat)) {
builder.setTitle(LocaleController.getString("VoipChannelLeaveAlertTitle", R.string.VoipChannelLeaveAlertTitle));
builder.setMessage(LocaleController.getString("VoipChannelLeaveAlertText", R.string.VoipChannelLeaveAlertText));
} else {
builder.setTitle(LocaleController.getString("VoipGroupLeaveAlertTitle", R.string.VoipGroupLeaveAlertTitle));
builder.setMessage(LocaleController.getString("VoipGroupLeaveAlertText", R.string.VoipGroupLeaveAlertText));
}
int currentAccount = service.getAccount();
CheckBoxCell[] cells = new CheckBoxCell[1];
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
cells[0] = new CheckBoxCell(context, 1);
cells[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (fromOverlayWindow) {
cells[0].setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
} else {
cells[0].setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
CheckBoxSquare checkBox = (CheckBoxSquare) cells[0].getCheckBoxView();
checkBox.setColors(Theme.key_voipgroup_mutedIcon, Theme.key_voipgroup_listeningText, Theme.key_voipgroup_nameText);
}
cells[0].setTag(0);
if (ChatObject.isChannelOrGiga(currentChat)) {
cells[0].setText(LocaleController.getString("VoipChannelLeaveAlertEndChat", R.string.VoipChannelLeaveAlertEndChat), "", false, false);
} else {
cells[0].setText(LocaleController.getString("VoipGroupLeaveAlertEndChat", R.string.VoipGroupLeaveAlertEndChat), "", false, false);
}
cells[0].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
linearLayout.addView(cells[0], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
cells[0].setOnClickListener(v -> {
Integer num = (Integer) v.getTag();
cells[num].setChecked(!cells[num].isChecked(), true);
});
builder.setCustomViewOffset(12);
builder.setView(linearLayout);
builder.setDialogButtonColorKey(Theme.key_voipgroup_listeningText);
builder.setPositiveButton(LocaleController.getString("VoipGroupLeave", R.string.VoipGroupLeave), (dialogInterface, position) -> processOnLeave(call, cells[0].isChecked(), selfId, onLeave));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
if (fromOverlayWindow) {
builder.setDimEnabled(false);
}
AlertDialog dialog = builder.create();
if (fromOverlayWindow) {
if (Build.VERSION.SDK_INT >= 26) {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
} else {
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
}
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
}
if (!fromOverlayWindow) {
dialog.setBackgroundColor(Theme.getColor(Theme.key_voipgroup_dialogBackground));
}
dialog.show();
if (!fromOverlayWindow) {
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (button != null) {
button.setTextColor(Theme.getColor(Theme.key_voipgroup_leaveCallMenu));
}
dialog.setTextColor(Theme.getColor(Theme.key_voipgroup_actionBarItems));
}
}
Aggregations