use of org.telegram.ui.Cells.GroupCreateUserCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class TooManyCommunitiesActivity method getThemeDescriptions.
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(0);
}
}
}
if (searchListView != null) {
int count = searchListView.getChildCount();
for (int a = 0; a < count; a++) {
View child = searchListView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(0);
}
}
}
buttonTextView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
progressBar.setProgressColor(Theme.getColor(Theme.key_progressCircle));
};
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(hintCell, 0, new Class[] { TooManyCommunitiesHintCell.class }, new String[] { "imageView" }, null, null, null, Theme.key_chats_nameMessage_threeLines));
themeDescriptions.add(new ThemeDescription(hintCell, 0, new Class[] { TooManyCommunitiesHintCell.class }, new String[] { "headerTextView" }, null, null, null, Theme.key_chats_nameMessage_threeLines));
themeDescriptions.add(new ThemeDescription(hintCell, 0, new Class[] { TooManyCommunitiesHintCell.class }, new String[] { "messageTextView" }, null, null, null, Theme.key_chats_message));
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(buttonLayout, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ShadowSectionCell.class }, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[] { ShadowSectionCell.class }, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { HeaderCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "textView" }, null, null, null, Theme.key_groupcreate_sectionText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkbox));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxDisabled));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxCheck));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "nameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { GroupCreateUserCell.class }, new String[] { "statusTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { GroupCreateUserCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "textView" }, null, null, null, Theme.key_groupcreate_sectionText));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkbox));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxDisabled));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "checkBox" }, null, null, null, Theme.key_checkboxCheck));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "nameTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(searchListView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { GroupCreateUserCell.class }, new String[] { "statusTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
themeDescriptions.add(new ThemeDescription(searchListView, 0, new Class[] { GroupCreateUserCell.class }, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder));
themeDescriptions.add(new ThemeDescription(buttonTextView, 0, null, null, null, cellDelegate, Theme.key_featuredStickers_addButton));
themeDescriptions.add(new ThemeDescription(buttonTextView, 0, null, null, null, cellDelegate, Theme.key_featuredStickers_addButtonPressed));
themeDescriptions.add(new ThemeDescription(progressBar, 0, null, null, null, cellDelegate, Theme.key_featuredStickers_addButtonPressed));
themeDescriptions.add(new ThemeDescription(hintCell, 0, new Class[] { TooManyCommunitiesHintCell.class }, new String[] { "imageLayout" }, null, null, null, Theme.key_dialogRedIcon));
return themeDescriptions;
}
use of org.telegram.ui.Cells.GroupCreateUserCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class FilterUsersActivity 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);
if (isInclude) {
actionBar.setTitle(LocaleController.getString("FilterAlwaysShow", R.string.FilterAlwaysShow));
} else {
actionBar.setTitle(LocaleController.getString("FilterNeverShow", R.string.FilterNeverShow));
}
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) {
@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);
}
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 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));
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);
editText.setHintText(LocaleController.getString("SearchForPeopleAndGroups", R.string.SearchForPeopleAndGroups));
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()) {
GroupCreateSpan span = allSpans.get(allSpans.size() - 1);
spansContainer.removeSpan(span);
if (span.getUid() == Integer.MIN_VALUE) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else if (span.getUid() == Integer.MIN_VALUE + 1) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
} else if (span.getUid() == Integer.MIN_VALUE + 2) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_GROUPS;
} else if (span.getUid() == Integer.MIN_VALUE + 3) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else if (span.getUid() == Integer.MIN_VALUE + 4) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_BOTS;
} else if (span.getUid() == Integer.MIN_VALUE + 5) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
} else if (span.getUid() == Integer.MIN_VALUE + 6) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
} else if (span.getUid() == Integer.MIN_VALUE + 7) {
filterFlags &= ~MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
}
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);
listView.setFastScrollVisible(false);
listView.setVerticalScrollBarEnabled(true);
emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView.showProgress();
}
adapter.searchDialogs(editText.getText().toString());
} else {
closeSearch();
}
}
});
emptyView = new EmptyTextProgressView(context);
if (ContactsController.getInstance(currentAccount).isLoadingContacts()) {
emptyView.showProgress();
} else {
emptyView.showTextView();
}
emptyView.setShowAtCenter(true);
emptyView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
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(new ItemDecoration());
frameLayout.addView(listView);
listView.setOnItemClickListener((view, position) -> {
if (view instanceof GroupCreateUserCell) {
GroupCreateUserCell cell = (GroupCreateUserCell) view;
Object object = cell.getObject();
long id;
if (object instanceof String) {
int flag;
if (isInclude) {
if (position == 1) {
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
id = Integer.MIN_VALUE;
} else if (position == 2) {
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
id = Integer.MIN_VALUE + 1;
} else if (position == 3) {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
id = Integer.MIN_VALUE + 2;
} else if (position == 4) {
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
id = Integer.MIN_VALUE + 3;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
id = Integer.MIN_VALUE + 4;
}
} else {
if (position == 1) {
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
id = Integer.MIN_VALUE + 5;
} else if (position == 2) {
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
id = Integer.MIN_VALUE + 6;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
id = Integer.MIN_VALUE + 7;
}
}
if (cell.isChecked()) {
filterFlags &= ~flag;
} else {
filterFlags |= flag;
}
} else {
if (object instanceof TLRPC.User) {
id = ((TLRPC.User) object).id;
} else if (object instanceof TLRPC.Chat) {
id = -((TLRPC.Chat) object).id;
} else {
return;
}
}
boolean exists;
if (exists = selectedContacts.indexOfKey(id) >= 0) {
GroupCreateSpan span = selectedContacts.get(id);
spansContainer.removeSpan(span);
} else {
if (!(object instanceof String) && selectedCount >= 100) {
return;
}
if (object instanceof TLRPC.User) {
TLRPC.User user = (TLRPC.User) object;
MessagesController.getInstance(currentAccount).putUser(user, !searching);
} else if (object instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) object;
MessagesController.getInstance(currentAccount).putChat(chat, !searching);
}
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
spansContainer.addSpan(span, true);
span.setOnClickListener(FilterUsersActivity.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);
}
}
});
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));
floatingButton.setImageResource(R.drawable.floating_check);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] { android.R.attr.state_pressed }, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, 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));
/*floatingButton.setVisibility(View.INVISIBLE);
floatingButton.setScaleX(0.0f);
floatingButton.setScaleY(0.0f);
floatingButton.setAlpha(0.0f);*/
floatingButton.setContentDescription(LocaleController.getString("Next", R.string.Next));
for (int position = 1, N = (isInclude ? 5 : 3); position <= N; position++) {
int id;
int flag;
Object object;
if (isInclude) {
if (position == 1) {
object = "contacts";
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else if (position == 2) {
object = "non_contacts";
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
} else if (position == 3) {
object = "groups";
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
} else if (position == 4) {
object = "channels";
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else {
object = "bots";
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
}
} else {
if (position == 1) {
object = "muted";
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED;
} else if (position == 2) {
object = "read";
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_READ;
} else {
object = "archived";
flag = MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED;
}
}
if ((filterFlags & flag) != 0) {
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
spansContainer.addSpan(span, false);
span.setOnClickListener(FilterUsersActivity.this);
}
}
if (initialIds != null && !initialIds.isEmpty()) {
TLObject object;
for (int a = 0, N = initialIds.size(); a < N; a++) {
Long id = initialIds.get(a);
if (id > 0) {
object = getMessagesController().getUser(id);
} else {
object = getMessagesController().getChat(-id);
}
if (object == null) {
continue;
}
GroupCreateSpan span = new GroupCreateSpan(editText.getContext(), object);
spansContainer.addSpan(span, false);
span.setOnClickListener(FilterUsersActivity.this);
}
}
updateHint();
return fragmentView;
}
use of org.telegram.ui.Cells.GroupCreateUserCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCreateFinalActivity method getThemeDescriptions.
@Override
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(0);
}
}
}
};
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollActive));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollInactive));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { View.class }, Theme.dividerPaint, null, null, Theme.key_divider));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_groupcreate_hintText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_CURSORCOLOR, null, null, null, null, Theme.key_groupcreate_cursor));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[] { ShadowSectionCell.class }, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[] { ShadowSectionCell.class }, null, null, null, Theme.key_windowBackgroundGray));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { HeaderCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[] { GroupCreateUserCell.class }, new String[] { "textView" }, null, null, null, Theme.key_groupcreate_sectionText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { GroupCreateUserCell.class }, new String[] { "statusTextView" }, null, null, null, Theme.key_windowBackgroundWhiteBlueText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[] { GroupCreateUserCell.class }, new String[] { "statusTextView" }, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { GroupCreateUserCell.class }, null, Theme.avatarDrawables, cellDelegate, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[] { TextSettingsCell.class }, new String[] { "textView" }, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(progressView, 0, null, null, null, null, Theme.key_contextProgressInner2));
themeDescriptions.add(new ThemeDescription(progressView, 0, null, null, null, null, Theme.key_contextProgressOuter2));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText));
return themeDescriptions;
}
use of org.telegram.ui.Cells.GroupCreateUserCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class GroupCreateFinalActivity method didReceivedNotification.
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
if (listView == null) {
return;
}
int mask = (Integer) args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(mask);
}
}
}
} else if (id == NotificationCenter.chatDidFailCreate) {
reqId = 0;
donePressed = false;
showEditDoneProgress(false);
if (editText != null) {
editText.setEnabled(true);
}
if (delegate != null) {
delegate.didFailChatCreation();
}
} else if (id == NotificationCenter.chatDidCreated) {
reqId = 0;
long chatId = (Long) args[0];
if (delegate != null) {
delegate.didFinishChatCreation(this, chatId);
} else {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
Bundle args2 = new Bundle();
args2.putLong("chat_id", chatId);
presentFragment(new ChatActivity(args2), true);
}
if (inputPhoto != null || inputVideo != null) {
getMessagesController().changeChatAvatar(chatId, null, inputPhoto, inputVideo, videoTimestamp, inputVideoPath, avatar, avatarBig, null);
}
}
}
use of org.telegram.ui.Cells.GroupCreateUserCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class EditWidgetActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(false);
if (AndroidUtilities.isTablet()) {
actionBar.setOccupyStatusBar(false);
}
if (widgetType == TYPE_CHATS) {
actionBar.setTitle(LocaleController.getString("WidgetChats", R.string.WidgetChats));
} else {
actionBar.setTitle(LocaleController.getString("WidgetShortcuts", R.string.WidgetShortcuts));
}
ActionBarMenu menu = actionBar.createMenu();
menu.addItem(done_item, LocaleController.getString("Done", R.string.Done).toUpperCase());
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
if (delegate == null) {
finishActivity();
return;
}
finishFragment();
} else if (id == done_item) {
if (getParentActivity() == null) {
return;
}
getMessagesStorage().putWidgetDialogs(currentWidgetId, selectedDialogs);
SharedPreferences preferences = getParentActivity().getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("account" + currentWidgetId, currentAccount);
editor.putInt("type" + currentWidgetId, widgetType);
editor.commit();
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getParentActivity());
if (widgetType == TYPE_CHATS) {
ChatsWidgetProvider.updateWidget(getParentActivity(), appWidgetManager, currentWidgetId);
} else {
ContactsWidgetProvider.updateWidget(getParentActivity(), appWidgetManager, currentWidgetId);
}
if (delegate != null) {
delegate.didSelectDialogs(selectedDialogs);
} else {
finishActivity();
}
}
}
});
listAdapter = new ListAdapter(context);
FrameLayout frameLayout = new FrameLayout(context);
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
fragmentView = frameLayout;
listView = new RecyclerListView(context);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(listAdapter);
((DefaultItemAnimator) listView.getItemAnimator()).setDelayAnimations(false);
frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
itemTouchHelper.attachToRecyclerView(listView);
listView.setOnItemClickListener((view, position) -> {
if (position == selectChatsRow) {
InviteMembersBottomSheet bottomSheet = new InviteMembersBottomSheet(context, currentAccount, null, 0, EditWidgetActivity.this, null);
bottomSheet.setDelegate(dids -> {
selectedDialogs.clear();
selectedDialogs.addAll(dids);
updateRows();
if (widgetPreviewCell != null) {
widgetPreviewCell.updateDialogs();
}
}, selectedDialogs);
bottomSheet.setSelectedContacts(selectedDialogs);
showDialog(bottomSheet);
}
});
listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {
private Rect rect = new Rect();
@Override
public boolean onItemClick(View view, int position, float x, float y) {
if (getParentActivity() == null || !(view instanceof GroupCreateUserCell)) {
return false;
}
ImageView imageView = (ImageView) view.getTag(R.id.object_tag);
imageView.getHitRect(rect);
if (!rect.contains((int) x, (int) y)) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] { LocaleController.getString("Delete", R.string.Delete) };
builder.setItems(items, (dialogInterface, i) -> {
if (i == 0) {
selectedDialogs.remove(position - chatsStartRow);
updateRows();
if (widgetPreviewCell != null) {
widgetPreviewCell.updateDialogs();
}
}
});
showDialog(builder.create());
return true;
}
return false;
}
@Override
public void onMove(float dx, float dy) {
}
@Override
public void onLongClickRelease() {
}
});
return fragmentView;
}
Aggregations