use of org.telegram.ui.Components.GroupCreateDividerItemDecoration in project Telegram-FOSS by Telegram-FOSS-Team.
the class InviteContactsActivity method createView.
@Override
public View createView(Context context) {
searching = false;
searchWas = false;
allSpans.clear();
selectedContacts.clear();
currentDeletingSpan = null;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("InviteFriends", R.string.InviteFriends));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
fragmentView = new ViewGroup(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(width, height);
int maxSize;
if (AndroidUtilities.isTablet() || height > width) {
maxSize = AndroidUtilities.dp(144);
} else {
maxSize = AndroidUtilities.dp(56);
}
int h;
infoTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
counterView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
if (infoTextView.getVisibility() == VISIBLE) {
h = infoTextView.getMeasuredHeight();
} else {
h = counterView.getMeasuredHeight();
}
scrollView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
listView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight() - h, MeasureSpec.EXACTLY));
emptyView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight() - AndroidUtilities.dp(72), MeasureSpec.EXACTLY));
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
scrollView.layout(0, 0, scrollView.getMeasuredWidth(), scrollView.getMeasuredHeight());
listView.layout(0, scrollView.getMeasuredHeight(), listView.getMeasuredWidth(), scrollView.getMeasuredHeight() + listView.getMeasuredHeight());
emptyView.layout(0, scrollView.getMeasuredHeight() + AndroidUtilities.dp(72), emptyView.getMeasuredWidth(), scrollView.getMeasuredHeight() + emptyView.getMeasuredHeight());
int y = bottom - top - infoTextView.getMeasuredHeight();
infoTextView.layout(0, y, infoTextView.getMeasuredWidth(), y + infoTextView.getMeasuredHeight());
y = bottom - top - counterView.getMeasuredHeight();
counterView.layout(0, y, counterView.getMeasuredWidth(), y + counterView.getMeasuredHeight());
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
if (child == listView || child == emptyView) {
parentLayout.drawHeaderShadow(canvas, scrollView.getMeasuredHeight());
}
return result;
}
};
ViewGroup frameLayout = (ViewGroup) fragmentView;
scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
if (ignoreScrollEvent) {
ignoreScrollEvent = false;
return false;
}
rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
rectangle.top += fieldY + AndroidUtilities.dp(20);
rectangle.bottom += fieldY + AndroidUtilities.dp(50);
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
};
scrollView.setVerticalScrollBarEnabled(false);
AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_windowBackgroundWhite));
frameLayout.addView(scrollView);
spansContainer = new SpansContainer(context);
scrollView.addView(spansContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
editText = new EditTextBoldCursor(context) {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (currentDeletingSpan != null) {
currentDeletingSpan.cancelDeleteAnimation();
currentDeletingSpan = null;
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (!AndroidUtilities.showKeyboard(this)) {
clearFocus();
requestFocus();
}
}
return super.onTouchEvent(event);
}
};
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
editText.setHintColor(Theme.getColor(Theme.key_groupcreate_hintText));
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
editText.setCursorColor(Theme.getColor(Theme.key_groupcreate_cursor));
editText.setCursorWidth(1.5f);
editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editText.setSingleLine(true);
editText.setBackgroundDrawable(null);
editText.setVerticalScrollBarEnabled(false);
editText.setHorizontalScrollBarEnabled(false);
editText.setTextIsSelectable(false);
editText.setPadding(0, 0, 0, 0);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
editText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
spansContainer.addView(editText);
editText.setHintText(LocaleController.getString("SearchFriends", R.string.SearchFriends));
editText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
/*editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
return actionId == EditorInfo.IME_ACTION_DONE && onDonePressed();
}
});*/
editText.setOnKeyListener(new View.OnKeyListener() {
private boolean wasEmpty;
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
wasEmpty = editText.length() == 0;
} else if (event.getAction() == KeyEvent.ACTION_UP && wasEmpty && !allSpans.isEmpty()) {
spansContainer.removeSpan(allSpans.get(allSpans.size() - 1));
updateHint();
checkVisibleRows();
return true;
}
return false;
}
});
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editText.length() != 0) {
searching = true;
searchWas = true;
adapter.setSearching(true);
adapter.searchDialogs(editText.getText().toString());
listView.setFastScrollVisible(false);
listView.setVerticalScrollBarEnabled(true);
emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
} else {
closeSearch();
}
}
});
emptyView = new EmptyTextProgressView(context);
if (ContactsController.getInstance(currentAccount).isLoadingContacts()) {
emptyView.showProgress();
} else {
emptyView.showTextView();
}
emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
frameLayout.addView(emptyView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
listView = new RecyclerListView(context);
listView.setEmptyView(emptyView);
listView.setAdapter(adapter = new InviteAdapter(context));
listView.setLayoutManager(linearLayoutManager);
listView.setVerticalScrollBarEnabled(true);
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
listView.addItemDecoration(decoration = new GroupCreateDividerItemDecoration());
frameLayout.addView(listView);
listView.setOnItemClickListener((view, position) -> {
if (position == 0 && !searching) {
try {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String text = ContactsController.getInstance(currentAccount).getInviteText(0);
intent.putExtra(Intent.EXTRA_TEXT, text);
getParentActivity().startActivityForResult(Intent.createChooser(intent, text), 500);
} catch (Exception e) {
FileLog.e(e);
}
return;
}
if (!(view instanceof InviteUserCell)) {
return;
}
InviteUserCell cell = (InviteUserCell) view;
ContactsController.Contact contact = cell.getContact();
if (contact == null) {
return;
}
boolean exists;
if (exists = selectedContacts.containsKey(contact.key)) {
GroupCreateSpan span = selectedContacts.get(contact.key);
spansContainer.removeSpan(span);
} else {
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), contact);
spansContainer.addSpan(span);
span.setOnClickListener(InviteContactsActivity.this);
}
updateHint();
if (searching || searchWas) {
AndroidUtilities.showKeyboard(editText);
} else {
cell.setChecked(!exists, true);
}
if (editText.length() > 0) {
editText.setText(null);
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(editText);
}
}
});
infoTextView = new TextView(context);
infoTextView.setBackgroundColor(Theme.getColor(Theme.key_contacts_inviteBackground));
infoTextView.setTextColor(Theme.getColor(Theme.key_contacts_inviteText));
infoTextView.setGravity(Gravity.CENTER);
infoTextView.setText(LocaleController.getString("InviteFriendsHelp", R.string.InviteFriendsHelp));
infoTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
infoTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
infoTextView.setPadding(AndroidUtilities.dp(17), AndroidUtilities.dp(9), AndroidUtilities.dp(17), AndroidUtilities.dp(9));
frameLayout.addView(infoTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
counterView = new FrameLayout(context);
counterView.setBackgroundColor(Theme.getColor(Theme.key_contacts_inviteBackground));
counterView.setVisibility(View.INVISIBLE);
frameLayout.addView(counterView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
counterView.setOnClickListener(v -> {
try {
StringBuilder builder = new StringBuilder();
int num = 0;
for (int a = 0; a < allSpans.size(); a++) {
ContactsController.Contact contact = allSpans.get(a).getContact();
if (builder.length() != 0) {
builder.append(';');
}
builder.append(contact.phones.get(0));
if (a == 0 && allSpans.size() == 1) {
num = contact.imported;
}
}
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + builder.toString()));
intent.putExtra("sms_body", ContactsController.getInstance(currentAccount).getInviteText(num));
getParentActivity().startActivityForResult(intent, 500);
} catch (Exception e) {
FileLog.e(e);
}
finishFragment();
});
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
counterView.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));
counterTextView = new TextView(context);
counterTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
counterTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
counterTextView.setTextColor(Theme.getColor(Theme.key_contacts_inviteBackground));
counterTextView.setGravity(Gravity.CENTER);
counterTextView.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(10), Theme.getColor(Theme.key_contacts_inviteText)));
counterTextView.setMinWidth(AndroidUtilities.dp(20));
counterTextView.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), AndroidUtilities.dp(1));
linearLayout.addView(counterTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 20, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));
textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setTextColor(Theme.getColor(Theme.key_contacts_inviteText));
textView.setGravity(Gravity.CENTER);
textView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
textView.setText(LocaleController.getString("InviteToTelegram", R.string.InviteToTelegram).toUpperCase());
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));
updateHint();
adapter.notifyDataSetChanged();
return fragmentView;
}
use of org.telegram.ui.Components.GroupCreateDividerItemDecoration in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCreateActivity method createView.
@Override
public View createView(Context context) {
searching = false;
searchWas = false;
allSpans.clear();
selectedContacts.clear();
currentDeletingSpan = null;
doneButtonVisible = chatType == ChatObject.CHAT_TYPE_CHANNEL;
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
if (chatType == ChatObject.CHAT_TYPE_CHANNEL) {
actionBar.setTitle(LocaleController.getString("ChannelAddSubscribers", R.string.ChannelAddSubscribers));
} else {
if (addToGroup) {
if (channelId != 0) {
actionBar.setTitle(LocaleController.getString("ChannelAddSubscribers", R.string.ChannelAddSubscribers));
} else {
actionBar.setTitle(LocaleController.getString("GroupAddMembers", R.string.GroupAddMembers));
}
} else if (isAlwaysShare) {
if (chatAddType == 2) {
actionBar.setTitle(LocaleController.getString("FilterAlwaysShow", R.string.FilterAlwaysShow));
} else if (chatAddType == 1) {
actionBar.setTitle(LocaleController.getString("AlwaysAllow", R.string.AlwaysAllow));
} else {
actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
}
} else if (isNeverShare) {
if (chatAddType == 2) {
actionBar.setTitle(LocaleController.getString("FilterNeverShow", R.string.FilterNeverShow));
} else if (chatAddType == 1) {
actionBar.setTitle(LocaleController.getString("NeverAllow", R.string.NeverAllow));
} else {
actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
}
} else {
actionBar.setTitle(chatType == ChatObject.CHAT_TYPE_CHAT ? LocaleController.getString("NewGroup", R.string.NewGroup) : LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
}
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == done_button) {
onDonePressed(true);
}
}
});
fragmentView = new ViewGroup(context) {
private VerticalPositionAutoAnimator verticalPositionAutoAnimator;
@Override
public void onViewAdded(View child) {
if (child == floatingButton && verticalPositionAutoAnimator == null) {
verticalPositionAutoAnimator = VerticalPositionAutoAnimator.attach(child);
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (verticalPositionAutoAnimator != null) {
verticalPositionAutoAnimator.ignoreNextLayout();
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(width, height);
if (AndroidUtilities.isTablet() || height > width) {
maxSize = AndroidUtilities.dp(144);
} else {
maxSize = AndroidUtilities.dp(56);
}
scrollView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(maxSize, MeasureSpec.AT_MOST));
listView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight(), MeasureSpec.EXACTLY));
emptyView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height - scrollView.getMeasuredHeight(), MeasureSpec.EXACTLY));
if (floatingButton != null) {
int w = AndroidUtilities.dp(Build.VERSION.SDK_INT >= 21 ? 56 : 60);
floatingButton.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY));
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
scrollView.layout(0, 0, scrollView.getMeasuredWidth(), scrollView.getMeasuredHeight());
listView.layout(0, scrollView.getMeasuredHeight(), listView.getMeasuredWidth(), scrollView.getMeasuredHeight() + listView.getMeasuredHeight());
emptyView.layout(0, scrollView.getMeasuredHeight(), emptyView.getMeasuredWidth(), scrollView.getMeasuredHeight() + emptyView.getMeasuredHeight());
if (floatingButton != null) {
int l = LocaleController.isRTL ? AndroidUtilities.dp(14) : (right - left) - AndroidUtilities.dp(14) - floatingButton.getMeasuredWidth();
int t = bottom - top - AndroidUtilities.dp(14) - floatingButton.getMeasuredHeight();
floatingButton.layout(l, t, l + floatingButton.getMeasuredWidth(), t + floatingButton.getMeasuredHeight());
}
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
parentLayout.drawHeaderShadow(canvas, Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight));
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if (child == listView) {
canvas.save();
canvas.clipRect(child.getLeft(), Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight), child.getRight(), child.getBottom());
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restore();
return result;
} else if (child == scrollView) {
canvas.save();
canvas.clipRect(child.getLeft(), child.getTop(), child.getRight(), Math.min(maxSize, measuredContainerHeight + containerHeight - measuredContainerHeight));
boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restore();
return result;
} else {
return super.drawChild(canvas, child, drawingTime);
}
}
};
ViewGroup frameLayout = (ViewGroup) fragmentView;
frameLayout.setFocusableInTouchMode(true);
frameLayout.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
if (ignoreScrollEvent) {
ignoreScrollEvent = false;
return false;
}
rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY());
rectangle.top += fieldY + AndroidUtilities.dp(20);
rectangle.bottom += fieldY + AndroidUtilities.dp(50);
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
};
scrollView.setClipChildren(false);
frameLayout.setClipChildren(false);
scrollView.setVerticalScrollBarEnabled(false);
AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_windowBackgroundWhite));
frameLayout.addView(scrollView);
spansContainer = new SpansContainer(context);
scrollView.addView(spansContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
spansContainer.setOnClickListener(v -> {
editText.clearFocus();
editText.requestFocus();
AndroidUtilities.showKeyboard(editText);
});
editText = new EditTextBoldCursor(context) {
@Override
public boolean onTouchEvent(MotionEvent event) {
if (currentDeletingSpan != null) {
currentDeletingSpan.cancelDeleteAnimation();
currentDeletingSpan = null;
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (!AndroidUtilities.showKeyboard(this)) {
clearFocus();
requestFocus();
}
}
return super.onTouchEvent(event);
}
};
editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
editText.setHintColor(Theme.getColor(Theme.key_groupcreate_hintText));
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
editText.setCursorColor(Theme.getColor(Theme.key_groupcreate_cursor));
editText.setCursorWidth(1.5f);
editText.setInputType(InputType.TYPE_TEXT_VARIATION_FILTER | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
editText.setSingleLine(true);
editText.setBackgroundDrawable(null);
editText.setVerticalScrollBarEnabled(false);
editText.setHorizontalScrollBarEnabled(false);
editText.setTextIsSelectable(false);
editText.setPadding(0, 0, 0, 0);
editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
editText.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
spansContainer.addView(editText);
updateEditTextHint();
editText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
public void onDestroyActionMode(ActionMode mode) {
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
editText.setOnEditorActionListener((v, actionId, event) -> actionId == EditorInfo.IME_ACTION_DONE && onDonePressed(true));
editText.setOnKeyListener(new View.OnKeyListener() {
private boolean wasEmpty;
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DEL) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
wasEmpty = editText.length() == 0;
} else if (event.getAction() == KeyEvent.ACTION_UP && wasEmpty && !allSpans.isEmpty()) {
spansContainer.removeSpan(allSpans.get(allSpans.size() - 1));
updateHint();
checkVisibleRows();
return true;
}
}
return false;
}
});
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void afterTextChanged(Editable editable) {
if (editText.length() != 0) {
if (!adapter.searching) {
searching = true;
searchWas = true;
adapter.setSearching(true);
itemDecoration.setSearching(true);
listView.setFastScrollVisible(false);
listView.setVerticalScrollBarEnabled(true);
}
adapter.searchDialogs(editText.getText().toString());
emptyView.showProgress(true, false);
} else {
closeSearch();
}
}
});
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(context);
flickerLoadingView.setViewType(FlickerLoadingView.USERS_TYPE);
flickerLoadingView.showDate(false);
emptyView = new StickerEmptyView(context, flickerLoadingView, StickerEmptyView.STICKER_TYPE_SEARCH);
emptyView.addView(flickerLoadingView);
emptyView.showProgress(true, false);
emptyView.title.setText(LocaleController.getString("NoResult", R.string.NoResult));
frameLayout.addView(emptyView);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
listView = new RecyclerListView(context);
listView.setFastScrollEnabled(RecyclerListView.FastScroll.LETTER_TYPE);
listView.setEmptyView(emptyView);
listView.setAdapter(adapter = new GroupCreateAdapter(context));
listView.setLayoutManager(linearLayoutManager);
listView.setVerticalScrollBarEnabled(false);
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
listView.addItemDecoration(itemDecoration = new GroupCreateDividerItemDecoration());
frameLayout.addView(listView);
listView.setOnItemClickListener((view, position) -> {
if (position == 0 && adapter.inviteViaLink != 0 && !adapter.searching) {
sharedLinkBottomSheet = new PermanentLinkBottomSheet(context, false, this, info, chatId, channelId != 0);
showDialog(sharedLinkBottomSheet);
} else if (view instanceof GroupCreateUserCell) {
GroupCreateUserCell cell = (GroupCreateUserCell) view;
Object object = cell.getObject();
long id;
if (object instanceof TLRPC.User) {
id = ((TLRPC.User) object).id;
} else if (object instanceof TLRPC.Chat) {
id = -((TLRPC.Chat) object).id;
} else {
return;
}
if (ignoreUsers != null && ignoreUsers.indexOfKey(id) >= 0) {
return;
}
boolean exists;
if (exists = selectedContacts.indexOfKey(id) >= 0) {
GroupCreateSpan span = selectedContacts.get(id);
spansContainer.removeSpan(span);
} else {
if (maxCount != 0 && selectedContacts.size() == maxCount) {
return;
}
if (chatType == ChatObject.CHAT_TYPE_CHAT && selectedContacts.size() == getMessagesController().maxGroupCount) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("SoftUserLimitAlert", R.string.SoftUserLimitAlert));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showDialog(builder.create());
return;
}
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
if (addToGroup && user.bot) {
if (channelId == 0 && user.bot_nochats) {
try {
BulletinFactory.of(this).createErrorBulletin(LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups)).show();
} catch (Exception e) {
FileLog.e(e);
}
return;
}
if (channelId != 0) {
TLRPC.Chat chat = getMessagesController().getChat(channelId);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
if (ChatObject.canAddAdmins(chat)) {
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setMessage(LocaleController.getString("AddBotAsAdmin", R.string.AddBotAsAdmin));
builder.setPositiveButton(LocaleController.getString("MakeAdmin", R.string.MakeAdmin), (dialogInterface, i) -> {
delegate2.needAddBot(user);
if (editText.length() > 0) {
editText.setText(null);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
} else {
builder.setMessage(LocaleController.getString("CantAddBotAsAdmin", R.string.CantAddBotAsAdmin));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
}
showDialog(builder.create());
return;
}
}
getMessagesController().putUser(user, !searching);
} else {
TLRPC.Chat chat = (TLRPC.Chat) object;
getMessagesController().putChat(chat, !searching);
}
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
spansContainer.addSpan(span);
span.setOnClickListener(GroupCreateActivity.this);
}
updateHint();
if (searching || searchWas) {
AndroidUtilities.showKeyboard(editText);
} else {
cell.setChecked(!exists, true);
}
if (editText.length() > 0) {
editText.setText(null);
}
}
});
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
editText.hideActionMode();
AndroidUtilities.hideKeyboard(editText);
}
}
});
listView.setAnimateEmptyView(true, 0);
floatingButton = new ImageView(context);
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable;
}
floatingButton.setBackgroundDrawable(drawable);
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
if (isNeverShare || isAlwaysShare || addToGroup) {
floatingButton.setImageResource(R.drawable.floating_check);
} else {
BackDrawable backDrawable = new BackDrawable(false);
backDrawable.setArrowRotation(180);
floatingButton.setImageDrawable(backDrawable);
}
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
frameLayout.addView(floatingButton);
floatingButton.setOnClickListener(v -> onDonePressed(true));
if (chatType != ChatObject.CHAT_TYPE_CHANNEL) {
floatingButton.setVisibility(View.INVISIBLE);
floatingButton.setScaleX(0.0f);
floatingButton.setScaleY(0.0f);
floatingButton.setAlpha(0.0f);
}
floatingButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
updateHint();
return fragmentView;
}
use of org.telegram.ui.Components.GroupCreateDividerItemDecoration in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCreateFinalActivity method createView.
@Override
public View createView(Context context) {
if (editText != null) {
editText.onDestroy();
}
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
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;
editText.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 (editText != null && editText.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() ? editText.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 (editText != null && editText.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();
}
};
fragmentView = sizeNotifierFrameLayout;
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fragmentView.setOnTouchListener((v, event) -> true);
shadowDrawable = context.getResources().getDrawable(R.drawable.greydivider_top).mutate();
LinearLayout linearLayout = new LinearLayout(context) {
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
if (child == listView && shadowDrawable != null) {
int y = editTextContainer.getMeasuredHeight();
shadowDrawable.setBounds(0, y, getMeasuredWidth(), y + shadowDrawable.getIntrinsicHeight());
shadowDrawable.draw(canvas);
}
return result;
}
};
linearLayout.setOrientation(LinearLayout.VERTICAL);
sizeNotifierFrameLayout.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
editTextContainer = new FrameLayout(context);
linearLayout.addView(editTextContainer, 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);
avatarImage.setContentDescription(LocaleController.getString("ChoosePhoto", R.string.ChoosePhoto));
editTextContainer.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0x55000000);
avatarOverlay = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
if (avatarImage != null && avatarProgressView.getVisibility() == VISIBLE) {
paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha() * avatarProgressView.getAlpha()));
canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
}
}
};
editTextContainer.addView(avatarOverlay, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
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));
editTextContainer.addView(avatarEditor, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
avatarProgressView = new RadialProgressView(context) {
@Override
public void setAlpha(float alpha) {
super.setAlpha(alpha);
avatarOverlay.invalidate();
}
};
avatarProgressView.setSize(AndroidUtilities.dp(30));
avatarProgressView.setProgressColor(0xffffffff);
avatarProgressView.setNoProgress(false);
editTextContainer.addView(avatarProgressView, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
showAvatarProgress(false, false);
editText = new EditTextEmoji(context, sizeNotifierFrameLayout, this, EditTextEmoji.STYLE_FRAGMENT);
editText.setHint(chatType == ChatObject.CHAT_TYPE_CHAT || chatType == ChatObject.CHAT_TYPE_MEGAGROUP ? LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder) : LocaleController.getString("EnterListName", R.string.EnterListName));
if (nameToSet != null) {
editText.setText(nameToSet);
nameToSet = null;
}
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(100);
editText.setFilters(inputFilters);
editTextContainer.addView(editText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 5 : 96, 0, LocaleController.isRTL ? 96 : 5, 0));
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
listView = new RecyclerListView(context);
listView.setAdapter(adapter = new GroupCreateAdapter(context));
listView.setLayoutManager(linearLayoutManager);
listView.setVerticalScrollBarEnabled(false);
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
GroupCreateDividerItemDecoration decoration = new GroupCreateDividerItemDecoration();
decoration.setSkipRows(currentGroupCreateAddress != null ? 5 : 2);
listView.addItemDecoration(decoration);
linearLayout.addView(listView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(editText);
}
}
});
listView.setOnItemClickListener((view, position) -> {
if (view instanceof TextSettingsCell) {
if (!AndroidUtilities.isGoogleMapsInstalled(GroupCreateFinalActivity.this)) {
return;
}
LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP);
fragment.setDialogId(0);
fragment.setDelegate((location, live, notify, scheduleDate) -> {
currentGroupCreateLocation.setLatitude(location.geo.lat);
currentGroupCreateLocation.setLongitude(location.geo._long);
currentGroupCreateAddress = location.address;
});
presentFragment(fragment);
}
});
floatingButtonContainer = new FrameLayout(context);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable;
}
floatingButtonContainer.setBackgroundDrawable(drawable);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButtonContainer.setStateListAnimator(animator);
floatingButtonContainer.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
VerticalPositionAutoAnimator.attach(floatingButtonContainer);
sizeNotifierFrameLayout.addView(floatingButtonContainer, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));
floatingButtonContainer.setOnClickListener(view -> {
if (donePressed) {
return;
}
if (editText.length() == 0) {
Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(200);
}
AndroidUtilities.shakeView(editText, 2, 0);
return;
}
donePressed = true;
AndroidUtilities.hideKeyboard(editText);
editText.setEnabled(false);
if (imageUpdater.isUploadingImage()) {
createAfterUpload = true;
} else {
showEditDoneProgress(true);
reqId = getMessagesController().createChat(editText.getText().toString(), selectedContacts, null, chatType, forImport, currentGroupCreateLocation, currentGroupCreateAddress, GroupCreateFinalActivity.this);
}
});
floatingButtonIcon = new ImageView(context);
floatingButtonIcon.setScaleType(ImageView.ScaleType.CENTER);
floatingButtonIcon.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
floatingButtonIcon.setImageResource(R.drawable.checkbig);
floatingButtonIcon.setPadding(0, AndroidUtilities.dp(2), 0, 0);
floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
floatingButtonContainer.addView(floatingButtonIcon, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60));
progressView = new ContextProgressView(context, 1);
progressView.setAlpha(0.0f);
progressView.setScaleX(0.1f);
progressView.setScaleY(0.1f);
progressView.setVisibility(View.INVISIBLE);
floatingButtonContainer.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
return fragmentView;
}
Aggregations