use of org.telegram.ui.Cells.RadioButtonCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatEditActivity method createView.
@Override
public View createView(Context context) {
if (nameTextView != null) {
nameTextView.onDestroy();
}
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
if (checkDiscard()) {
finishFragment();
}
} else if (id == done_button) {
processDone();
}
}
});
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
private boolean ignoreLayout;
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = measureKeyboardHeight();
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
nameTextView.hideEmojiView();
ignoreLayout = false;
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child == null || child.getVisibility() == GONE || child == actionBar) {
continue;
}
if (nameTextView != null && nameTextView.isPopupView(child)) {
if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
if (AndroidUtilities.isTablet()) {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
}
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
}
} else {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
}
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int keyboardSize = measureKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int width = child.getMeasuredWidth();
final int height = child.getMeasuredHeight();
int childLeft;
int childTop;
int gravity = lp.gravity;
if (gravity == -1) {
gravity = Gravity.TOP | Gravity.LEFT;
}
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
break;
case Gravity.RIGHT:
childLeft = r - width - lp.rightMargin;
break;
case Gravity.LEFT:
default:
childLeft = lp.leftMargin;
}
switch(verticalGravity) {
case Gravity.TOP:
childTop = lp.topMargin + getPaddingTop();
break;
case Gravity.CENTER_VERTICAL:
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
break;
default:
childTop = lp.topMargin;
}
if (nameTextView != null && nameTextView.isPopupView(child)) {
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
notifyHeightChanged();
}
@Override
public void requestLayout() {
if (ignoreLayout) {
return;
}
super.requestLayout();
}
};
sizeNotifierFrameLayout.setOnTouchListener((v, event) -> true);
fragmentView = sizeNotifierFrameLayout;
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
ScrollView scrollView = new ScrollView(context);
scrollView.setFillViewport(true);
sizeNotifierFrameLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
LinearLayout linearLayout1 = new LinearLayout(context);
scrollView.addView(linearLayout1, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout1.setOrientation(LinearLayout.VERTICAL);
actionBar.setTitle(LocaleController.getString("ChannelEdit", R.string.ChannelEdit));
avatarContainer = new LinearLayout(context);
avatarContainer.setOrientation(LinearLayout.VERTICAL);
avatarContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(avatarContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
FrameLayout frameLayout = new FrameLayout(context);
avatarContainer.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
avatarImage = new BackupImageView(context) {
@Override
public void invalidate() {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate();
}
@Override
public void invalidate(int l, int t, int r, int b) {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate(l, t, r, b);
}
};
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
if (ChatObject.canChangeChatInfo(currentChat)) {
frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0x55000000);
avatarOverlay = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
if (avatarImage != null && avatarImage.getImageReceiver().hasNotThumb()) {
paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha()));
canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
}
}
};
frameLayout.addView(avatarOverlay, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
avatarProgressView = new RadialProgressView(context);
avatarProgressView.setSize(AndroidUtilities.dp(30));
avatarProgressView.setProgressColor(0xffffffff);
avatarProgressView.setNoProgress(false);
frameLayout.addView(avatarProgressView, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 8));
showAvatarProgress(false, false);
avatarContainer.setOnClickListener(v -> {
if (imageUpdater.isUploadingImage()) {
return;
}
TLRPC.Chat chat = getMessagesController().getChat(chatId);
if (chat.photo != null && chat.photo.photo_big != null) {
PhotoViewer.getInstance().setParentActivity(getParentActivity());
if (chat.photo.dc_id != 0) {
chat.photo.photo_big.dc_id = chat.photo.dc_id;
}
ImageLocation videoLocation;
if (info != null && (info.chat_photo instanceof TLRPC.TL_photo) && !info.chat_photo.video_sizes.isEmpty()) {
videoLocation = ImageLocation.getForPhoto(info.chat_photo.video_sizes.get(0), info.chat_photo);
} else {
videoLocation = null;
}
PhotoViewer.getInstance().openPhotoWithVideo(chat.photo.photo_big, videoLocation, provider);
}
});
} else {
frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
}
nameTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, this, EditTextEmoji.STYLE_FRAGMENT);
if (isChannel) {
nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName));
} else {
nameTextView.setHint(LocaleController.getString("GroupName", R.string.GroupName));
}
nameTextView.setEnabled(ChatObject.canChangeChatInfo(currentChat));
nameTextView.setFocusable(nameTextView.isEnabled());
nameTextView.getEditText().addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
avatarDrawable.setInfo(5, nameTextView.getText().toString(), null);
if (avatarImage != null) {
avatarImage.invalidate();
}
}
});
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(128);
nameTextView.setFilters(inputFilters);
frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 5 : 96, 0, LocaleController.isRTL ? 96 : 5, 0));
settingsContainer = new LinearLayout(context);
settingsContainer.setOrientation(LinearLayout.VERTICAL);
settingsContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(settingsContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (ChatObject.canChangeChatInfo(currentChat)) {
setAvatarCell = new TextCell(context) {
@Override
protected void onDraw(Canvas canvas) {
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
}
};
setAvatarCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
setAvatarCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
setAvatarCell.setOnClickListener(v -> {
imageUpdater.openMenu(avatar != null, () -> {
avatar = null;
MessagesController.getInstance(currentAccount).changeChatAvatar(chatId, null, null, null, 0, null, null, null, null);
showAvatarProgress(false, true);
avatarImage.setImage(null, null, avatarDrawable, currentChat);
cameraDrawable.setCurrentFrame(0);
setAvatarCell.imageView.playAnimation();
}, dialogInterface -> {
if (!imageUpdater.isUploadingImage()) {
cameraDrawable.setCustomEndFrame(86);
setAvatarCell.imageView.playAnimation();
} else {
cameraDrawable.setCurrentFrame(0, false);
}
});
cameraDrawable.setCurrentFrame(0);
cameraDrawable.setCustomEndFrame(43);
setAvatarCell.imageView.playAnimation();
});
settingsContainer.addView(setAvatarCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
descriptionTextView = new EditTextBoldCursor(context);
descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
descriptionTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
descriptionTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
descriptionTextView.setBackgroundDrawable(null);
descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
descriptionTextView.setEnabled(ChatObject.canChangeChatInfo(currentChat));
descriptionTextView.setFocusable(descriptionTextView.isEnabled());
inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(255);
descriptionTextView.setFilters(inputFilters);
descriptionTextView.setHint(LocaleController.getString("DescriptionOptionalPlaceholder", R.string.DescriptionOptionalPlaceholder));
descriptionTextView.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setCursorSize(AndroidUtilities.dp(20));
descriptionTextView.setCursorWidth(1.5f);
if (descriptionTextView.isEnabled()) {
settingsContainer.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 23, 15, 23, 9));
} else {
settingsContainer.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 23, 12, 23, 6));
}
descriptionTextView.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
doneButton.performClick();
return true;
}
return false;
});
descriptionTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
}
});
settingsTopSectionCell = new ShadowSectionCell(context);
linearLayout1.addView(settingsTopSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
typeEditContainer = new LinearLayout(context);
typeEditContainer.setOrientation(LinearLayout.VERTICAL);
typeEditContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(typeEditContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (currentChat.megagroup && (info == null || info.can_set_location)) {
locationCell = new TextDetailCell(context);
locationCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
typeEditContainer.addView(locationCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
locationCell.setOnClickListener(v -> {
if (!AndroidUtilities.isGoogleMapsInstalled(ChatEditActivity.this)) {
return;
}
LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP);
fragment.setDialogId(-chatId);
if (info != null && info.location instanceof TLRPC.TL_channelLocation) {
fragment.setInitialLocation((TLRPC.TL_channelLocation) info.location);
}
fragment.setDelegate((location, live, notify, scheduleDate) -> {
TLRPC.TL_channelLocation channelLocation = new TLRPC.TL_channelLocation();
channelLocation.address = location.address;
channelLocation.geo_point = location.geo;
info.location = channelLocation;
info.flags |= 32768;
updateFields(false);
getMessagesController().loadFullChat(chatId, 0, true);
});
presentFragment(fragment);
});
}
if (currentChat.creator && (info == null || info.can_set_username)) {
typeCell = new TextDetailCell(context);
typeCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
typeEditContainer.addView(typeCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
typeCell.setOnClickListener(v -> {
ChatEditTypeActivity fragment = new ChatEditTypeActivity(chatId, locationCell != null && locationCell.getVisibility() == View.VISIBLE);
fragment.setInfo(info);
presentFragment(fragment);
});
}
if (ChatObject.isChannel(currentChat) && (isChannel && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_CHANGE_INFO) || !isChannel && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_PIN))) {
linkedCell = new TextDetailCell(context);
linkedCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
typeEditContainer.addView(linkedCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linkedCell.setOnClickListener(v -> {
ChatLinkActivity fragment = new ChatLinkActivity(chatId);
fragment.setInfo(info);
presentFragment(fragment);
});
}
if (!isChannel && ChatObject.canBlockUsers(currentChat) && (ChatObject.isChannel(currentChat) || currentChat.creator)) {
historyCell = new TextDetailCell(context);
historyCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
typeEditContainer.addView(historyCell, LayoutHelper.createLinear(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
historyCell.setOnClickListener(v -> {
BottomSheet.Builder builder = new BottomSheet.Builder(context);
builder.setApplyTopPadding(false);
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
HeaderCell headerCell = new HeaderCell(context, Theme.key_dialogTextBlue2, 23, 15, false);
headerCell.setHeight(47);
headerCell.setText(LocaleController.getString("ChatHistory", R.string.ChatHistory));
linearLayout.addView(headerCell);
LinearLayout linearLayoutInviteContainer = new LinearLayout(context);
linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
RadioButtonCell[] buttons = new RadioButtonCell[2];
for (int a = 0; a < 2; a++) {
buttons[a] = new RadioButtonCell(context, true);
buttons[a].setTag(a);
buttons[a].setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (a == 0) {
buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryVisible", R.string.ChatHistoryVisible), LocaleController.getString("ChatHistoryVisibleInfo", R.string.ChatHistoryVisibleInfo), true, !historyHidden);
} else {
if (ChatObject.isChannel(currentChat)) {
buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryHidden", R.string.ChatHistoryHidden), LocaleController.getString("ChatHistoryHiddenInfo", R.string.ChatHistoryHiddenInfo), false, historyHidden);
} else {
buttons[a].setTextAndValue(LocaleController.getString("ChatHistoryHidden", R.string.ChatHistoryHidden), LocaleController.getString("ChatHistoryHiddenInfo2", R.string.ChatHistoryHiddenInfo2), false, historyHidden);
}
}
linearLayoutInviteContainer.addView(buttons[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
buttons[a].setOnClickListener(v2 -> {
Integer tag = (Integer) v2.getTag();
buttons[0].setChecked(tag == 0, true);
buttons[1].setChecked(tag == 1, true);
historyHidden = tag == 1;
builder.getDismissRunnable().run();
updateFields(true);
});
}
builder.setCustomView(linearLayout);
showDialog(builder.create());
});
}
if (isChannel) {
signCell = new TextCheckCell(context);
signCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
signCell.setTextAndValueAndCheck(LocaleController.getString("ChannelSignMessages", R.string.ChannelSignMessages), LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo), signMessages, true, false);
typeEditContainer.addView(signCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
signCell.setOnClickListener(v -> {
signMessages = !signMessages;
((TextCheckCell) v).setChecked(signMessages);
});
}
ActionBarMenu menu = actionBar.createMenu();
if (ChatObject.canChangeChatInfo(currentChat) || signCell != null || historyCell != null) {
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
doneButton.setContentDescription(LocaleController.getString("Done", R.string.Done));
}
if (locationCell != null || signCell != null || historyCell != null || typeCell != null || linkedCell != null) {
settingsSectionCell = new ShadowSectionCell(context);
linearLayout1.addView(settingsSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
infoContainer = new LinearLayout(context);
infoContainer.setOrientation(LinearLayout.VERTICAL);
infoContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(infoContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
blockCell = new TextCell(context);
blockCell.setBackground(Theme.getSelectorDrawable(false));
blockCell.setVisibility(ChatObject.isChannel(currentChat) || currentChat.creator || ChatObject.hasAdminRights(currentChat) && ChatObject.canChangeChatInfo(currentChat) ? View.VISIBLE : View.GONE);
blockCell.setOnClickListener(v -> {
Bundle args = new Bundle();
args.putLong("chat_id", chatId);
args.putInt("type", !isChannel && !currentChat.gigagroup ? ChatUsersActivity.TYPE_KICKED : ChatUsersActivity.TYPE_BANNED);
ChatUsersActivity fragment = new ChatUsersActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
});
inviteLinksCell = new TextCell(context);
inviteLinksCell.setBackground(Theme.getSelectorDrawable(false));
inviteLinksCell.setOnClickListener(v -> {
ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
fragment.setInfo(info, info.exported_invite);
presentFragment(fragment);
});
reactionsCell = new TextCell(context);
reactionsCell.setBackground(Theme.getSelectorDrawable(false));
reactionsCell.setOnClickListener(v -> {
Bundle args = new Bundle();
args.putLong(ChatReactionsEditActivity.KEY_CHAT_ID, chatId);
ChatReactionsEditActivity reactionsEditActivity = new ChatReactionsEditActivity(args);
reactionsEditActivity.setInfo(info);
presentFragment(reactionsEditActivity);
});
adminCell = new TextCell(context);
adminCell.setBackground(Theme.getSelectorDrawable(false));
adminCell.setOnClickListener(v -> {
Bundle args = new Bundle();
args.putLong("chat_id", chatId);
args.putInt("type", ChatUsersActivity.TYPE_ADMIN);
ChatUsersActivity fragment = new ChatUsersActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
});
membersCell = new TextCell(context);
membersCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
membersCell.setOnClickListener(v -> {
Bundle args = new Bundle();
args.putLong("chat_id", chatId);
args.putInt("type", ChatUsersActivity.TYPE_USERS);
ChatUsersActivity fragment = new ChatUsersActivity(args);
fragment.setInfo(info);
presentFragment(fragment);
});
if (!ChatObject.isChannelAndNotMegaGroup(currentChat)) {
memberRequestsCell = new TextCell(context);
memberRequestsCell.setBackground(Theme.getSelectorDrawable(false));
memberRequestsCell.setOnClickListener(v -> {
MemberRequestsActivity activity = new MemberRequestsActivity(chatId);
presentFragment(activity);
});
}
if (ChatObject.isChannel(currentChat) || currentChat.gigagroup) {
logCell = new TextCell(context);
logCell.setTextAndIcon(LocaleController.getString("EventLog", R.string.EventLog), R.drawable.group_log, false);
logCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
logCell.setOnClickListener(v -> presentFragment(new ChannelAdminLogActivity(currentChat)));
}
infoContainer.addView(reactionsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (!isChannel && !currentChat.gigagroup) {
infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
if (!isChannel) {
infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
infoContainer.addView(adminCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
infoContainer.addView(membersCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (memberRequestsCell != null && info != null && info.requests_pending > 0) {
infoContainer.addView(memberRequestsCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
if (isChannel) {
infoContainer.addView(inviteLinksCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
if (isChannel || currentChat.gigagroup) {
infoContainer.addView(blockCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
if (logCell != null) {
infoContainer.addView(logCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
infoSectionCell = new ShadowSectionCell(context);
linearLayout1.addView(infoSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (!ChatObject.hasAdminRights(currentChat)) {
infoContainer.setVisibility(View.GONE);
settingsTopSectionCell.setVisibility(View.GONE);
}
if (!isChannel && info != null && info.can_set_stickers) {
stickersContainer = new FrameLayout(context);
stickersContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(stickersContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
stickersCell = new TextSettingsCell(context);
stickersCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
stickersCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
stickersContainer.addView(stickersCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
stickersCell.setOnClickListener(v -> {
GroupStickersActivity groupStickersActivity = new GroupStickersActivity(currentChat.id);
groupStickersActivity.setInfo(info);
presentFragment(groupStickersActivity);
});
stickersInfoCell3 = new TextInfoPrivacyCell(context);
stickersInfoCell3.setText(LocaleController.getString("GroupStickersInfo", R.string.GroupStickersInfo));
linearLayout1.addView(stickersInfoCell3, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
}
if (currentChat.creator) {
deleteContainer = new FrameLayout(context);
deleteContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout1.addView(deleteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
deleteCell = new TextSettingsCell(context);
deleteCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText5));
deleteCell.setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (isChannel) {
deleteCell.setText(LocaleController.getString("ChannelDelete", R.string.ChannelDelete), false);
} else {
deleteCell.setText(LocaleController.getString("DeleteAndExitButton", R.string.DeleteAndExitButton), false);
}
deleteContainer.addView(deleteCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
deleteCell.setOnClickListener(v -> AlertsCreator.createClearOrDeleteDialogAlert(ChatEditActivity.this, false, true, false, currentChat, null, false, true, (param) -> {
if (AndroidUtilities.isTablet()) {
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, -chatId);
} else {
getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
}
finishFragment();
getNotificationCenter().postNotificationName(NotificationCenter.needDeleteDialog, -currentChat.id, null, currentChat, param);
}, null));
deleteInfoCell = new ShadowSectionCell(context);
deleteInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout1.addView(deleteInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
} else {
if (!isChannel) {
if (stickersInfoCell3 == null) {
infoSectionCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
}
}
}
if (stickersInfoCell3 != null) {
if (deleteInfoCell == null) {
stickersInfoCell3.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
} else {
stickersInfoCell3.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
}
}
undoView = new UndoView(context);
sizeNotifierFrameLayout.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
nameTextView.setText(currentChat.title);
nameTextView.setSelection(nameTextView.length());
if (info != null) {
descriptionTextView.setText(info.about);
}
setAvatar();
updateFields(true);
return fragmentView;
}
use of org.telegram.ui.Cells.RadioButtonCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChatEditTypeActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
processDone();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
fragmentView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
rectangle.bottom += AndroidUtilities.dp(60);
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
};
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
ScrollView scrollView = (ScrollView) fragmentView;
scrollView.setFillViewport(true);
linearLayout = new LinearLayout(context);
scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
if (isForcePublic) {
actionBar.setTitle(LocaleController.getString("TypeLocationGroup", R.string.TypeLocationGroup));
} else if (isChannel) {
actionBar.setTitle(LocaleController.getString("ChannelSettingsTitle", R.string.ChannelSettingsTitle));
} else {
actionBar.setTitle(LocaleController.getString("GroupSettingsTitle", R.string.GroupSettingsTitle));
}
linearLayoutTypeContainer = new LinearLayout(context);
linearLayoutTypeContainer.setOrientation(LinearLayout.VERTICAL);
linearLayoutTypeContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout.addView(linearLayoutTypeContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
headerCell2 = new HeaderCell(context, 23);
headerCell2.setHeight(46);
if (isChannel) {
headerCell2.setText(LocaleController.getString("ChannelTypeHeader", R.string.ChannelTypeHeader));
} else {
headerCell2.setText(LocaleController.getString("GroupTypeHeader", R.string.GroupTypeHeader));
}
linearLayoutTypeContainer.addView(headerCell2);
radioButtonCell2 = new RadioButtonCell(context);
radioButtonCell2.setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (isChannel) {
radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), false, isPrivate);
} else {
radioButtonCell2.setTextAndValue(LocaleController.getString("MegaPrivate", R.string.MegaPrivate), LocaleController.getString("MegaPrivateInfo", R.string.MegaPrivateInfo), false, isPrivate);
}
linearLayoutTypeContainer.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell2.setOnClickListener(v -> {
if (isPrivate) {
return;
}
isPrivate = true;
updatePrivatePublic();
});
radioButtonCell1 = new RadioButtonCell(context);
radioButtonCell1.setBackgroundDrawable(Theme.getSelectorDrawable(false));
if (isChannel) {
radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), false, !isPrivate);
} else {
radioButtonCell1.setTextAndValue(LocaleController.getString("MegaPublic", R.string.MegaPublic), LocaleController.getString("MegaPublicInfo", R.string.MegaPublicInfo), false, !isPrivate);
}
linearLayoutTypeContainer.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell1.setOnClickListener(v -> {
if (!isPrivate) {
return;
}
isPrivate = false;
updatePrivatePublic();
});
sectionCell2 = new ShadowSectionCell(context);
linearLayout.addView(sectionCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (isForcePublic) {
radioButtonCell2.setVisibility(View.GONE);
radioButtonCell1.setVisibility(View.GONE);
sectionCell2.setVisibility(View.GONE);
headerCell2.setVisibility(View.GONE);
}
linkContainer = new LinearLayout(context);
linkContainer.setOrientation(LinearLayout.VERTICAL);
linkContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
headerCell = new HeaderCell(context, 23);
linkContainer.addView(headerCell);
publicContainer = new LinearLayout(context);
publicContainer.setOrientation(LinearLayout.HORIZONTAL);
linkContainer.addView(publicContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 23, 7, 23, 0));
editText = new EditTextBoldCursor(context);
editText.setText(getMessagesController().linkPrefix + "/");
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
editText.setMaxLines(1);
editText.setLines(1);
editText.setEnabled(false);
editText.setBackgroundDrawable(null);
editText.setPadding(0, 0, 0, 0);
editText.setSingleLine(true);
editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36));
usernameTextView = new EditTextBoldCursor(context);
usernameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
usernameTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
usernameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
usernameTextView.setMaxLines(1);
usernameTextView.setLines(1);
usernameTextView.setBackgroundDrawable(null);
usernameTextView.setPadding(0, 0, 0, 0);
usernameTextView.setSingleLine(true);
usernameTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
usernameTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
usernameTextView.setHint(LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder));
usernameTextView.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
usernameTextView.setCursorSize(AndroidUtilities.dp(20));
usernameTextView.setCursorWidth(1.5f);
publicContainer.addView(usernameTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36));
usernameTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
if (ignoreTextChanges) {
return;
}
checkUserName(usernameTextView.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
checkDoneButton();
}
});
privateContainer = new LinearLayout(context);
privateContainer.setOrientation(LinearLayout.VERTICAL);
linkContainer.addView(privateContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
permanentLinkView = new LinkActionView(context, this, null, chatId, true, ChatObject.isChannel(currentChat));
permanentLinkView.setDelegate(new LinkActionView.Delegate() {
@Override
public void revokeLink() {
ChatEditTypeActivity.this.generateLink(true);
}
@Override
public void showUsersForPermanentLink() {
inviteLinkBottomSheet = new InviteLinkBottomSheet(context, invite, info, usersMap, ChatEditTypeActivity.this, chatId, true, ChatObject.isChannel(currentChat));
inviteLinkBottomSheet.show();
}
});
permanentLinkView.setUsers(0, null);
privateContainer.addView(permanentLinkView);
checkTextView = new TextInfoPrivacyCell(context);
checkTextView.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
checkTextView.setBottomPadding(6);
linearLayout.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
typeInfoCell = new TextInfoPrivacyCell(context);
linearLayout.addView(typeInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
loadingAdminedCell = new LoadingCell(context);
linearLayout.addView(loadingAdminedCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
adminnedChannelsLayout = new LinearLayout(context);
adminnedChannelsLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
adminnedChannelsLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(adminnedChannelsLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
adminedInfoCell = new ShadowSectionCell(context);
linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
manageLinksTextView = new TextCell(context);
manageLinksTextView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
manageLinksTextView.setTextAndIcon(LocaleController.getString("ManageInviteLinks", R.string.ManageInviteLinks), R.drawable.actions_link, false);
manageLinksTextView.setOnClickListener(v -> {
ManageLinksActivity fragment = new ManageLinksActivity(chatId, 0, 0);
fragment.setInfo(info, invite);
presentFragment(fragment);
});
linearLayout.addView(manageLinksTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
manageLinksInfoCell = new TextInfoPrivacyCell(context);
linearLayout.addView(manageLinksInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
saveContainer = new LinearLayout(context);
saveContainer.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(saveContainer);
saveHeaderCell = new HeaderCell(context, 23);
saveHeaderCell.setHeight(46);
saveHeaderCell.setText(LocaleController.getString("SavingContentTitle", R.string.SavingContentTitle));
saveHeaderCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
saveContainer.addView(saveHeaderCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
saveRestrictCell = new TextCheckCell(context);
saveRestrictCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
saveRestrictCell.setTextAndCheck(LocaleController.getString("RestrictSavingContent", R.string.RestrictSavingContent), isSaveRestricted, false);
saveRestrictCell.setOnClickListener(v -> {
isSaveRestricted = !isSaveRestricted;
((TextCheckCell) v).setChecked(isSaveRestricted);
});
saveContainer.addView(saveRestrictCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
saveRestrictInfoCell = new TextInfoPrivacyCell(context);
if (isChannel && !ChatObject.isMegagroup(currentChat)) {
saveRestrictInfoCell.setText(LocaleController.getString("RestrictSavingContentInfoChannel", R.string.RestrictSavingContentInfoChannel));
} else {
saveRestrictInfoCell.setText(LocaleController.getString("RestrictSavingContentInfoGroup", R.string.RestrictSavingContentInfoGroup));
}
saveContainer.addView(saveRestrictInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
if (!isPrivate && currentChat.username != null) {
ignoreTextChanges = true;
usernameTextView.setText(currentChat.username);
usernameTextView.setSelection(currentChat.username.length());
ignoreTextChanges = false;
}
updatePrivatePublic();
return fragmentView;
}
use of org.telegram.ui.Cells.RadioButtonCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChannelCreateActivity method createView.
@Override
public View createView(Context context) {
if (nameTextView != null) {
nameTextView.onDestroy();
}
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
if (currentStep == 0) {
if (donePressed || getParentActivity() == null) {
return;
}
if (nameTextView.length() == 0) {
Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(200);
}
AndroidUtilities.shakeView(nameTextView, 2, 0);
return;
}
donePressed = true;
if (imageUpdater.isUploadingImage()) {
createAfterUpload = true;
progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setOnCancelListener(dialog -> {
createAfterUpload = false;
progressDialog = null;
donePressed = false;
});
progressDialog.show();
return;
}
final int reqId = MessagesController.getInstance(currentAccount).createChat(nameTextView.getText().toString(), new ArrayList<>(), descriptionTextView.getText().toString(), ChatObject.CHAT_TYPE_CHANNEL, false, null, null, ChannelCreateActivity.this);
progressDialog = new AlertDialog(getParentActivity(), 3);
progressDialog.setOnCancelListener(dialog -> {
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
donePressed = false;
});
progressDialog.show();
} else if (currentStep == 1) {
if (!isPrivate) {
if (descriptionTextView.length() == 0) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("ChannelPublicEmptyUsernameTitle", R.string.ChannelPublicEmptyUsernameTitle));
builder.setMessage(LocaleController.getString("ChannelPublicEmptyUsername", R.string.ChannelPublicEmptyUsername));
builder.setPositiveButton(LocaleController.getString("Close", R.string.Close), null);
showDialog(builder.create());
return;
} else {
if (!lastNameAvailable) {
Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(200);
}
AndroidUtilities.shakeView(checkTextView, 2, 0);
return;
} else {
MessagesController.getInstance(currentAccount).updateChannelUserName(chatId, lastCheckName);
}
}
}
Bundle args = new Bundle();
args.putInt("step", 2);
args.putLong("chatId", chatId);
args.putInt("chatType", ChatObject.CHAT_TYPE_CHANNEL);
presentFragment(new GroupCreateActivity(args), true);
}
}
}
});
ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
if (currentStep == 0) {
actionBar.setTitle(LocaleController.getString("NewChannel", R.string.NewChannel));
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
private boolean ignoreLayout;
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int keyboardSize = measureKeyboardHeight();
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
nameTextView.hideEmojiView();
ignoreLayout = false;
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child == null || child.getVisibility() == GONE || child == actionBar) {
continue;
}
if (nameTextView != null && nameTextView.isPopupView(child)) {
if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
if (AndroidUtilities.isTablet()) {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
}
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
}
} else {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
}
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
int keyboardSize = measureKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? nameTextView.getEmojiPadding() : 0;
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int width = child.getMeasuredWidth();
final int height = child.getMeasuredHeight();
int childLeft;
int childTop;
int gravity = lp.gravity;
if (gravity == -1) {
gravity = Gravity.TOP | Gravity.LEFT;
}
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
switch(absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
break;
case Gravity.RIGHT:
childLeft = r - width - lp.rightMargin;
break;
case Gravity.LEFT:
default:
childLeft = lp.leftMargin;
}
switch(verticalGravity) {
case Gravity.TOP:
childTop = lp.topMargin + getPaddingTop();
break;
case Gravity.CENTER_VERTICAL:
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
break;
default:
childTop = lp.topMargin;
}
if (nameTextView != null && nameTextView.isPopupView(child)) {
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
}
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
notifyHeightChanged();
}
@Override
public void requestLayout() {
if (ignoreLayout) {
return;
}
super.requestLayout();
}
};
sizeNotifierFrameLayout.setOnTouchListener((v, event) -> true);
fragmentView = sizeNotifierFrameLayout;
fragmentView.setTag(Theme.key_windowBackgroundWhite);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
sizeNotifierFrameLayout.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
FrameLayout frameLayout = new FrameLayout(context);
linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
avatarImage = new BackupImageView(context) {
@Override
public void invalidate() {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate();
}
@Override
public void invalidate(int l, int t, int r, int b) {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate(l, t, r, b);
}
};
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable.setInfo(5, null, null);
avatarImage.setImageDrawable(avatarDrawable);
frameLayout.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0x55000000);
avatarOverlay = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
if (avatarImage != null && avatarImage.getImageReceiver().hasNotThumb()) {
paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha()));
canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
}
}
};
frameLayout.addView(avatarOverlay, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
avatarOverlay.setOnClickListener(view -> {
imageUpdater.openMenu(avatar != null, () -> {
avatar = null;
avatarBig = null;
inputPhoto = null;
inputVideo = null;
inputVideoPath = null;
videoTimestamp = 0;
showAvatarProgress(false, true);
avatarImage.setImage(null, null, avatarDrawable, null);
avatarEditor.setAnimation(cameraDrawable);
cameraDrawable.setCurrentFrame(0);
}, dialog -> {
if (!imageUpdater.isUploadingImage()) {
cameraDrawable.setCustomEndFrame(86);
avatarEditor.playAnimation();
} else {
cameraDrawable.setCurrentFrame(0, false);
}
});
cameraDrawable.setCurrentFrame(0);
cameraDrawable.setCustomEndFrame(43);
avatarEditor.playAnimation();
});
cameraDrawable = new RLottieDrawable(R.raw.camera, "" + R.raw.camera, AndroidUtilities.dp(60), AndroidUtilities.dp(60), false, null);
avatarEditor = new RLottieImageView(context) {
@Override
public void invalidate(int l, int t, int r, int b) {
super.invalidate(l, t, r, b);
avatarOverlay.invalidate();
}
@Override
public void invalidate() {
super.invalidate();
avatarOverlay.invalidate();
}
};
avatarEditor.setScaleType(ImageView.ScaleType.CENTER);
avatarEditor.setAnimation(cameraDrawable);
avatarEditor.setEnabled(false);
avatarEditor.setClickable(false);
avatarEditor.setPadding(AndroidUtilities.dp(2), 0, 0, AndroidUtilities.dp(1));
frameLayout.addView(avatarEditor, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
avatarProgressView = new RadialProgressView(context);
avatarProgressView.setSize(AndroidUtilities.dp(30));
avatarProgressView.setProgressColor(0xffffffff);
avatarProgressView.setNoProgress(false);
frameLayout.addView(avatarProgressView, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 12, LocaleController.isRTL ? 16 : 0, 12));
showAvatarProgress(false, false);
nameTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, this, EditTextEmoji.STYLE_FRAGMENT);
nameTextView.setHint(LocaleController.getString("EnterChannelName", R.string.EnterChannelName));
if (nameToSet != null) {
nameTextView.setText(nameToSet);
nameToSet = null;
}
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(100);
nameTextView.setFilters(inputFilters);
nameTextView.getEditText().setSingleLine(true);
nameTextView.getEditText().setImeOptions(EditorInfo.IME_ACTION_NEXT);
nameTextView.getEditText().setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_NEXT && !TextUtils.isEmpty(nameTextView.getEditText().getText())) {
descriptionTextView.requestFocus();
return true;
}
return false;
});
frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 5 : 96, 0, LocaleController.isRTL ? 96 : 5, 0));
descriptionTextView = new EditTextBoldCursor(context);
descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
descriptionTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
descriptionTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
descriptionTextView.setPadding(0, 0, 0, AndroidUtilities.dp(6));
descriptionTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
descriptionTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(120);
descriptionTextView.setFilters(inputFilters);
descriptionTextView.setHint(LocaleController.getString("DescriptionPlaceholder", R.string.DescriptionPlaceholder));
descriptionTextView.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setCursorSize(AndroidUtilities.dp(20));
descriptionTextView.setCursorWidth(1.5f);
linearLayout.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 24, 18, 24, 0));
descriptionTextView.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_DONE && doneButton != null) {
doneButton.performClick();
return true;
}
return false;
});
descriptionTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
}
});
helpTextView = new TextView(context);
helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
helpTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText8));
helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
helpTextView.setText(LocaleController.getString("DescriptionInfo", R.string.DescriptionInfo));
linearLayout.addView(helpTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 24, 10, 24, 20));
} else if (currentStep == 1) {
fragmentView = new ScrollView(context);
ScrollView scrollView = (ScrollView) fragmentView;
scrollView.setFillViewport(true);
linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
scrollView.addView(linearLayout, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
actionBar.setTitle(LocaleController.getString("ChannelSettingsTitle", R.string.ChannelSettingsTitle));
fragmentView.setTag(Theme.key_windowBackgroundGray);
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
headerCell2 = new HeaderCell(context, 23);
headerCell2.setHeight(46);
headerCell2.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
headerCell2.setText(LocaleController.getString("ChannelTypeHeader", R.string.ChannelTypeHeader));
linearLayout.addView(headerCell2);
linearLayout2 = new LinearLayout(context);
linearLayout2.setOrientation(LinearLayout.VERTICAL);
linearLayout2.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout.addView(linearLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell1 = new RadioButtonCell(context);
radioButtonCell1.setBackgroundDrawable(Theme.getSelectorDrawable(false));
radioButtonCell1.setTextAndValue(LocaleController.getString("ChannelPublic", R.string.ChannelPublic), LocaleController.getString("ChannelPublicInfo", R.string.ChannelPublicInfo), false, !isPrivate);
linearLayout2.addView(radioButtonCell1, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell1.setOnClickListener(v -> {
if (!isPrivate) {
return;
}
isPrivate = false;
updatePrivatePublic();
});
radioButtonCell2 = new RadioButtonCell(context);
radioButtonCell2.setBackgroundDrawable(Theme.getSelectorDrawable(false));
radioButtonCell2.setTextAndValue(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate), LocaleController.getString("ChannelPrivateInfo", R.string.ChannelPrivateInfo), false, isPrivate);
linearLayout2.addView(radioButtonCell2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
radioButtonCell2.setOnClickListener(v -> {
if (isPrivate) {
return;
}
isPrivate = true;
updatePrivatePublic();
});
sectionCell = new ShadowSectionCell(context);
linearLayout.addView(sectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
linkContainer = new LinearLayout(context);
linkContainer.setOrientation(LinearLayout.VERTICAL);
linkContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
linearLayout.addView(linkContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
headerCell = new HeaderCell(context);
linkContainer.addView(headerCell);
publicContainer = new LinearLayout(context);
publicContainer.setOrientation(LinearLayout.HORIZONTAL);
linkContainer.addView(publicContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 17, 7, 17, 0));
editText = new EditTextBoldCursor(context);
editText.setText(MessagesController.getInstance(currentAccount).linkPrefix + "/");
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
editText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
editText.setMaxLines(1);
editText.setLines(1);
editText.setEnabled(false);
editText.setBackgroundDrawable(null);
editText.setPadding(0, 0, 0, 0);
editText.setSingleLine(true);
editText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
publicContainer.addView(editText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36));
descriptionTextView = new EditTextBoldCursor(context);
descriptionTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
descriptionTextView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
descriptionTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setMaxLines(1);
descriptionTextView.setLines(1);
descriptionTextView.setBackgroundDrawable(null);
descriptionTextView.setPadding(0, 0, 0, 0);
descriptionTextView.setSingleLine(true);
descriptionTextView.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
descriptionTextView.setImeOptions(EditorInfo.IME_ACTION_DONE);
descriptionTextView.setHint(LocaleController.getString("ChannelUsernamePlaceholder", R.string.ChannelUsernamePlaceholder));
descriptionTextView.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
descriptionTextView.setCursorSize(AndroidUtilities.dp(20));
descriptionTextView.setCursorWidth(1.5f);
publicContainer.addView(descriptionTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36));
descriptionTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
checkUserName(descriptionTextView.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
privateContainer = new LinearLayout(context);
privateContainer.setOrientation(LinearLayout.VERTICAL);
linkContainer.addView(privateContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
permanentLinkView = new LinkActionView(context, this, null, chatId, true, ChatObject.isChannel(getMessagesController().getChat(chatId)));
// permanentLinkView.showOptions(false);
permanentLinkView.hideRevokeOption(true);
permanentLinkView.setUsers(0, null);
privateContainer.addView(permanentLinkView);
checkTextView = new TextView(context);
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
checkTextView.setVisibility(View.GONE);
linkContainer.addView(checkTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 17, 3, 17, 7));
typeInfoCell = new TextInfoPrivacyCell(context);
typeInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout.addView(typeInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
loadingAdminedCell = new LoadingCell(context);
linearLayout.addView(loadingAdminedCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
adminnedChannelsLayout = new LinearLayout(context);
adminnedChannelsLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
adminnedChannelsLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(adminnedChannelsLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
adminedInfoCell = new TextInfoPrivacyCell(context);
adminedInfoCell.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
linearLayout.addView(adminedInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
updatePrivatePublic();
}
return fragmentView;
}
Aggregations