use of org.telegram.ui.Components.RadialProgressView in project Telegram-FOSS by Telegram-FOSS-Team.
the class LoginActivity method createView.
@Override
public View createView(Context context) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == done_button) {
onDoneButtonPressed();
} else if (id == -1) {
if (onBackPressed()) {
finishFragment();
}
}
}
});
currentDoneType = DONE_TYPE_FLOATING;
doneButtonVisible[DONE_TYPE_FLOATING] = true;
doneButtonVisible[DONE_TYPE_ACTION] = false;
ActionBarMenu menu = actionBar.createMenu();
actionBar.setAllowOverlayTitle(true);
doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
doneProgressView = new ContextProgressView(context, 1);
doneProgressView.setAlpha(0.0f);
doneProgressView.setScaleX(0.1f);
doneProgressView.setScaleY(0.1f);
doneProgressView.setVisibility(View.INVISIBLE);
doneItem.setAlpha(0.0f);
doneItem.setScaleX(0.1f);
doneItem.setScaleY(0.1f);
doneItem.addView(doneProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
doneItem.setContentDescription(LocaleController.getString("Done", R.string.Done));
doneItem.setVisibility(doneButtonVisible[DONE_TYPE_ACTION] ? View.VISIBLE : View.GONE);
FrameLayout container = new FrameLayout(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
MarginLayoutParams marginLayoutParams = (MarginLayoutParams) floatingButtonContainer.getLayoutParams();
if (Bulletin.getVisibleBulletin() != null && Bulletin.getVisibleBulletin().isShowing()) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
marginLayoutParams.bottomMargin = AndroidUtilities.dp(14) + Bulletin.getVisibleBulletin().getLayout().getMeasuredHeight() - AndroidUtilities.dp(10);
} else {
marginLayoutParams.bottomMargin = AndroidUtilities.dp(14);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
fragmentView = container;
ScrollView scrollView = new ScrollView(context) {
@Override
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
if (currentViewNum == 1 || currentViewNum == 2 || currentViewNum == 4) {
rectangle.bottom += AndroidUtilities.dp(40);
}
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
scrollHeight = MeasureSpec.getSize(heightMeasureSpec) - AndroidUtilities.dp(30);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
};
scrollView.setFillViewport(true);
container.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
views[0] = new PhoneView(context);
views[1] = new LoginActivitySmsView(context, 1);
views[2] = new LoginActivitySmsView(context, 2);
views[3] = new LoginActivitySmsView(context, 3);
views[4] = new LoginActivitySmsView(context, 4);
views[5] = new LoginActivityRegisterView(context);
views[6] = new LoginActivityPasswordView(context);
views[7] = new LoginActivityRecoverView(context);
views[8] = new LoginActivityResetWaitView(context);
views[9] = new LoginActivityNewPasswordView(context, 0);
views[10] = new LoginActivityNewPasswordView(context, 1);
views[11] = new LoginActivitySmsView(context, 11);
for (int a = 0; a < views.length; a++) {
views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
}
Bundle savedInstanceState = loadCurrentState();
if (savedInstanceState != null) {
currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
syncContacts = savedInstanceState.getInt("syncContacts", 1) == 1;
if (currentViewNum >= 1 && currentViewNum <= 4) {
int time = savedInstanceState.getInt("open");
if (time != 0 && Math.abs(System.currentTimeMillis() / 1000 - time) >= 24 * 60 * 60) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
} else if (currentViewNum == 6) {
LoginActivityPasswordView view = (LoginActivityPasswordView) views[6];
if (view.currentPassword == null) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
} else if (currentViewNum == 7) {
LoginActivityRecoverView view = (LoginActivityRecoverView) views[7];
if (view.passwordString == null) {
currentViewNum = 0;
savedInstanceState = null;
clearCurrentState();
}
}
}
floatingButtonContainer = new FrameLayout(context);
floatingButtonContainer.setVisibility(doneButtonVisible[DONE_TYPE_FLOATING] ? View.VISIBLE : View.GONE);
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);
container.addView(floatingButtonContainer, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 14, 14));
floatingButtonContainer.setOnClickListener(view -> onDoneButtonPressed());
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.actionbtn_next);
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));
floatingProgressView = new RadialProgressView(context);
floatingProgressView.setSize(AndroidUtilities.dp(22));
floatingProgressView.setProgressColor(Theme.getColor(Theme.key_chats_actionIcon));
floatingProgressView.setAlpha(0.0f);
floatingProgressView.setScaleX(0.1f);
floatingProgressView.setScaleY(0.1f);
floatingProgressView.setVisibility(View.INVISIBLE);
floatingButtonContainer.addView(floatingProgressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
if (savedInstanceState != null) {
restoringState = true;
}
for (int a = 0; a < views.length; a++) {
if (savedInstanceState != null) {
if (a >= 1 && a <= 4) {
if (a == currentViewNum) {
views[a].restoreStateParams(savedInstanceState);
}
} else {
views[a].restoreStateParams(savedInstanceState);
}
}
if (currentViewNum == a) {
actionBar.setBackButtonImage(views[a].needBackButton() || newAccount ? R.drawable.ic_ab_back : 0);
views[a].setVisibility(View.VISIBLE);
views[a].onShow();
currentDoneType = DONE_TYPE_FLOATING;
if (a == 1 || a == 2 || a == 3 || a == 4 || a == 8) {
showDoneButton(false, false);
} else {
showDoneButton(true, false);
}
if (a == 1 || a == 2 || a == 3 || a == 4) {
currentDoneType = DONE_TYPE_ACTION;
}
} else {
views[a].setVisibility(View.GONE);
}
}
restoringState = false;
actionBar.setTitle(views[currentViewNum].getHeaderName());
return fragmentView;
}
use of org.telegram.ui.Components.RadialProgressView in project Telegram-FOSS by Telegram-FOSS-Team.
the class ChannelAdminLogActivity method createView.
@Override
public View createView(Context context) {
if (chatMessageCellsCache.isEmpty()) {
for (int a = 0; a < 8; a++) {
chatMessageCellsCache.add(new ChatMessageCell(context));
}
}
searchWas = false;
hasOwnBackground = true;
Theme.createChatResources(context, false);
actionBar.setAddToContainer(false);
actionBar.setOccupyStatusBar(Build.VERSION.SDK_INT >= 21 && !AndroidUtilities.isTablet());
actionBar.setBackButtonDrawable(new BackDrawable(false));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(final int id) {
if (id == -1) {
finishFragment();
}
}
});
avatarContainer = new ChatAvatarContainer(context, null, false);
avatarContainer.setOccupyStatusBar(!AndroidUtilities.isTablet());
actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 56, 0, 40, 0));
ActionBarMenu menu = actionBar.createMenu();
searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
@Override
public void onSearchCollapse() {
searchQuery = "";
avatarContainer.setVisibility(View.VISIBLE);
if (searchWas) {
searchWas = false;
loadMessages(true);
}
/*highlightMessageId = Integer.MAX_VALUE;
updateVisibleRows();
scrollToLastMessage(false);
*/
updateBottomOverlay();
}
@Override
public void onSearchExpand() {
avatarContainer.setVisibility(View.GONE);
updateBottomOverlay();
}
@Override
public void onSearchPressed(EditText editText) {
searchWas = true;
searchQuery = editText.getText().toString();
loadMessages(true);
// updateSearchButtons(0, 0, 0);
}
});
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
avatarContainer.setEnabled(false);
avatarContainer.setTitle(currentChat.title);
avatarContainer.setSubtitle(LocaleController.getString("EventLogAllEvents", R.string.EventLogAllEvents));
avatarContainer.setChatAvatar(currentChat);
fragmentView = new SizeNotifierFrameLayout(context) {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject != null && messageObject.isRoundVideo() && messageObject.eventId != 0 && messageObject.getDialogId() == -currentChat.id) {
MediaController.getInstance().setTextureView(createTextureView(false), aspectRatioFrameLayout, roundVideoContainer, true);
}
}
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
if (child == actionBar && parentLayout != null) {
parentLayout.drawHeaderShadow(canvas, actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() : 0);
}
return result;
}
@Override
protected boolean isActionBarVisible() {
return actionBar.getVisibility() == VISIBLE;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int allHeight;
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int actionBarHeight = actionBar.getMeasuredHeight();
if (actionBar.getVisibility() == VISIBLE) {
heightSize -= actionBarHeight;
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child == null || child.getVisibility() == GONE || child == actionBar) {
continue;
}
if (child == chatListView || child == progressView) {
int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
int contentHeightSpec = MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize - AndroidUtilities.dp(48 + 2)), MeasureSpec.EXACTLY);
child.measure(contentWidthSpec, contentHeightSpec);
} else if (child == emptyViewContainer) {
int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
int contentHeightSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
child.measure(contentWidthSpec, contentHeightSpec);
} 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();
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();
if (child != actionBar && actionBar.getVisibility() == VISIBLE) {
childTop += actionBar.getMeasuredHeight();
}
break;
case Gravity.CENTER_VERTICAL:
childTop = (b - t - height) / 2 + lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = (b - t) - height - lp.bottomMargin;
break;
default:
childTop = lp.topMargin;
}
if (child == emptyViewContainer) {
childTop -= AndroidUtilities.dp(24) - (actionBar.getVisibility() == VISIBLE ? actionBar.getMeasuredHeight() / 2 : 0);
} else if (child == actionBar) {
childTop -= getPaddingTop();
} else if (child == backgroundView) {
childTop = 0;
}
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
updateMessagesVisisblePart();
notifyHeightChanged();
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (AvatarPreviewer.hasVisibleInstance()) {
AvatarPreviewer.getInstance().onTouchEvent(ev);
return true;
}
return super.dispatchTouchEvent(ev);
}
};
contentView = (SizeNotifierFrameLayout) fragmentView;
contentView.setOccupyStatusBar(!AndroidUtilities.isTablet());
contentView.setBackgroundImage(Theme.getCachedWallpaper(), Theme.isWallpaperMotion());
emptyViewContainer = new FrameLayout(context);
emptyViewContainer.setVisibility(View.INVISIBLE);
contentView.addView(emptyViewContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
emptyViewContainer.setOnTouchListener((v, event) -> true);
emptyView = new TextView(context);
emptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
emptyView.setGravity(Gravity.CENTER);
emptyView.setTextColor(Theme.getColor(Theme.key_chat_serviceText));
emptyView.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(6), emptyView, contentView));
emptyView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16));
emptyViewContainer.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 16, 0, 16, 0));
chatListView = new RecyclerListView(context) {
@Override
public boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
if (child instanceof ChatMessageCell) {
ChatMessageCell chatMessageCell = (ChatMessageCell) child;
ImageReceiver imageReceiver = chatMessageCell.getAvatarImage();
if (imageReceiver != null) {
if (chatMessageCell.getMessageObject().deleted) {
imageReceiver.setVisible(false, false);
return result;
}
int top = (int) child.getY();
if (chatMessageCell.drawPinnedBottom()) {
int p;
ViewHolder holder = chatListView.getChildViewHolder(child);
p = holder.getAdapterPosition();
if (p >= 0) {
int nextPosition;
nextPosition = p + 1;
holder = chatListView.findViewHolderForAdapterPosition(nextPosition);
if (holder != null) {
imageReceiver.setVisible(false, false);
return result;
}
}
}
float tx = chatMessageCell.getSlidingOffsetX() + chatMessageCell.getCheckBoxTranslation();
int y = (int) child.getY() + chatMessageCell.getLayoutHeight();
int maxY = chatListView.getMeasuredHeight() - chatListView.getPaddingBottom();
if (y > maxY) {
y = maxY;
}
if (chatMessageCell.drawPinnedTop()) {
int p;
ViewHolder holder = chatListView.getChildViewHolder(child);
p = holder.getAdapterPosition();
if (p >= 0) {
int tries = 0;
while (true) {
if (tries >= 20) {
break;
}
tries++;
int prevPosition;
prevPosition = p - 1;
holder = chatListView.findViewHolderForAdapterPosition(prevPosition);
if (holder != null) {
top = holder.itemView.getTop();
if (holder.itemView instanceof ChatMessageCell) {
chatMessageCell = (ChatMessageCell) holder.itemView;
if (!chatMessageCell.drawPinnedTop()) {
break;
} else {
p = prevPosition;
}
} else {
break;
}
} else {
break;
}
}
}
}
if (y - AndroidUtilities.dp(48) < top) {
y = top + AndroidUtilities.dp(48);
}
if (!chatMessageCell.drawPinnedBottom()) {
int cellBottom = (int) (chatMessageCell.getY() + chatMessageCell.getMeasuredHeight());
if (y > cellBottom) {
y = cellBottom;
}
}
canvas.save();
if (tx != 0) {
canvas.translate(tx, 0);
}
if (chatMessageCell.getCurrentMessagesGroup() != null) {
if (chatMessageCell.getCurrentMessagesGroup().transitionParams.backgroundChangeBounds) {
y -= chatMessageCell.getTranslationY();
}
}
imageReceiver.setImageY(y - AndroidUtilities.dp(44));
if (chatMessageCell.shouldDrawAlphaLayer()) {
imageReceiver.setAlpha(chatMessageCell.getAlpha());
canvas.scale(chatMessageCell.getScaleX(), chatMessageCell.getScaleY(), chatMessageCell.getX() + chatMessageCell.getPivotX(), chatMessageCell.getY() + (chatMessageCell.getHeight() >> 1));
} else {
imageReceiver.setAlpha(1f);
}
imageReceiver.setVisible(true, false);
imageReceiver.draw(canvas);
canvas.restore();
}
}
return result;
}
};
chatListView.setOnItemClickListener((view, position) -> createMenu(view));
chatListView.setTag(1);
chatListView.setVerticalScrollBarEnabled(true);
chatListView.setAdapter(chatAdapter = new ChatActivityAdapter(context));
chatListView.setClipToPadding(false);
chatListView.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(3));
chatListView.setItemAnimator(chatListItemAnimator = new ChatListItemAnimator(null, chatListView, null) {
int scrollAnimationIndex = -1;
Runnable finishRunnable;
public void onAnimationStart() {
if (scrollAnimationIndex == -1) {
scrollAnimationIndex = getNotificationCenter().setAnimationInProgress(scrollAnimationIndex, null, false);
}
if (finishRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(finishRunnable);
finishRunnable = null;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("admin logs chatItemAnimator disable notifications");
}
}
@Override
protected void onAllAnimationsDone() {
super.onAllAnimationsDone();
if (finishRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(finishRunnable);
}
AndroidUtilities.runOnUIThread(finishRunnable = () -> {
if (scrollAnimationIndex != -1) {
getNotificationCenter().onAnimationFinish(scrollAnimationIndex);
scrollAnimationIndex = -1;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("admin logs chatItemAnimator enable notifications");
}
});
}
});
chatListItemAnimator.setReversePositions(true);
chatListView.setLayoutAnimation(null);
chatLayoutManager = new LinearLayoutManager(context) {
@Override
public boolean supportsPredictiveItemAnimations() {
return true;
}
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
linearSmoothScroller.setTargetPosition(position);
startSmoothScroll(linearSmoothScroller);
}
};
chatLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
chatLayoutManager.setStackFromEnd(true);
chatListView.setLayoutManager(chatLayoutManager);
contentView.addView(chatListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
chatListView.setOnScrollListener(new RecyclerView.OnScrollListener() {
private float totalDy = 0;
private final int scrollValue = AndroidUtilities.dp(100);
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
scrollingFloatingDate = true;
checkTextureViewPosition = true;
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
scrollingFloatingDate = false;
checkTextureViewPosition = false;
hideFloatingDateView(true);
}
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
chatListView.invalidate();
if (dy != 0 && scrollingFloatingDate && !currentFloatingTopIsNotMessage) {
if (floatingDateView.getTag() == null) {
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
}
floatingDateView.setTag(1);
floatingDateAnimation = new AnimatorSet();
floatingDateAnimation.setDuration(150);
floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 1.0f));
floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(floatingDateAnimation)) {
floatingDateAnimation = null;
}
}
});
floatingDateAnimation.start();
}
}
checkScrollForLoad(true);
updateMessagesVisisblePart();
}
});
if (scrollToPositionOnRecreate != -1) {
chatLayoutManager.scrollToPositionWithOffset(scrollToPositionOnRecreate, scrollToOffsetOnRecreate);
scrollToPositionOnRecreate = -1;
}
progressView = new FrameLayout(context);
progressView.setVisibility(View.INVISIBLE);
contentView.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
progressView2 = new View(context);
progressView2.setBackground(Theme.createServiceDrawable(AndroidUtilities.dp(18), progressView2, contentView));
progressView.addView(progressView2, LayoutHelper.createFrame(36, 36, Gravity.CENTER));
progressBar = new RadialProgressView(context);
progressBar.setSize(AndroidUtilities.dp(28));
progressBar.setProgressColor(Theme.getColor(Theme.key_chat_serviceText));
progressView.addView(progressBar, LayoutHelper.createFrame(32, 32, Gravity.CENTER));
floatingDateView = new ChatActionCell(context);
floatingDateView.setAlpha(0.0f);
floatingDateView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
contentView.addView(floatingDateView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 4, 0, 0));
contentView.addView(actionBar);
bottomOverlayChat = new FrameLayout(context) {
@Override
public void onDraw(Canvas canvas) {
int bottom = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), bottom);
Theme.chat_composeShadowDrawable.draw(canvas);
canvas.drawRect(0, bottom, getMeasuredWidth(), getMeasuredHeight(), Theme.chat_composeBackgroundPaint);
}
};
bottomOverlayChat.setWillNotDraw(false);
bottomOverlayChat.setPadding(0, AndroidUtilities.dp(3), 0, 0);
contentView.addView(bottomOverlayChat, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
bottomOverlayChat.setOnClickListener(view -> {
if (getParentActivity() == null) {
return;
}
AdminLogFilterAlert adminLogFilterAlert = new AdminLogFilterAlert(getParentActivity(), currentFilter, selectedAdmins, currentChat.megagroup);
adminLogFilterAlert.setCurrentAdmins(admins);
adminLogFilterAlert.setAdminLogFilterAlertDelegate((filter, admins) -> {
currentFilter = filter;
selectedAdmins = admins;
if (currentFilter != null || selectedAdmins != null) {
avatarContainer.setSubtitle(LocaleController.getString("EventLogSelectedEvents", R.string.EventLogSelectedEvents));
} else {
avatarContainer.setSubtitle(LocaleController.getString("EventLogAllEvents", R.string.EventLogAllEvents));
}
loadMessages(true);
});
showDialog(adminLogFilterAlert);
});
bottomOverlayChatText = new TextView(context);
bottomOverlayChatText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
bottomOverlayChatText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
bottomOverlayChatText.setTextColor(Theme.getColor(Theme.key_chat_fieldOverlayText));
bottomOverlayChatText.setText(LocaleController.getString("SETTINGS", R.string.SETTINGS).toUpperCase());
bottomOverlayChat.addView(bottomOverlayChatText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
bottomOverlayImage = new ImageView(context);
bottomOverlayImage.setImageResource(R.drawable.log_info);
bottomOverlayImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_fieldOverlayText), PorterDuff.Mode.MULTIPLY));
bottomOverlayImage.setScaleType(ImageView.ScaleType.CENTER);
bottomOverlayChat.addView(bottomOverlayImage, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP, 3, 0, 0, 0));
bottomOverlayImage.setContentDescription(LocaleController.getString("BotHelp", R.string.BotHelp));
bottomOverlayImage.setOnClickListener(v -> {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
if (currentChat.megagroup) {
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("EventLogInfoDetail", R.string.EventLogInfoDetail)));
} else {
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("EventLogInfoDetailChannel", R.string.EventLogInfoDetailChannel)));
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setTitle(LocaleController.getString("EventLogInfoTitle", R.string.EventLogInfoTitle));
showDialog(builder.create());
});
searchContainer = new FrameLayout(context) {
@Override
public void onDraw(Canvas canvas) {
int bottom = Theme.chat_composeShadowDrawable.getIntrinsicHeight();
Theme.chat_composeShadowDrawable.setBounds(0, 0, getMeasuredWidth(), bottom);
Theme.chat_composeShadowDrawable.draw(canvas);
canvas.drawRect(0, bottom, getMeasuredWidth(), getMeasuredHeight(), Theme.chat_composeBackgroundPaint);
}
};
searchContainer.setWillNotDraw(false);
searchContainer.setVisibility(View.INVISIBLE);
searchContainer.setFocusable(true);
searchContainer.setFocusableInTouchMode(true);
searchContainer.setClickable(true);
searchContainer.setPadding(0, AndroidUtilities.dp(3), 0, 0);
contentView.addView(searchContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
/*searchUpButton = new ImageView(context);
searchUpButton.setScaleType(ImageView.ScaleType.CENTER);
searchUpButton.setImageResource(R.drawable.msg_go_up);
searchUpButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY));
searchContainer.addView(searchUpButton, LayoutHelper.createFrame(48, 48));
searchUpButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MessagesSearchQuery.searchMessagesInChat(null, dialog_id, mergeDialogId, classGuid, 1);
}
});
searchDownButton = new ImageView(context);
searchDownButton.setScaleType(ImageView.ScaleType.CENTER);
searchDownButton.setImageResource(R.drawable.msg_go_down);
searchDownButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY));
searchContainer.addView(searchDownButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP, 48, 0, 0, 0));
searchDownButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MessagesSearchQuery.searchMessagesInChat(null, dialog_id, mergeDialogId, classGuid, 2);
}
});*/
searchCalendarButton = new ImageView(context);
searchCalendarButton.setScaleType(ImageView.ScaleType.CENTER);
searchCalendarButton.setImageResource(R.drawable.msg_calendar);
searchCalendarButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_searchPanelIcons), PorterDuff.Mode.MULTIPLY));
searchContainer.addView(searchCalendarButton, LayoutHelper.createFrame(48, 48, Gravity.RIGHT | Gravity.TOP));
searchCalendarButton.setOnClickListener(view -> {
if (getParentActivity() == null) {
return;
}
AndroidUtilities.hideKeyboard(searchItem.getSearchField());
showDialog(AlertsCreator.createCalendarPickerDialog(getParentActivity(), 1375315200000L, param -> loadMessages(true), null).create());
});
searchCountText = new SimpleTextView(context);
searchCountText.setTextColor(Theme.getColor(Theme.key_chat_searchPanelText));
searchCountText.setTextSize(15);
searchCountText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
searchContainer.addView(searchCountText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.CENTER_VERTICAL, 108, 0, 0, 0));
chatAdapter.updateRows();
if (loading && messages.isEmpty()) {
AndroidUtilities.updateViewVisibilityAnimated(progressView, true, 0.3f, true);
chatListView.setEmptyView(null);
} else {
AndroidUtilities.updateViewVisibilityAnimated(progressView, false, 0.3f, true);
chatListView.setEmptyView(emptyViewContainer);
}
chatListView.setAnimateEmptyView(true, 1);
undoView = new UndoView(context);
undoView.setAdditionalTranslationY(AndroidUtilities.dp(51));
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
updateEmptyPlaceholder();
return fragmentView;
}
use of org.telegram.ui.Components.RadialProgressView in project Telegram-FOSS by Telegram-FOSS-Team.
the class TooManyCommunitiesActivity method createView.
@Override
public View createView(Context context) {
type = arguments.getInt("type", TYPE_JOIN);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("LimitReached", R.string.LimitReached));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
ActionBarMenu menu = actionBar.createMenu();
ActionBarMenuItem searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
boolean expanded = false;
@Override
public void onSearchCollapse() {
super.onSearchCollapse();
if (listView.getVisibility() != View.VISIBLE) {
listView.setVisibility(View.VISIBLE);
listView.setAlpha(0);
}
emptyView.setVisibility(View.GONE);
adapter.notifyDataSetChanged();
listView.animate().alpha(1f).setDuration(150).setListener(null).start();
searchViewContainer.animate().alpha(0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
searchViewContainer.setVisibility(View.GONE);
}
}).start();
expanded = false;
}
@Override
public void onTextChanged(EditText editText) {
String query = editText.getText().toString();
searchAdapter.search(query);
if (!expanded && !TextUtils.isEmpty(query)) {
if (searchViewContainer.getVisibility() != View.VISIBLE) {
searchViewContainer.setVisibility(View.VISIBLE);
searchViewContainer.setAlpha(0);
}
listView.animate().alpha(0).setDuration(150).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
listView.setVisibility(View.GONE);
}
}).start();
searchAdapter.searchResultsSignatures.clear();
searchAdapter.searchResults.clear();
searchAdapter.notifyDataSetChanged();
searchViewContainer.animate().setListener(null).alpha(1f).setDuration(150).start();
expanded = true;
} else if (expanded && TextUtils.isEmpty(query)) {
onSearchCollapse();
}
}
});
searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
FrameLayout contentView = new FrameLayout(context);
fragmentView = contentView;
listView = new RecyclerListView(context);
listView.setLayoutManager(new LinearLayoutManager(context));
listView.setAdapter(adapter = new Adapter());
listView.setClipToPadding(false);
listView.setOnItemClickListener(onItemClickListener);
listView.setOnItemLongClickListener(onItemLongClickListener);
searchListView = new RecyclerListView(context);
searchListView.setLayoutManager(new LinearLayoutManager(context));
searchListView.setAdapter(searchAdapter = new SearchAdapter());
searchListView.setOnItemClickListener(onItemClickListener);
searchListView.setOnItemLongClickListener(onItemLongClickListener);
searchListView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
}
});
emptyView = new EmptyTextProgressView(context);
emptyView.setShowAtCenter(true);
emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
emptyView.showTextView();
progressBar = new RadialProgressView(context);
contentView.addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
adapter.updateRows();
progressBar.setVisibility(View.GONE);
contentView.addView(listView);
searchViewContainer = new FrameLayout(context);
searchViewContainer.addView(searchListView);
searchViewContainer.addView(emptyView);
searchViewContainer.setVisibility(View.GONE);
contentView.addView(searchViewContainer);
loadInactiveChannels();
fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
buttonLayout = new FrameLayout(context) {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawRect(0, 0, getMeasuredWidth(), 1, Theme.dividerPaint);
}
};
buttonLayout.setWillNotDraw(false);
buttonTextView = new TextView(context);
buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
buttonTextView.setGravity(Gravity.CENTER);
buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
buttonTextView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
contentView.addView(buttonLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 64, Gravity.BOTTOM));
buttonLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
buttonLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 12, 16, 12));
buttonLayout.setVisibility(View.GONE);
buttonTextView.setOnClickListener(v -> {
if (selectedIds.isEmpty()) {
return;
}
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
ArrayList<TLRPC.Chat> chats = new ArrayList<>();
for (int i = 0; i < inactiveChats.size(); i++) {
if (selectedIds.contains(inactiveChats.get(i).id)) {
chats.add(inactiveChats.get(i));
}
}
for (int i = 0; i < chats.size(); i++) {
TLRPC.Chat chat = chats.get(i);
getMessagesController().putChat(chat, false);
getMessagesController().deleteParticipantFromChat(chat.id, currentUser, null);
}
finishFragment();
});
return fragmentView;
}
use of org.telegram.ui.Components.RadialProgressView in project Telegram-FOSS by Telegram-FOSS-Team.
the class PhotoAlbumPickerActivity method createView.
@Override
public View createView(Context context) {
actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == 1) {
if (delegate != null) {
finishFragment(false);
delegate.startPhotoSelectActivity();
}
} else if (id == 2) {
openPhotoPicker(null, 0);
}
}
});
ActionBarMenu menu = actionBar.createMenu();
if (allowSearchImages) {
menu.addItem(2, R.drawable.ic_ab_search).setContentDescription(LocaleController.getString("Search", R.string.Search));
}
ActionBarMenuItem menuItem = menu.addItem(0, R.drawable.ic_ab_other);
menuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
menuItem.addSubItem(1, R.drawable.msg_openin, LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
private int lastNotifyWidth;
private boolean ignoreLayout;
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : measureKeyboardHeight();
if (keyboardSize <= AndroidUtilities.dp(20)) {
if (!AndroidUtilities.isInMultiwindow) {
heightSize -= commentTextView.getEmojiPadding();
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
}
} else {
ignoreLayout = true;
commentTextView.hideEmojiView();
ignoreLayout = false;
}
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child == null || child.getVisibility() == GONE) {
continue;
}
if (commentTextView != null && commentTextView.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) {
if (lastNotifyWidth != r - l) {
lastNotifyWidth = r - l;
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
}
final int count = getChildCount();
int keyboardSize = SharedConfig.smoothKeyboard ? 0 : measureKeyboardHeight();
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.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 - l) - width - lp.rightMargin - getPaddingRight();
break;
case Gravity.LEFT:
default:
childLeft = lp.leftMargin + getPaddingLeft();
}
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 (commentTextView != null && commentTextView.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.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
fragmentView = sizeNotifierFrameLayout;
actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
listView = new RecyclerListView(context);
listView.setPadding(AndroidUtilities.dp(6), AndroidUtilities.dp(4), AndroidUtilities.dp(6), AndroidUtilities.dp(54));
listView.setClipToPadding(false);
listView.setHorizontalScrollBarEnabled(false);
listView.setVerticalScrollBarEnabled(false);
listView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
listView.setDrawingCacheEnabled(false);
sizeNotifierFrameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP));
listView.setAdapter(listAdapter = new ListAdapter(context));
listView.setGlowColor(Theme.getColor(Theme.key_dialogBackground));
emptyView = new TextView(context);
emptyView.setTextColor(0xff808080);
emptyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
emptyView.setGravity(Gravity.CENTER);
emptyView.setVisibility(View.GONE);
emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
sizeNotifierFrameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));
emptyView.setOnTouchListener((v, event) -> true);
progressView = new FrameLayout(context);
progressView.setVisibility(View.GONE);
sizeNotifierFrameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 48));
RadialProgressView progressBar = new RadialProgressView(context);
progressBar.setProgressColor(0xff527da3);
progressView.addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
shadow = new View(context);
shadow.setBackgroundResource(R.drawable.header_shadow_reverse);
shadow.setTranslationY(AndroidUtilities.dp(48));
sizeNotifierFrameLayout.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
frameLayout2 = new FrameLayout(context);
frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
frameLayout2.setVisibility(View.INVISIBLE);
frameLayout2.setTranslationY(AndroidUtilities.dp(48));
sizeNotifierFrameLayout.addView(frameLayout2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
frameLayout2.setOnTouchListener((v, event) -> true);
if (commentTextView != null) {
commentTextView.onDestroy();
}
commentTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, null, EditTextEmoji.STYLE_DIALOG);
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(MessagesController.getInstance(UserConfig.selectedAccount).maxCaptionLength);
commentTextView.setFilters(inputFilters);
commentTextView.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
EditTextBoldCursor editText = commentTextView.getEditText();
editText.setMaxLines(1);
editText.setSingleLine(true);
frameLayout2.addView(commentTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 84, 0));
if (caption != null) {
commentTextView.setText(caption);
}
writeButtonContainer = new FrameLayout(context) {
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
info.setText(LocaleController.formatPluralString("AccDescrSendPhotos", selectedPhotos.size()));
info.setClassName(Button.class.getName());
info.setLongClickable(true);
info.setClickable(true);
}
};
writeButtonContainer.setFocusable(true);
writeButtonContainer.setFocusableInTouchMode(true);
writeButtonContainer.setVisibility(View.INVISIBLE);
writeButtonContainer.setScaleX(0.2f);
writeButtonContainer.setScaleY(0.2f);
writeButtonContainer.setAlpha(0.0f);
sizeNotifierFrameLayout.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 12, 10));
writeButton = new ImageView(context);
writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_dialogFloatingButton), Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, writeButtonDrawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
writeButtonDrawable = combinedDrawable;
}
writeButton.setBackgroundDrawable(writeButtonDrawable);
writeButton.setImageResource(R.drawable.attach_send);
writeButton.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
writeButton.setScaleType(ImageView.ScaleType.CENTER);
if (Build.VERSION.SDK_INT >= 21) {
writeButton.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
writeButtonContainer.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.LEFT | Gravity.TOP, Build.VERSION.SDK_INT >= 21 ? 2 : 0, 0, 0, 0));
writeButton.setOnClickListener(v -> {
if (chatActivity != null && chatActivity.isInScheduleMode()) {
AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), (notify, scheduleDate) -> {
sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, notify, scheduleDate);
finishFragment();
});
} else {
sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, true, 0);
finishFragment();
}
});
writeButton.setOnLongClickListener(view -> {
if (chatActivity == null || maxSelectedPhotos == 1) {
return false;
}
TLRPC.Chat chat = chatActivity.getCurrentChat();
TLRPC.User user = chatActivity.getCurrentUser();
if (sendPopupLayout == null) {
sendPopupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity());
sendPopupLayout.setAnimationEnabled(false);
sendPopupLayout.setOnTouchListener(new View.OnTouchListener() {
private android.graphics.Rect popupRect = new android.graphics.Rect();
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
v.getHitRect(popupRect);
if (!popupRect.contains((int) event.getX(), (int) event.getY())) {
sendPopupWindow.dismiss();
}
}
}
return false;
}
});
sendPopupLayout.setDispatchKeyEventListener(keyEvent -> {
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
});
sendPopupLayout.setShownFromBotton(false);
itemCells = new ActionBarMenuSubItem[2];
for (int a = 0; a < 2; a++) {
if (a == 0 && !chatActivity.canScheduleMessage() || a == 1 && UserObject.isUserSelf(user)) {
continue;
}
int num = a;
itemCells[a] = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == 1);
if (num == 0) {
if (UserObject.isUserSelf(user)) {
itemCells[a].setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.msg_schedule);
} else {
itemCells[a].setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.msg_schedule);
}
} else {
itemCells[a].setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
}
itemCells[a].setMinimumWidth(AndroidUtilities.dp(196));
sendPopupLayout.addView(itemCells[a], LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
itemCells[a].setOnClickListener(v -> {
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
sendPopupWindow.dismiss();
}
if (num == 0) {
AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), chatActivity.getDialogId(), (notify, scheduleDate) -> {
sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, notify, scheduleDate);
finishFragment();
});
} else {
sendSelectedPhotos(selectedPhotos, selectedPhotosOrder, true, 0);
finishFragment();
}
});
}
sendPopupLayout.setupRadialSelectors(Theme.getColor(Theme.key_dialogButtonSelector));
sendPopupWindow = new ActionBarPopupWindow(sendPopupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
sendPopupWindow.setAnimationEnabled(false);
sendPopupWindow.setAnimationStyle(R.style.PopupContextAnimation2);
sendPopupWindow.setOutsideTouchable(true);
sendPopupWindow.setClippingEnabled(true);
sendPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
sendPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
sendPopupWindow.getContentView().setFocusableInTouchMode(true);
}
sendPopupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
sendPopupWindow.setFocusable(true);
int[] location = new int[2];
view.getLocationInWindow(location);
sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2));
sendPopupWindow.dimBehind();
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
return false;
});
textPaint.setTextSize(AndroidUtilities.dp(12));
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
selectedCountView = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
String text = String.format("%d", Math.max(1, selectedPhotosOrder.size()));
int textSize = (int) Math.ceil(textPaint.measureText(text));
int size = Math.max(AndroidUtilities.dp(16) + textSize, AndroidUtilities.dp(24));
int cx = getMeasuredWidth() / 2;
int cy = getMeasuredHeight() / 2;
textPaint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBoxCheck));
paint.setColor(Theme.getColor(Theme.key_dialogBackground));
rect.set(cx - size / 2, 0, cx + size / 2, getMeasuredHeight());
canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), paint);
paint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBox));
rect.set(cx - size / 2 + AndroidUtilities.dp(2), AndroidUtilities.dp(2), cx + size / 2 - AndroidUtilities.dp(2), getMeasuredHeight() - AndroidUtilities.dp(2));
canvas.drawRoundRect(rect, AndroidUtilities.dp(10), AndroidUtilities.dp(10), paint);
canvas.drawText(text, cx - textSize / 2, AndroidUtilities.dp(16.2f), textPaint);
}
};
selectedCountView.setAlpha(0.0f);
selectedCountView.setScaleX(0.2f);
selectedCountView.setScaleY(0.2f);
sizeNotifierFrameLayout.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -2, 9));
if (selectPhotoType != SELECT_TYPE_ALL) {
commentTextView.setVisibility(View.GONE);
}
if (loading && (albumsSorted == null || albumsSorted.isEmpty())) {
progressView.setVisibility(View.VISIBLE);
listView.setEmptyView(null);
} else {
progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
}
return fragmentView;
}
Aggregations