mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-05 23:51:00 +00:00
update to 9.2.0
This commit is contained in:
parent
0e17caa7a6
commit
b73fc8de38
242 changed files with 14252 additions and 5037 deletions
|
|
@ -12,6 +12,7 @@ import android.animation.Animator;
|
|||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
|
|
@ -48,6 +49,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.ui.Adapters.FiltersView;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.EllipsizeSpanAnimator;
|
||||
import org.telegram.ui.Components.FireworksEffect;
|
||||
|
|
@ -69,8 +71,9 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private INavigationLayout.BackButtonState backButtonState;
|
||||
private INavigationLayout.BackButtonState backButtonState = INavigationLayout.BackButtonState.BACK;
|
||||
private ImageView backButtonImageView;
|
||||
private BackupImageView avatarSearchImageView;
|
||||
private Drawable backButtonDrawable;
|
||||
private SimpleTextView[] titleTextView = new SimpleTextView[2];
|
||||
private SimpleTextView subtitleTextView;
|
||||
|
|
@ -117,6 +120,7 @@ public class ActionBar extends FrameLayout {
|
|||
private boolean castShadows = true;
|
||||
|
||||
protected boolean isSearchFieldVisible;
|
||||
public float searchFieldVisibleAlpha;
|
||||
protected int itemsBackgroundColor;
|
||||
protected int itemsActionModeBackgroundColor;
|
||||
protected int itemsColor;
|
||||
|
|
@ -130,10 +134,13 @@ public class ActionBar extends FrameLayout {
|
|||
private boolean fromBottom;
|
||||
private boolean centerScale;
|
||||
private CharSequence subtitle;
|
||||
private boolean drawBackButton;
|
||||
|
||||
private View.OnTouchListener interceptTouchEventListener;
|
||||
private final Theme.ResourcesProvider resourcesProvider;
|
||||
|
||||
private PorterDuff.Mode colorFilterMode = PorterDuff.Mode.MULTIPLY;
|
||||
|
||||
SizeNotifierFrameLayout contentView;
|
||||
boolean blurredBackground;
|
||||
public Paint blurScrimPaint = new Paint();
|
||||
|
|
@ -158,7 +165,14 @@ public class ActionBar extends FrameLayout {
|
|||
});
|
||||
}
|
||||
|
||||
public void setColorFilterMode(PorterDuff.Mode colorFilterMode) {
|
||||
this.colorFilterMode = colorFilterMode;
|
||||
}
|
||||
|
||||
public INavigationLayout.BackButtonState getBackButtonState() {
|
||||
if (backButtonDrawable instanceof INavigationLayout.IBackButtonDrawable) {
|
||||
return ((INavigationLayout.IBackButtonDrawable) backButtonDrawable).getBackButtonState();
|
||||
}
|
||||
return backButtonState;
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +184,7 @@ public class ActionBar extends FrameLayout {
|
|||
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
backButtonImageView.setBackgroundDrawable(Theme.createSelectorDrawable(itemsBackgroundColor));
|
||||
if (itemsColor != 0) {
|
||||
backButtonImageView.setColorFilter(new PorterDuffColorFilter(itemsColor, PorterDuff.Mode.MULTIPLY));
|
||||
backButtonImageView.setColorFilter(new PorterDuffColorFilter(itemsColor, colorFilterMode));
|
||||
}
|
||||
backButtonImageView.setPadding(AndroidUtilities.dp(1), 0, 0, 0);
|
||||
addView(backButtonImageView, LayoutHelper.createFrame(54, 54, Gravity.LEFT | Gravity.TOP));
|
||||
|
|
@ -224,6 +238,23 @@ public class ActionBar extends FrameLayout {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public BackupImageView getSearchAvatarImageView() {
|
||||
return avatarSearchImageView;
|
||||
}
|
||||
|
||||
public void setSearchAvatarImageView(BackupImageView backupImageView) {
|
||||
if (avatarSearchImageView == backupImageView) {
|
||||
return;
|
||||
}
|
||||
if (avatarSearchImageView != null) {
|
||||
removeView(avatarSearchImageView);
|
||||
}
|
||||
avatarSearchImageView = backupImageView;
|
||||
if (avatarSearchImageView != null) {
|
||||
addView(avatarSearchImageView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (supportsHolidayImage && !titleOverlayShown && !LocaleController.isRTL && ev.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
|
|
@ -252,9 +283,12 @@ public class ActionBar extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
if (parentFragment != null && parentFragment.getParentLayout().isActionBarInCrossfade()) {
|
||||
if (parentFragment != null && parentFragment.getParentLayout() != null && parentFragment.getParentLayout().isActionBarInCrossfade()) {
|
||||
return false;
|
||||
}
|
||||
if (drawBackButton && child == backButtonImageView) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean clip = shouldClipChild(child);
|
||||
if (clip) {
|
||||
|
|
@ -318,9 +352,6 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
backButtonImageView.setVisibility(resource == 0 ? GONE : VISIBLE);
|
||||
backButtonImageView.setImageResource(resource);
|
||||
if (resource == R.drawable.ic_ab_back) {
|
||||
backButtonState = INavigationLayout.BackButtonState.BACK;
|
||||
}
|
||||
}
|
||||
|
||||
private void createSubtitleTextView() {
|
||||
|
|
@ -380,7 +411,12 @@ public class ActionBar extends FrameLayout {
|
|||
if (titleTextView[i] != null) {
|
||||
return;
|
||||
}
|
||||
titleTextView[i] = new SimpleTextView(getContext());
|
||||
titleTextView[i] = new SimpleTextView(getContext()) {
|
||||
@Override
|
||||
public void setAlpha(float alpha) {
|
||||
super.setAlpha(alpha);
|
||||
}
|
||||
};
|
||||
titleTextView[i].setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
if (titleColorToSet != 0) {
|
||||
titleTextView[i].setTextColor(titleColorToSet);
|
||||
|
|
@ -691,6 +727,15 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
actionModeAnimation = new AnimatorSet();
|
||||
actionModeAnimation.playTogether(animators);
|
||||
if (backgroundUpdateListener != null) {
|
||||
ValueAnimator alphaUpdate = ValueAnimator.ofFloat(0, 1);
|
||||
alphaUpdate.addUpdateListener(anm -> {
|
||||
if (backgroundUpdateListener != null) {
|
||||
backgroundUpdateListener.run();
|
||||
}
|
||||
});
|
||||
actionModeAnimation.playTogether(alphaUpdate);
|
||||
}
|
||||
actionModeAnimation.setDuration(200);
|
||||
actionModeAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
|
@ -844,6 +889,15 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
actionModeAnimation = new AnimatorSet();
|
||||
actionModeAnimation.playTogether(animators);
|
||||
if (backgroundUpdateListener != null) {
|
||||
ValueAnimator alphaUpdate = ValueAnimator.ofFloat(0, 1);
|
||||
alphaUpdate.addUpdateListener(anm -> {
|
||||
if (backgroundUpdateListener != null) {
|
||||
backgroundUpdateListener.run();
|
||||
}
|
||||
});
|
||||
actionModeAnimation.playTogether(alphaUpdate);
|
||||
}
|
||||
actionModeAnimation.setDuration(200);
|
||||
actionModeAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
|
@ -948,8 +1002,17 @@ public class ActionBar extends FrameLayout {
|
|||
return actionMode != null && actionModeVisible && ((actionModeTag == null && tag == null) || (actionModeTag != null && actionModeTag.equals(tag)));
|
||||
}
|
||||
|
||||
Runnable backgroundUpdateListener;
|
||||
AnimatorSet searchVisibleAnimator;
|
||||
|
||||
public void listenToBackgroundUpdate(Runnable invalidate) {
|
||||
backgroundUpdateListener = invalidate;
|
||||
}
|
||||
|
||||
protected boolean onSearchChangedIgnoreTitles() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onSearchFieldVisibilityChanged(boolean visible) {
|
||||
isSearchFieldVisible = visible;
|
||||
if (searchVisibleAnimator != null) {
|
||||
|
|
@ -958,14 +1021,26 @@ public class ActionBar extends FrameLayout {
|
|||
searchVisibleAnimator = new AnimatorSet();
|
||||
final ArrayList<View> viewsToHide = new ArrayList<>();
|
||||
|
||||
if (titleTextView[0] != null) {
|
||||
viewsToHide.add(titleTextView[0]);
|
||||
final boolean ignoreTitles = onSearchChangedIgnoreTitles();
|
||||
if (!ignoreTitles) {
|
||||
if (titleTextView[0] != null) {
|
||||
viewsToHide.add(titleTextView[0]);
|
||||
}
|
||||
|
||||
if (subtitleTextView != null && !TextUtils.isEmpty(subtitle)) {
|
||||
viewsToHide.add(subtitleTextView);
|
||||
subtitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (subtitleTextView != null && !TextUtils.isEmpty(subtitle)) {
|
||||
viewsToHide.add(subtitleTextView);
|
||||
subtitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
|
||||
}
|
||||
ValueAnimator alphaUpdate = ValueAnimator.ofFloat(searchFieldVisibleAlpha, visible ? 1f : 0f);
|
||||
alphaUpdate.addUpdateListener(anm -> {
|
||||
searchFieldVisibleAlpha = (float) anm.getAnimatedValue();
|
||||
if (backgroundUpdateListener != null) {
|
||||
backgroundUpdateListener.run();
|
||||
}
|
||||
});
|
||||
searchVisibleAnimator.playTogether(alphaUpdate);
|
||||
|
||||
for (int i = 0; i < viewsToHide.size(); i++) {
|
||||
View view = viewsToHide.get(i);
|
||||
|
|
@ -979,6 +1054,10 @@ public class ActionBar extends FrameLayout {
|
|||
searchVisibleAnimator.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_Y, visible ? 0.95f : 1f));
|
||||
searchVisibleAnimator.playTogether(ObjectAnimator.ofFloat(view, View.SCALE_X, visible ? 0.95f : 1f));
|
||||
}
|
||||
if (avatarSearchImageView != null) {
|
||||
avatarSearchImageView.setVisibility(View.VISIBLE);
|
||||
searchVisibleAnimator.playTogether(ObjectAnimator.ofFloat(avatarSearchImageView, View.ALPHA, visible ? 1f : 0f));
|
||||
}
|
||||
centerScale = true;
|
||||
requestLayout();
|
||||
searchVisibleAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
|
|
@ -994,7 +1073,7 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
if (visible && !ignoreTitles) {
|
||||
if (titleTextView[0] != null) {
|
||||
titleTextView[0].setVisibility(View.GONE);
|
||||
}
|
||||
|
|
@ -1002,16 +1081,24 @@ public class ActionBar extends FrameLayout {
|
|||
titleTextView[1].setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (avatarSearchImageView != null) {
|
||||
if (!visible) {
|
||||
avatarSearchImageView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
searchVisibleAnimator.setDuration(150).start();
|
||||
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof MenuDrawable) {
|
||||
MenuDrawable menuDrawable = (MenuDrawable) drawable;
|
||||
menuDrawable.setRotateToBack(true);
|
||||
menuDrawable.setRotation(visible ? 1 : 0, true);
|
||||
if (backButtonImageView != null) {
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof MenuDrawable) {
|
||||
MenuDrawable menuDrawable = (MenuDrawable) drawable;
|
||||
menuDrawable.setRotateToBack(true);
|
||||
menuDrawable.setRotation(visible ? 1 : 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1194,10 +1281,17 @@ public class ActionBar extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
if (avatarSearchImageView != null) {
|
||||
avatarSearchImageView.measure(
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY)
|
||||
);
|
||||
}
|
||||
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE || child == titleTextView[0] || child == titleTextView[1] || child == subtitleTextView || child == menu || child == backButtonImageView || child == additionalSubtitleTextView) {
|
||||
if (child.getVisibility() == GONE || child == titleTextView[0] || child == titleTextView[1] || child == subtitleTextView || child == menu || child == backButtonImageView || child == additionalSubtitleTextView || child == avatarSearchImageView) {
|
||||
continue;
|
||||
}
|
||||
measureChildWithMargins(child, widthMeasureSpec, 0, MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY), 0);
|
||||
|
|
@ -1250,10 +1344,19 @@ public class ActionBar extends FrameLayout {
|
|||
additionalSubtitleTextView.layout(textLeft, additionalTop + textTop, textLeft + additionalSubtitleTextView.getMeasuredWidth(), additionalTop + textTop + additionalSubtitleTextView.getTextHeight());
|
||||
}
|
||||
|
||||
if (avatarSearchImageView != null) {
|
||||
avatarSearchImageView.layout(
|
||||
AndroidUtilities.dp(56 + 8),
|
||||
additionalTop + (getCurrentActionBarHeight() - avatarSearchImageView.getMeasuredHeight()) / 2,
|
||||
AndroidUtilities.dp(56 + 8) + avatarSearchImageView.getMeasuredWidth(),
|
||||
additionalTop + (getCurrentActionBarHeight() + avatarSearchImageView.getMeasuredHeight()) / 2
|
||||
);
|
||||
}
|
||||
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE || child == titleTextView[0] || child == titleTextView[1] || child == subtitleTextView || child == menu || child == backButtonImageView || child == additionalSubtitleTextView) {
|
||||
if (child.getVisibility() == GONE || child == titleTextView[0] || child == titleTextView[1] || child == subtitleTextView || child == menu || child == backButtonImageView || child == additionalSubtitleTextView || child == avatarSearchImageView) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -1476,7 +1579,7 @@ public class ActionBar extends FrameLayout {
|
|||
itemsColor = color;
|
||||
if (backButtonImageView != null) {
|
||||
if (itemsColor != 0) {
|
||||
backButtonImageView.setColorFilter(new PorterDuffColorFilter(itemsColor, PorterDuff.Mode.MULTIPLY));
|
||||
backButtonImageView.setColorFilter(new PorterDuffColorFilter(itemsColor, colorFilterMode));
|
||||
Drawable drawable = backButtonImageView.getDrawable();
|
||||
if (drawable instanceof BackDrawable) {
|
||||
((BackDrawable) drawable).setColor(color);
|
||||
|
|
@ -1709,4 +1812,12 @@ public class ActionBar extends FrameLayout {
|
|||
public void setForceSkipTouches(boolean forceSkipTouches) {
|
||||
this.forceSkipTouches = forceSkipTouches;
|
||||
}
|
||||
|
||||
public void setDrawBackButton(boolean b) {
|
||||
this.drawBackButton = b;
|
||||
if (backButtonImageView != null) {
|
||||
backButtonImageView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1606,6 +1606,10 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
}
|
||||
|
||||
public void closeLastFragment(boolean animated, boolean forceNoAnimation) {
|
||||
BaseFragment fragment = getLastFragment();
|
||||
if (fragment != null && fragment.closeLastFragment()) {
|
||||
return;
|
||||
}
|
||||
if (delegate != null && !delegate.needCloseLastFragment(this) || checkTransitionAnimation() || fragmentsStack.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -2188,7 +2192,9 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
oldFragment = null;
|
||||
Runnable endRunnable = onCloseAnimationEndRunnable;
|
||||
onCloseAnimationEndRunnable = null;
|
||||
endRunnable.run();
|
||||
if (endRunnable != null) {
|
||||
endRunnable.run();
|
||||
}
|
||||
checkNeedRebuild();
|
||||
checkNeedRebuild();
|
||||
}
|
||||
|
|
@ -2346,19 +2352,19 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
|
|||
}
|
||||
}
|
||||
|
||||
private View findScrollingChild(ViewGroup parent, float x, float y) {
|
||||
public static View findScrollingChild(ViewGroup parent, float x, float y) {
|
||||
int n = parent.getChildCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
View child = parent.getChildAt(i);
|
||||
if (child.getVisibility() != View.VISIBLE) {
|
||||
continue;
|
||||
}
|
||||
child.getHitRect(rect);
|
||||
if (rect.contains((int) x, (int) y)) {
|
||||
child.getHitRect(AndroidUtilities.rectTmp2);
|
||||
if (AndroidUtilities.rectTmp2.contains((int) x, (int) y)) {
|
||||
if (child.canScrollHorizontally(-1)) {
|
||||
return child;
|
||||
} else if (child instanceof ViewGroup) {
|
||||
View v = findScrollingChild((ViewGroup) child, x - rect.left, y - rect.top);
|
||||
View v = findScrollingChild((ViewGroup) child, x - AndroidUtilities.rectTmp2.left, y - AndroidUtilities.rectTmp2.top);
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ public class ActionBarMenuItem extends FrameLayout {
|
|||
public void setSearchPaddingStart(int padding) {
|
||||
searchItemPaddingStart = padding;
|
||||
if (searchContainer != null) {
|
||||
((MarginLayoutParams)searchContainer.getLayoutParams()).leftMargin = AndroidUtilities.dp(padding);
|
||||
((MarginLayoutParams) searchContainer.getLayoutParams()).leftMargin = AndroidUtilities.dp(padding);
|
||||
searchContainer.setClipChildren(searchItemPaddingStart != 0);
|
||||
searchContainer.setLayoutParams(searchContainer.getLayoutParams());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ActionBarMenuItemSearchListener {
|
||||
|
|
@ -1837,6 +1837,17 @@ public class ActionBarMenuItem extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
public int getVisibleSubItemsCount() {
|
||||
int count = 0;
|
||||
for (int i = 0; i < popupLayout.getItemsCount(); ++i) {
|
||||
View item = popupLayout.getItemAt(i);
|
||||
if (item != null && item.getVisibility() == View.VISIBLE) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public void requestFocusOnSearchView() {
|
||||
if (searchContainer.getWidth() != 0 && !searchField.isFocused()) {
|
||||
searchField.requestFocus();
|
||||
|
|
|
|||
|
|
@ -1019,21 +1019,31 @@ public class ActionBarPopupWindow extends PopupWindow {
|
|||
Theme.ResourcesProvider resourcesProvider;
|
||||
String colorKey;
|
||||
|
||||
Drawable shadowDrawable;
|
||||
|
||||
public GapView(Context context, Theme.ResourcesProvider resourcesProvider) {
|
||||
this(context, resourcesProvider, Theme.key_actionBarDefaultSubmenuSeparator);
|
||||
}
|
||||
|
||||
public GapView(Context context, Theme.ResourcesProvider resourcesProvider, String colorKey) {
|
||||
super(context);
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
this.colorKey = colorKey;
|
||||
|
||||
setBackgroundColor(getThemedColor(colorKey));
|
||||
}
|
||||
|
||||
private int getThemedColor(String key) {
|
||||
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
|
||||
return color != null ? color : Theme.getColor(key);
|
||||
this.shadowDrawable = Theme.getThemedDrawable(getContext(), R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow, resourcesProvider);
|
||||
setBackgroundColor(Theme.getColor(colorKey, resourcesProvider));
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
setBackgroundColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
if (shadowDrawable != null) {
|
||||
shadowDrawable.setBounds(0, 0, getWidth(), getHeight());
|
||||
shadowDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -44,8 +44,10 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.LineProgressView;
|
||||
|
|
@ -57,7 +59,7 @@ import org.telegram.ui.Components.spoilers.SpoilersTextView;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
public class AlertDialog extends Dialog implements Drawable.Callback {
|
||||
public class AlertDialog extends Dialog implements Drawable.Callback, NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private View customView;
|
||||
private int customViewHeight = LayoutHelper.WRAP_CONTENT;
|
||||
|
|
@ -594,7 +596,14 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
contentScrollView.addView(scrollContainer, new ScrollView.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
}
|
||||
|
||||
messageTextView = new SpoilersTextView(getContext(), false);
|
||||
messageTextView = new SpoilersTextView(getContext(), false) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(messageTextView);
|
||||
messageTextView.setTextColor(getThemedColor(topAnimationIsNew ? Theme.key_windowBackgroundWhiteGrayText : Theme.key_dialogTextBlack));
|
||||
messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
messageTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
|
||||
|
|
@ -955,6 +964,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
}
|
||||
|
||||
window.setAttributes(params);
|
||||
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1095,8 +1106,18 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.emojiLoaded) {
|
||||
if (messageTextView != null) {
|
||||
messageTextView.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
|
||||
if (onDismissListener != null) {
|
||||
onDismissListener.onDismiss(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public abstract class BaseFragment {
|
|||
protected boolean inTransitionAnimation = false;
|
||||
protected boolean fragmentBeginToShow;
|
||||
private boolean removingFromStack;
|
||||
private PreviewDelegate previewDelegate;
|
||||
|
||||
public BaseFragment() {
|
||||
classGuid = ConnectionsManager.generateClassGuid();
|
||||
|
|
@ -262,7 +263,7 @@ public abstract class BaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
protected ActionBar createActionBar(Context context) {
|
||||
public ActionBar createActionBar(Context context) {
|
||||
ActionBar actionBar = new ActionBar(context, getResourceProvider());
|
||||
actionBar.setBackgroundColor(getThemedColor(Theme.key_actionBarDefault));
|
||||
actionBar.setItemsBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSelector), false);
|
||||
|
|
@ -290,7 +291,11 @@ public abstract class BaseFragment {
|
|||
parentDialog.dismiss();
|
||||
return;
|
||||
}
|
||||
finishFragment(true);
|
||||
if (inPreviewMode && previewDelegate != null) {
|
||||
previewDelegate.finishFragment();
|
||||
} else {
|
||||
finishFragment(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void finishFragment(boolean animated) {
|
||||
|
|
@ -514,6 +519,10 @@ public abstract class BaseFragment {
|
|||
|
||||
}
|
||||
|
||||
public void onSlideProgressFront(boolean isOpen, float progress) {
|
||||
|
||||
}
|
||||
|
||||
public void onTransitionAnimationProgress(boolean isOpen, float progress) {
|
||||
|
||||
}
|
||||
|
|
@ -838,4 +847,25 @@ public abstract class BaseFragment {
|
|||
public void drawOverlay(Canvas canvas, View parent) {
|
||||
|
||||
}
|
||||
|
||||
public void setPreviewOpenedProgress(float progress) {
|
||||
|
||||
}
|
||||
|
||||
public void setPreviewReplaceProgress(float progress) {
|
||||
|
||||
}
|
||||
|
||||
public boolean closeLastFragment() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPreviewDelegate(PreviewDelegate previewDelegate) {
|
||||
this.previewDelegate = previewDelegate;
|
||||
}
|
||||
|
||||
public interface PreviewDelegate {
|
||||
void finishFragment();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -816,7 +816,7 @@ public class BottomSheet extends Dialog {
|
|||
textView.setTextColor(getThemedColor(Theme.key_featuredStickers_buttonText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
textView.setBackground(Theme.AdaptiveRipple.filledRect(getThemedColor(Theme.key_featuredStickers_addButton), 4));
|
||||
textView.setBackground(Theme.AdaptiveRipple.filledRect(getThemedColor(Theme.key_featuredStickers_addButton), 6));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 16, 16, 16, 16));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,7 +245,12 @@ public class EmojiThemes {
|
|||
if (themeInfo == null) {
|
||||
int settingsIndex = getSettingsIndex(index);
|
||||
TLRPC.TL_theme tlTheme = getTlTheme(index);
|
||||
Theme.ThemeInfo baseTheme = Theme.getTheme(Theme.getBaseThemeKey(tlTheme.settings.get(settingsIndex)));
|
||||
Theme.ThemeInfo baseTheme;
|
||||
if (tlTheme != null) {
|
||||
baseTheme = Theme.getTheme(Theme.getBaseThemeKey(tlTheme.settings.get(settingsIndex)));
|
||||
} else {
|
||||
baseTheme = Theme.getTheme("Blue");
|
||||
}
|
||||
themeInfo = new Theme.ThemeInfo(baseTheme);
|
||||
accent = themeInfo.createNewAccent(tlTheme, currentAccount, true, settingsIndex);
|
||||
themeInfo.setCurrentAccentId(accent.id);
|
||||
|
|
|
|||
|
|
@ -385,4 +385,8 @@ public interface INavigationLayout {
|
|||
BACK,
|
||||
MENU
|
||||
}
|
||||
|
||||
interface IBackButtonDrawable {
|
||||
BackButtonState getBackButtonState();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class MenuDrawable extends Drawable {
|
|||
|
||||
canvas.save();
|
||||
|
||||
canvas.translate(getIntrinsicWidth() / 2 - AndroidUtilities.dp(9), getIntrinsicHeight() / 2);
|
||||
canvas.translate(getIntrinsicWidth() / 2 - AndroidUtilities.dp(9) - AndroidUtilities.dp(1) * currentRotation, getIntrinsicHeight() / 2);
|
||||
float endYDiff;
|
||||
float endXDiff;
|
||||
float startYDiff;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
|
|
@ -93,7 +94,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
private boolean wasLayout;
|
||||
|
||||
private boolean rightDrawableOutside;
|
||||
private boolean ellipsizeByGradient;
|
||||
private boolean ellipsizeByGradient, ellipsizeByGradientLeft;
|
||||
private int ellipsizeByGradientWidthDp = 16;
|
||||
private int paddingRight;
|
||||
|
||||
|
|
@ -218,9 +219,17 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
fadePaintBack.setShader(new LinearGradient(0, 0, AndroidUtilities.dp(6), 0, new int[]{0, 0xffffffff}, new float[]{0f, 1f}, Shader.TileMode.CLAMP));
|
||||
fadePaintBack.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
||||
}
|
||||
if ((fadeEllpsizePaint == null || fadeEllpsizePaintWidth != AndroidUtilities.dp(ellipsizeByGradientWidthDp)) && ellipsizeByGradient) {
|
||||
fadeEllpsizePaint = new Paint();
|
||||
fadeEllpsizePaint.setShader(new LinearGradient(0, 0, fadeEllpsizePaintWidth = AndroidUtilities.dp(ellipsizeByGradientWidthDp), 0, new int[]{0, 0xffffffff}, new float[]{0f, 1f}, Shader.TileMode.CLAMP));
|
||||
boolean ellipsizeLeft = getAlignment() == Layout.Alignment.ALIGN_NORMAL && LocaleController.isRTL || getAlignment() == Layout.Alignment.ALIGN_OPPOSITE && !LocaleController.isRTL;
|
||||
if ((fadeEllpsizePaint == null || fadeEllpsizePaintWidth != AndroidUtilities.dp(ellipsizeByGradientWidthDp) || ellipsizeByGradientLeft != ellipsizeLeft) && ellipsizeByGradient) {
|
||||
if (fadeEllpsizePaint == null) {
|
||||
fadeEllpsizePaint = new Paint();
|
||||
}
|
||||
ellipsizeByGradientLeft = ellipsizeLeft;
|
||||
if (ellipsizeByGradientLeft) {
|
||||
fadeEllpsizePaint.setShader(new LinearGradient(0, 0, fadeEllpsizePaintWidth = AndroidUtilities.dp(ellipsizeByGradientWidthDp), 0, new int[]{0xffffffff, 0}, new float[]{0f, 1f}, Shader.TileMode.CLAMP));
|
||||
} else {
|
||||
fadeEllpsizePaint.setShader(new LinearGradient(0, 0, fadeEllpsizePaintWidth = AndroidUtilities.dp(ellipsizeByGradientWidthDp), 0, new int[]{0, 0xffffffff}, new float[]{0f, 1f}, Shader.TileMode.CLAMP));
|
||||
}
|
||||
fadeEllpsizePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
|
||||
}
|
||||
}
|
||||
|
|
@ -254,6 +263,9 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
}
|
||||
|
||||
private void calcOffset(int width) {
|
||||
if (layout == null) {
|
||||
return;
|
||||
}
|
||||
if (layout.getLineCount() > 0) {
|
||||
textWidth = (int) Math.ceil(layout.getLineWidth(0));
|
||||
if (fullLayout != null) {
|
||||
|
|
@ -282,7 +294,7 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
offsetX = -AndroidUtilities.dp(8);
|
||||
}
|
||||
offsetX += getPaddingLeft();
|
||||
textDoesNotFit = textWidth > width;
|
||||
textDoesNotFit = textWidth > (width - paddingRight);
|
||||
|
||||
if (fullLayout != null && fullLayoutAdditionalWidth > 0) {
|
||||
fullLayoutLeftCharactersOffset = fullLayout.getPrimaryHorizontal(0) - firstLineLayout.getPrimaryHorizontal(0);
|
||||
|
|
@ -659,6 +671,34 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
public void setRightPadding(int padding) {
|
||||
if (paddingRight != padding) {
|
||||
paddingRight = padding;
|
||||
|
||||
int width = getMaxTextWidth() - getPaddingLeft() - getPaddingRight() - minusWidth;
|
||||
if (leftDrawable != null) {
|
||||
width -= leftDrawable.getIntrinsicWidth();
|
||||
width -= drawablePadding;
|
||||
}
|
||||
int rightDrawableWidth = 0;
|
||||
if (rightDrawable != null && !rightDrawableOutside) {
|
||||
rightDrawableWidth = (int) (rightDrawable.getIntrinsicWidth() * rightDrawableScale);
|
||||
width -= rightDrawableWidth;
|
||||
width -= drawablePadding;
|
||||
}
|
||||
if (replacedText != null && replacedDrawable != null) {
|
||||
if ((replacingDrawableTextIndex = text.toString().indexOf(replacedText)) < 0) {
|
||||
width -= replacedDrawable.getIntrinsicWidth();
|
||||
width -= drawablePadding;
|
||||
}
|
||||
}
|
||||
if (canHideRightDrawable && rightDrawableWidth != 0 && !rightDrawableOutside) {
|
||||
CharSequence string = TextUtils.ellipsize(text, textPaint, width, TextUtils.TruncateAt.END);
|
||||
if (!text.equals(string)) {
|
||||
rightDrawableHidden = true;
|
||||
width += rightDrawableWidth;
|
||||
width += drawablePadding;
|
||||
}
|
||||
}
|
||||
calcOffset(width);
|
||||
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
|
@ -831,9 +871,12 @@ public class SimpleTextView extends View implements Drawable.Callback {
|
|||
canvas.translate(getMaxTextWidth() - paddingRight - AndroidUtilities.dp(6), 0);
|
||||
canvas.drawRect(0, 0, AndroidUtilities.dp(6), getMeasuredHeight(), fadePaintBack);
|
||||
canvas.restore();
|
||||
} else if (ellipsizeByGradient && (!widthWrapContent || textDoesNotFit) && fadeEllpsizePaint != null) {
|
||||
} else if (ellipsizeByGradient && textDoesNotFit && fadeEllpsizePaint != null) {
|
||||
canvas.save();
|
||||
canvas.translate(getMaxTextWidth() - paddingRight - fadeEllpsizePaintWidth - AndroidUtilities.dp(rightDrawable != null && !(rightDrawable instanceof AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable) && rightDrawableOutside ? +2 : 0), 0);
|
||||
updateFadePaints();
|
||||
if (!ellipsizeByGradientLeft) {
|
||||
canvas.translate(getMaxTextWidth() - paddingRight - fadeEllpsizePaintWidth - AndroidUtilities.dp(rightDrawable != null && !(rightDrawable instanceof AnimatedEmojiDrawable.SwapAnimatedEmojiDrawable) && rightDrawableOutside ? +2 : 0), 0);
|
||||
}
|
||||
canvas.drawRect(0, 0, fadeEllpsizePaintWidth, getMeasuredHeight(), fadeEllpsizePaint);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2913,7 +2913,7 @@ public class Theme {
|
|||
public static Paint avatar_backgroundPaint;
|
||||
|
||||
public static Drawable listSelector;
|
||||
public static Drawable[] avatarDrawables = new Drawable[12];
|
||||
public static Drawable[] avatarDrawables = new Drawable[13];
|
||||
|
||||
public static Drawable moveUpDrawable;
|
||||
|
||||
|
|
@ -3011,6 +3011,7 @@ public class Theme {
|
|||
|
||||
public static TextPaint chat_msgTextPaint;
|
||||
public static TextPaint chat_actionTextPaint;
|
||||
public static TextPaint chat_actionTextPaint2;
|
||||
public static TextPaint chat_unlockExtendedMediaTextPaint;
|
||||
public static TextPaint chat_msgBotButtonPaint;
|
||||
public static TextPaint chat_msgGameTextPaint;
|
||||
|
|
@ -4048,6 +4049,7 @@ public class Theme {
|
|||
public static final String key_paint_chatActionBackgroundSelected = "paintChatActionBackgroundSelected";
|
||||
public static final String key_paint_chatMessageBackgroundSelected = "paintChatMessageBackgroundSelected";
|
||||
public static final String key_paint_chatActionText = "paintChatActionText";
|
||||
public static final String key_paint_chatActionText2 = "paintChatActionText2";
|
||||
public static final String key_paint_chatBotButton = "paintChatBotButton";
|
||||
public static final String key_paint_chatComposeBackground = "paintChatComposeBackground";
|
||||
public static final String key_paint_chatTimeBackground = "paintChatTimeBackground";
|
||||
|
|
@ -8799,6 +8801,7 @@ public class Theme {
|
|||
avatarDrawables[9] = resources.getDrawable(R.drawable.msg_folders_archive);
|
||||
avatarDrawables[10] = resources.getDrawable(R.drawable.msg_folders_private);
|
||||
avatarDrawables[11] = resources.getDrawable(R.drawable.chats_replies);
|
||||
avatarDrawables[12] = resources.getDrawable(R.drawable.other_chats);
|
||||
|
||||
|
||||
if (dialogs_archiveAvatarDrawable != null) {
|
||||
|
|
@ -9091,7 +9094,7 @@ public class Theme {
|
|||
chat_timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
|
||||
final float[] emojiSizePercents = new float[] {.7f, .52f, .37f, .28f, .25f, .19f};
|
||||
final float[] emojiSizePercents = new float[] {.68f, .46f, .34f, .28f, .22f, .19f};
|
||||
for (int i = 0; i < chat_msgTextPaintEmoji.length; ++i) {
|
||||
chat_msgTextPaintEmoji[i] = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
chat_msgTextPaintEmoji[i].setTextSize(AndroidUtilities.dp(emojiSizePercents[i] * 120f));
|
||||
|
|
@ -9185,6 +9188,7 @@ public class Theme {
|
|||
chat_statusRecordPaint.setStyle(Paint.Style.STROKE);
|
||||
chat_statusRecordPaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
chat_actionTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
chat_actionTextPaint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
chat_actionTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
chat_unlockExtendedMediaTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
chat_unlockExtendedMediaTextPaint.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
|
||||
|
|
@ -9208,6 +9212,7 @@ public class Theme {
|
|||
addChatPaint(key_paint_chatActionBackground, chat_actionBackgroundPaint, key_chat_serviceBackground);
|
||||
addChatPaint(key_paint_chatActionBackgroundSelected, chat_actionBackgroundSelectedPaint, key_chat_serviceBackgroundSelected);
|
||||
addChatPaint(key_paint_chatActionText, chat_actionTextPaint, key_chat_serviceText);
|
||||
addChatPaint(key_paint_chatActionText2, chat_actionTextPaint2, key_chat_serviceText);
|
||||
addChatPaint(key_paint_chatBotButton, chat_botButtonPaint, key_chat_botButtonText);
|
||||
addChatPaint(key_paint_chatComposeBackground, chat_composeBackgroundPaint, key_chat_messagePanelBackground);
|
||||
addChatPaint(key_paint_chatTimeBackground, chat_timeBackgroundPaint, key_chat_mediaTimeBackground);
|
||||
|
|
@ -9522,6 +9527,7 @@ public class Theme {
|
|||
chat_instantViewRectPaint.setStrokeWidth(AndroidUtilities.dp(1));
|
||||
chat_pollTimerPaint.setStrokeWidth(AndroidUtilities.dp(1.1f));
|
||||
chat_actionTextPaint.setTextSize(AndroidUtilities.dp(Math.max(16, SharedConfig.fontSize) - 2));
|
||||
chat_actionTextPaint2.setTextSize(AndroidUtilities.dp(Math.max(16, SharedConfig.fontSize) - 2));
|
||||
chat_unlockExtendedMediaTextPaint.setTextSize(AndroidUtilities.dp(Math.max(16, SharedConfig.fontSize)));
|
||||
chat_contextResult_titleTextPaint.setTextSize(AndroidUtilities.dp(15));
|
||||
chat_contextResult_descriptionTextPaint.setTextSize(AndroidUtilities.dp(13));
|
||||
|
|
@ -9583,6 +9589,7 @@ public class Theme {
|
|||
chat_statusPaint.setColor(getColor(key_chat_status));
|
||||
chat_statusRecordPaint.setColor(getColor(key_chat_status));
|
||||
chat_actionTextPaint.setColor(getColor(key_chat_serviceText));
|
||||
chat_actionTextPaint2.setColor(getColor(key_chat_serviceText));
|
||||
chat_actionTextPaint.linkColor = getColor(key_chat_serviceLink);
|
||||
chat_unlockExtendedMediaTextPaint.setColor(getColor(key_chat_serviceText));
|
||||
chat_contextResult_titleTextPaint.setColor(getColor(key_windowBackgroundWhiteBlackText));
|
||||
|
|
@ -9827,6 +9834,7 @@ public class Theme {
|
|||
setDrawableColor(chat_msgStickerViewsDrawable, 0xffffffff);
|
||||
setDrawableColor(chat_msgStickerRepliesDrawable, 0xffffffff);
|
||||
chat_actionTextPaint.setColor(0xffffffff);
|
||||
chat_actionTextPaint2.setColor(0xffffffff);
|
||||
chat_actionTextPaint.linkColor = 0xffffffff;
|
||||
chat_unlockExtendedMediaTextPaint.setColor(0xffffffff);
|
||||
chat_botButtonPaint.setColor(0xffffffff);
|
||||
|
|
@ -9848,6 +9856,7 @@ public class Theme {
|
|||
setDrawableColorByKey(chat_msgStickerViewsDrawable, key_chat_serviceText);
|
||||
setDrawableColorByKey(chat_msgStickerRepliesDrawable, key_chat_serviceText);
|
||||
chat_actionTextPaint.setColor(getColor(key_chat_serviceText));
|
||||
chat_actionTextPaint2.setColor(getColor(key_chat_serviceText));
|
||||
chat_actionTextPaint.linkColor = getColor(key_chat_serviceLink);
|
||||
chat_unlockExtendedMediaTextPaint.setColor(getColor(key_chat_serviceText));
|
||||
setDrawableColorByKey(chat_commentStickerDrawable, key_chat_serviceIcon);
|
||||
|
|
@ -9974,6 +9983,10 @@ public class Theme {
|
|||
setDrawableColorByKey(profile_verifiedCheckDrawable, key_profile_verifiedCheck);
|
||||
}
|
||||
|
||||
public static Drawable getThemedDrawable(Context context, int resId, String key, Theme.ResourcesProvider resourcesProvider) {
|
||||
return getThemedDrawable(context, resId, getColor(key, resourcesProvider));
|
||||
}
|
||||
|
||||
public static Drawable getThemedDrawable(Context context, int resId, String key) {
|
||||
return getThemedDrawable(context, resId, getColor(key));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,11 +24,12 @@ import android.view.ViewGroup;
|
|||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
|
|
@ -57,6 +58,7 @@ import org.telegram.ui.Components.BlurredRecyclerView;
|
|||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
|
||||
import org.telegram.ui.Components.PullForegroundDrawable;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
import org.telegram.ui.DialogsActivity;
|
||||
|
|
@ -64,23 +66,24 @@ import org.telegram.ui.DialogsActivity;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
|
||||
public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements DialogCell.DialogCellDelegate {
|
||||
public final static int VIEW_TYPE_DIALOG = 0,
|
||||
VIEW_TYPE_FLICKER = 1,
|
||||
VIEW_TYPE_RECENTLY_VIEWED = 2,
|
||||
VIEW_TYPE_DIVIDER = 3,
|
||||
VIEW_TYPE_ME_URL = 4,
|
||||
VIEW_TYPE_EMPTY = 5,
|
||||
VIEW_TYPE_USER = 6,
|
||||
VIEW_TYPE_HEADER = 7,
|
||||
VIEW_TYPE_SHADOW = 8,
|
||||
VIEW_TYPE_ARCHIVE = 9,
|
||||
VIEW_TYPE_LAST_EMPTY = 10,
|
||||
VIEW_TYPE_NEW_CHAT_HINT = 11,
|
||||
VIEW_TYPE_TEXT = 12,
|
||||
VIEW_TYPE_CONTACTS_FLICKER = 13,
|
||||
VIEW_TYPE_HEADER_2 = 14;
|
||||
VIEW_TYPE_FLICKER = 1,
|
||||
VIEW_TYPE_RECENTLY_VIEWED = 2,
|
||||
VIEW_TYPE_DIVIDER = 3,
|
||||
VIEW_TYPE_ME_URL = 4,
|
||||
VIEW_TYPE_EMPTY = 5,
|
||||
VIEW_TYPE_USER = 6,
|
||||
VIEW_TYPE_HEADER = 7,
|
||||
VIEW_TYPE_SHADOW = 8,
|
||||
VIEW_TYPE_ARCHIVE = 9,
|
||||
VIEW_TYPE_LAST_EMPTY = 10,
|
||||
VIEW_TYPE_NEW_CHAT_HINT = 11,
|
||||
VIEW_TYPE_TEXT = 12,
|
||||
VIEW_TYPE_CONTACTS_FLICKER = 13,
|
||||
VIEW_TYPE_HEADER_2 = 14;
|
||||
|
||||
private Context mContext;
|
||||
private ArchiveHintCell archiveHintCell;
|
||||
|
|
@ -101,7 +104,11 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
private boolean showArchiveHint;
|
||||
private boolean isReordering;
|
||||
private long lastSortTime;
|
||||
private boolean collapsedView;
|
||||
RecyclerListView recyclerListView;
|
||||
private PullForegroundDrawable pullForegroundDrawable;
|
||||
ArrayList<ItemInternal> itemInternals = new ArrayList<>();
|
||||
ArrayList<ItemInternal> oldItems = new ArrayList<>();
|
||||
|
||||
private Drawable arrowDrawable;
|
||||
|
||||
|
|
@ -109,6 +116,8 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
private boolean forceShowEmptyCell;
|
||||
|
||||
private DialogsActivity parentFragment;
|
||||
private boolean isTransitionSupport;
|
||||
private boolean fromDiffUtils;
|
||||
|
||||
public DialogsAdapter(DialogsActivity fragment, Context context, int type, int folder, boolean onlySelect, ArrayList<Long> selected, int account) {
|
||||
mContext = context;
|
||||
|
|
@ -129,6 +138,10 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
}
|
||||
|
||||
public void setRecyclerListView(RecyclerListView recyclerListView) {
|
||||
this.recyclerListView = recyclerListView;
|
||||
}
|
||||
|
||||
public void setOpenedDialogId(long id) {
|
||||
openedDialogId = id;
|
||||
}
|
||||
|
|
@ -152,8 +165,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
|
||||
public boolean isDataSetChanged() {
|
||||
int current = currentCount;
|
||||
return current != getItemCount() || current == 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setDialogsType(int type) {
|
||||
|
|
@ -171,140 +183,115 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
ArrayList<TLRPC.Dialog> array = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
|
||||
dialogsCount = array.size();
|
||||
if (!forceUpdatingContacts && !forceShowEmptyCell && dialogsType != 7 && dialogsType != 8 && dialogsType != 11 && dialogsCount == 0 && (folderId != 0 || messagesController.isLoadingDialogs(folderId) || !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId))) {
|
||||
onlineContacts = null;
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("DialogsAdapter dialogsCount=" + dialogsCount + " dialogsType=" + dialogsType + " isLoadingDialogs=" + messagesController.isLoadingDialogs(folderId) + " isDialogsEndReached=" + MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId));
|
||||
currentCount = itemInternals.size();
|
||||
return currentCount;
|
||||
}
|
||||
|
||||
public int findDialogPosition(long dialogId) {
|
||||
for (int i = 0; i < itemInternals.size(); i++) {
|
||||
if (itemInternals.get(i).dialog != null && itemInternals.get(i).dialog.id == dialogId) {
|
||||
return i;
|
||||
}
|
||||
if (folderId == 1 && showArchiveHint) {
|
||||
return (currentCount = 2);
|
||||
}
|
||||
return (currentCount = 0);
|
||||
}
|
||||
if (dialogsCount == 0 && messagesController.isLoadingDialogs(folderId)) {
|
||||
return (currentCount = 0);
|
||||
}
|
||||
int count = dialogsCount;
|
||||
if (dialogsType == 7 || dialogsType == 8) {
|
||||
if (dialogsCount == 0) {
|
||||
count++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int fixScrollGap(RecyclerListView animationSupportListView, int p, int offset, boolean hasHidenArchive, boolean oppened) {
|
||||
int itemsToEnd = getItemCount() - p ;
|
||||
int cellHeight = AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72);
|
||||
int bottom = offset + animationSupportListView.getPaddingTop() + itemsToEnd * cellHeight + itemsToEnd - 1;
|
||||
//fix height changed
|
||||
int top = offset + animationSupportListView.getPaddingTop() - p * cellHeight - p;
|
||||
if (oppened) {
|
||||
bottom -= AndroidUtilities.dp(44);
|
||||
} else {
|
||||
if (!messagesController.isDialogsEndReached(folderId) || dialogsCount == 0) {
|
||||
count++;
|
||||
}
|
||||
bottom += AndroidUtilities.dp(44);
|
||||
}
|
||||
boolean hasContacts = false;
|
||||
if (hasHints) {
|
||||
count += 2 + messagesController.hintDialogs.size();
|
||||
} else if (dialogsType == 0 && folderId == 0 && messagesController.isDialogsEndReached(folderId)) {
|
||||
if (ContactsController.getInstance(currentAccount).contacts.isEmpty() && !ContactsController.getInstance(currentAccount).doneLoadingContacts && !forceUpdatingContacts) {
|
||||
onlineContacts = null;
|
||||
if (BuildVars.LOGS_ENABLED) {
|
||||
FileLog.d("DialogsAdapter loadingContacts=" + (ContactsController.getInstance(currentAccount).contacts.isEmpty() && !ContactsController.getInstance(currentAccount).doneLoadingContacts) + "dialogsCount=" + dialogsCount + " dialogsType=" + dialogsType);
|
||||
}
|
||||
return (currentCount = 0);
|
||||
}
|
||||
if (hasHidenArchive) {
|
||||
top += cellHeight;
|
||||
}
|
||||
if (top > animationSupportListView.getPaddingTop()) {
|
||||
return offset + animationSupportListView.getPaddingTop() - top;
|
||||
}
|
||||
if (bottom < animationSupportListView.getMeasuredHeight()) {
|
||||
return offset + (animationSupportListView.getMeasuredHeight() - bottom);
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
if (messagesController.getAllFoldersDialogsCount() <= 10 && ContactsController.getInstance(currentAccount).doneLoadingContacts && !ContactsController.getInstance(currentAccount).contacts.isEmpty()) {
|
||||
if (onlineContacts == null || prevDialogsCount != dialogsCount || prevContactsCount != ContactsController.getInstance(currentAccount).contacts.size()) {
|
||||
onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
|
||||
prevContactsCount = onlineContacts.size();
|
||||
prevDialogsCount = messagesController.dialogs_dict.size();
|
||||
long selfId = UserConfig.getInstance(currentAccount).clientUserId;
|
||||
for (int a = 0, N = onlineContacts.size(); a < N; a++) {
|
||||
long userId = onlineContacts.get(a).user_id;
|
||||
if (userId == selfId || messagesController.dialogs_dict.get(userId) != null) {
|
||||
onlineContacts.remove(a);
|
||||
a--;
|
||||
N--;
|
||||
}
|
||||
}
|
||||
if (onlineContacts.isEmpty()) {
|
||||
onlineContacts = null;
|
||||
}
|
||||
sortOnlineContacts(false);
|
||||
private class ItemInternal extends AdapterWithDiffUtils.Item {
|
||||
|
||||
if (parentFragment.getContactsAlpha() == 0f) {
|
||||
registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||
@Override
|
||||
public void onChanged() {
|
||||
parentFragment.setContactsAlpha(0f);
|
||||
parentFragment.animateContactsAlpha(1f);
|
||||
TLRPC.Dialog dialog;
|
||||
TLRPC.RecentMeUrl recentMeUrl;
|
||||
TLRPC.TL_contact contact;
|
||||
boolean isForumCell;
|
||||
private boolean pinned;
|
||||
private boolean isFolder;
|
||||
|
||||
unregisterAdapterDataObserver(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (onlineContacts != null) {
|
||||
count += onlineContacts.size() + 2;
|
||||
hasContacts = true;
|
||||
}
|
||||
public ItemInternal(int viewType, TLRPC.Dialog dialog) {
|
||||
super(viewType, true);
|
||||
this.dialog = dialog;
|
||||
if (dialog != null) {
|
||||
pinned = dialog.pinned;
|
||||
isFolder = dialog.isFolder;
|
||||
isForumCell = MessagesController.getInstance(currentAccount).isForum(dialog.id);
|
||||
}
|
||||
}
|
||||
if (folderId == 0 && !hasContacts && dialogsCount == 0 && forceUpdatingContacts) {
|
||||
count += 3;
|
||||
}
|
||||
if (folderId == 0 && onlineContacts != null) {
|
||||
if (!hasContacts) {
|
||||
onlineContacts = null;
|
||||
}
|
||||
}
|
||||
if (folderId == 1 && showArchiveHint) {
|
||||
count += 2;
|
||||
}
|
||||
if (folderId == 0 && dialogsCount != 0) {
|
||||
count++;
|
||||
if (dialogsCount > 10 && dialogsType == 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (dialogsType == 11 || dialogsType == 13) {
|
||||
count += 2;
|
||||
} else if (dialogsType == 12) {
|
||||
count += 1;
|
||||
}
|
||||
currentCount = count;
|
||||
|
||||
return count;
|
||||
public ItemInternal(int viewTypeMeUrl, TLRPC.RecentMeUrl recentMeUrl) {
|
||||
super(viewTypeMeUrl, true);
|
||||
this.recentMeUrl = recentMeUrl;
|
||||
}
|
||||
|
||||
public ItemInternal(int viewTypeEmpty) {
|
||||
super(viewTypeEmpty, true);
|
||||
}
|
||||
|
||||
public ItemInternal(int viewTypeUser, TLRPC.TL_contact tl_contact) {
|
||||
super(viewTypeUser, true);
|
||||
contact = tl_contact;
|
||||
}
|
||||
|
||||
boolean compare(ItemInternal itemInternal) {
|
||||
if (viewType != itemInternal.viewType) {
|
||||
return false;
|
||||
}
|
||||
if (viewType == VIEW_TYPE_DIALOG) {
|
||||
return dialog != null && itemInternal.dialog != null && dialog.id == itemInternal.dialog.id
|
||||
&& isFolder == itemInternal.isFolder &&
|
||||
isForumCell == itemInternal.isForumCell &&
|
||||
pinned == itemInternal.pinned;
|
||||
}
|
||||
if (viewType == VIEW_TYPE_HEADER_2) {
|
||||
return dialog != null && itemInternal.dialog != null && dialog.id == itemInternal.dialog.id && dialog.isFolder == itemInternal.dialog.isFolder;
|
||||
}
|
||||
if (viewType == VIEW_TYPE_ME_URL) {
|
||||
return recentMeUrl != null && itemInternal.recentMeUrl != null && recentMeUrl.url != null && recentMeUrl.url.equals(recentMeUrl.url);
|
||||
}
|
||||
if (viewType == VIEW_TYPE_USER) {
|
||||
return contact != null && itemInternal.contact != null && contact.user_id == itemInternal.contact.user_id;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(dialog, recentMeUrl, contact);
|
||||
}
|
||||
}
|
||||
|
||||
public TLObject getItem(int i) {
|
||||
if (onlineContacts != null && (dialogsCount == 0 || i >= dialogsCount)) {
|
||||
if (dialogsCount == 0) {
|
||||
i -= 3;
|
||||
} else {
|
||||
i -= dialogsCount + 2;
|
||||
}
|
||||
if (i < 0 || i >= onlineContacts.size()) {
|
||||
return null;
|
||||
}
|
||||
return MessagesController.getInstance(currentAccount).getUser(onlineContacts.get(i).user_id);
|
||||
}
|
||||
if (showArchiveHint) {
|
||||
i -= 2;
|
||||
} else if (dialogsType == 11 || dialogsType == 13) {
|
||||
i -= 2;
|
||||
} else if (dialogsType == 12) {
|
||||
i -= 1;
|
||||
}
|
||||
ArrayList<TLRPC.Dialog> arrayList = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
|
||||
if (hasHints) {
|
||||
int count = MessagesController.getInstance(currentAccount).hintDialogs.size();
|
||||
if (i < 2 + count) {
|
||||
return MessagesController.getInstance(currentAccount).hintDialogs.get(i - 1);
|
||||
} else {
|
||||
i -= count + 2;
|
||||
}
|
||||
}
|
||||
if (i < 0 || i >= arrayList.size()) {
|
||||
if (i < 0 || i >= itemInternals.size()) {
|
||||
return null;
|
||||
}
|
||||
return arrayList.get(i);
|
||||
if (itemInternals.get(i).dialog != null) {
|
||||
return itemInternals.get(i).dialog;
|
||||
} else if (itemInternals.get(i).contact != null) {
|
||||
return itemInternals.get(i).contact;
|
||||
} else if (itemInternals.get(i).recentMeUrl != null) {
|
||||
return itemInternals.get(i).recentMeUrl;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void sortOnlineContacts(boolean notify) {
|
||||
|
|
@ -367,6 +354,10 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
dialogsListFrozen = frozen;
|
||||
}
|
||||
|
||||
public boolean getDialogsListIsFrozen() {
|
||||
return dialogsListFrozen;
|
||||
}
|
||||
|
||||
public ViewPager getArchiveHintCellPager() {
|
||||
return archiveHintCell != null ? archiveHintCell.getViewPager() : null;
|
||||
}
|
||||
|
|
@ -375,19 +366,71 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
hasHints = folderId == 0 && dialogsType == 0 && !isOnlySelect && !MessagesController.getInstance(currentAccount).hintDialogs.isEmpty();
|
||||
}
|
||||
|
||||
public void updateList(RecyclerListView recyclerListView) {
|
||||
oldItems.clear();
|
||||
oldItems.addAll(itemInternals);
|
||||
updateItemList();
|
||||
|
||||
if (recyclerListView != null && recyclerListView.getChildCount() > 0) {
|
||||
LinearLayoutManager layoutManager = ((LinearLayoutManager) recyclerListView.getLayoutManager());
|
||||
View view = null;
|
||||
int position = -1;
|
||||
int top = Integer.MAX_VALUE;
|
||||
for (int i = 0; i < recyclerListView.getChildCount(); i++) {
|
||||
int childPosition = recyclerListView.getChildAdapterPosition(recyclerListView.getChildAt(i));
|
||||
View child = recyclerListView.getChildAt(i);
|
||||
if (childPosition != RecyclerListView.NO_POSITION && child.getTop() < top) {
|
||||
view = child;
|
||||
position = childPosition;
|
||||
top = child.getTop();
|
||||
}
|
||||
}
|
||||
if (view != null) {
|
||||
layoutManager.scrollToPositionWithOffset(position, view.getTop() - recyclerListView.getPaddingTop());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fromDiffUtils = true;
|
||||
DiffUtil.calculateDiff(new DiffUtil.Callback() {
|
||||
@Override
|
||||
public int getOldListSize() {
|
||||
return oldItems.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewListSize() {
|
||||
return itemInternals.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
|
||||
return oldItems.get(oldItemPosition).compare(itemInternals.get(newItemPosition));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
|
||||
return oldItems.get(oldItemPosition).viewType == itemInternals.get(newItemPosition).viewType;
|
||||
}
|
||||
}).dispatchUpdatesTo(this);
|
||||
fromDiffUtils = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
updateHasHints();
|
||||
updateItemList();
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
|
||||
if (holder.itemView instanceof DialogCell) {
|
||||
DialogCell dialogCell = (DialogCell) holder.itemView;
|
||||
dialogCell.onReorderStateChanged(isReordering, false);
|
||||
int position = fixPosition(holder.getAdapterPosition());
|
||||
dialogCell.setDialogIndex(position);
|
||||
// dialogCell.setDialogIndex(position);
|
||||
// dialogCell.collapsed = collapsedView;
|
||||
dialogCell.checkCurrentDialogIndex(dialogsListFrozen);
|
||||
dialogCell.setChecked(selectedDialogs.contains(dialogCell.getDialogId()), false);
|
||||
}
|
||||
|
|
@ -413,6 +456,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
dialogCell.setArchivedPullAnimation(pullForegroundDrawable);
|
||||
dialogCell.setPreloader(preloader);
|
||||
dialogCell.setDialogCellDelegate(this);
|
||||
dialogCell.setIsTransitionSupport(isTransitionSupport);
|
||||
view = dialogCell;
|
||||
}
|
||||
break;
|
||||
|
|
@ -564,6 +608,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
|
||||
public int lastDialogsEmptyType = -1;
|
||||
|
||||
public int dialogsEmptyType() {
|
||||
if (dialogsType == 7 || dialogsType == 8) {
|
||||
if (MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) {
|
||||
|
|
@ -643,6 +688,11 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
cell.setChecked(selectedDialogs.contains(dialog.id), false);
|
||||
cell.setDialog(dialog, dialogsType, folderId);
|
||||
cell.checkHeight();
|
||||
if (cell.collapsed != collapsedView) {
|
||||
cell.collapsed = collapsedView;
|
||||
cell.requestLayout();
|
||||
}
|
||||
if (preloader != null && i < 10) {
|
||||
preloader.add(dialog.id);
|
||||
}
|
||||
|
|
@ -681,13 +731,8 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
case VIEW_TYPE_USER: {
|
||||
UserCell cell = (UserCell) holder.itemView;
|
||||
int position;
|
||||
if (dialogsCount == 0) {
|
||||
position = i - 3;
|
||||
} else {
|
||||
position = i - dialogsCount - 2;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(onlineContacts.get(position).user_id);
|
||||
TLRPC.TL_contact contact = (TLRPC.TL_contact) getItem(i);
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(contact.user_id);
|
||||
cell.setData(user, null, null, 0);
|
||||
break;
|
||||
}
|
||||
|
|
@ -755,113 +800,30 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (dialogsCount == 0 && forceUpdatingContacts) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
return VIEW_TYPE_EMPTY;
|
||||
case 1:
|
||||
return VIEW_TYPE_SHADOW;
|
||||
case 2:
|
||||
return VIEW_TYPE_HEADER;
|
||||
case 3:
|
||||
return VIEW_TYPE_CONTACTS_FLICKER;
|
||||
}
|
||||
} else if (onlineContacts != null) {
|
||||
if (dialogsCount == 0) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_EMPTY;
|
||||
} else if (i == 1) {
|
||||
return VIEW_TYPE_SHADOW;
|
||||
} else if (i == 2) {
|
||||
return VIEW_TYPE_HEADER;
|
||||
}
|
||||
} else {
|
||||
if (i < dialogsCount) {
|
||||
return VIEW_TYPE_DIALOG;
|
||||
} else if (i == dialogsCount) {
|
||||
return VIEW_TYPE_SHADOW;
|
||||
} else if (i == dialogsCount + 1) {
|
||||
return VIEW_TYPE_HEADER;
|
||||
} else if (i == currentCount - 1) {
|
||||
return VIEW_TYPE_LAST_EMPTY;
|
||||
}
|
||||
}
|
||||
return VIEW_TYPE_USER;
|
||||
} else if (hasHints) {
|
||||
int count = MessagesController.getInstance(currentAccount).hintDialogs.size();
|
||||
if (i < 2 + count) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_RECENTLY_VIEWED;
|
||||
} else if (i == 1 + count) {
|
||||
return VIEW_TYPE_DIVIDER;
|
||||
}
|
||||
return VIEW_TYPE_ME_URL;
|
||||
} else {
|
||||
i -= 2 + count;
|
||||
}
|
||||
} else if (showArchiveHint) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_ARCHIVE;
|
||||
} else if (i == 1) {
|
||||
return VIEW_TYPE_SHADOW;
|
||||
} else {
|
||||
i -= 2;
|
||||
}
|
||||
} else if (dialogsType == 11 || dialogsType == 13) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_HEADER;
|
||||
} else if (i == 1) {
|
||||
return VIEW_TYPE_TEXT;
|
||||
} else {
|
||||
i -= 2;
|
||||
}
|
||||
} else if (dialogsType == 12) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_HEADER;
|
||||
} else {
|
||||
i -= 1;
|
||||
}
|
||||
}
|
||||
if (folderId == 0 && dialogsCount > 10 && i == currentCount - 2 && dialogsType == 0) {
|
||||
return VIEW_TYPE_NEW_CHAT_HINT;
|
||||
}
|
||||
int size = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen).size();
|
||||
if (i == size) {
|
||||
if (!forceShowEmptyCell && dialogsType != 7 && dialogsType != 8 && !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) {
|
||||
return VIEW_TYPE_FLICKER;
|
||||
} else if (size == 0) {
|
||||
return VIEW_TYPE_EMPTY;
|
||||
} else {
|
||||
return VIEW_TYPE_LAST_EMPTY;
|
||||
}
|
||||
} else if (i > size) {
|
||||
return VIEW_TYPE_LAST_EMPTY;
|
||||
}
|
||||
if (dialogsType == 2 && getItem(i) instanceof DialogsActivity.DialogsHeader) {
|
||||
return VIEW_TYPE_HEADER_2;
|
||||
}
|
||||
return VIEW_TYPE_DIALOG;
|
||||
return itemInternals.get(i).viewType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyItemMoved(int fromPosition, int toPosition) {
|
||||
ArrayList<TLRPC.Dialog> dialogs = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, false);
|
||||
int fromIndex = fixPosition(fromPosition);
|
||||
int toIndex = fixPosition(toPosition);
|
||||
TLRPC.Dialog fromDialog = dialogs.get(fromIndex);
|
||||
TLRPC.Dialog toDialog = dialogs.get(toIndex);
|
||||
if (dialogsType == 7 || dialogsType == 8) {
|
||||
MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
|
||||
int idx1 = filter.pinnedDialogs.get(fromDialog.id);
|
||||
int idx2 = filter.pinnedDialogs.get(toDialog.id);
|
||||
filter.pinnedDialogs.put(fromDialog.id, idx2);
|
||||
filter.pinnedDialogs.put(toDialog.id, idx1);
|
||||
} else {
|
||||
int oldNum = fromDialog.pinnedNum;
|
||||
fromDialog.pinnedNum = toDialog.pinnedNum;
|
||||
toDialog.pinnedNum = oldNum;
|
||||
if (!fromDiffUtils) {
|
||||
ArrayList<TLRPC.Dialog> dialogs = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, false);
|
||||
int fromIndex = fixPosition(fromPosition);
|
||||
int toIndex = fixPosition(toPosition);
|
||||
TLRPC.Dialog fromDialog = dialogs.get(fromIndex);
|
||||
TLRPC.Dialog toDialog = dialogs.get(toIndex);
|
||||
if (dialogsType == 7 || dialogsType == 8) {
|
||||
MessagesController.DialogFilter filter = MessagesController.getInstance(currentAccount).selectedDialogFilter[dialogsType == 8 ? 1 : 0];
|
||||
int idx1 = filter.pinnedDialogs.get(fromDialog.id);
|
||||
int idx2 = filter.pinnedDialogs.get(toDialog.id);
|
||||
filter.pinnedDialogs.put(fromDialog.id, idx2);
|
||||
filter.pinnedDialogs.put(toDialog.id, idx1);
|
||||
} else {
|
||||
int oldNum = fromDialog.pinnedNum;
|
||||
fromDialog.pinnedNum = toDialog.pinnedNum;
|
||||
toDialog.pinnedNum = oldNum;
|
||||
}
|
||||
Collections.swap(dialogs, fromIndex, toIndex);
|
||||
}
|
||||
Collections.swap(dialogs, fromIndex, toIndex);
|
||||
super.notifyItemMoved(fromPosition, toPosition);
|
||||
}
|
||||
|
||||
|
|
@ -902,6 +864,34 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
return selectedDialogs.isEmpty();
|
||||
}
|
||||
|
||||
public void setIsTransitionSupport() {
|
||||
this.isTransitionSupport = true;
|
||||
}
|
||||
|
||||
public void setCollapsedView(boolean collapsedView, RecyclerListView listView) {
|
||||
this.collapsedView = collapsedView;
|
||||
for (int i = 0; i < listView.getChildCount(); i++) {
|
||||
if (listView.getChildAt(i) instanceof DialogCell) {
|
||||
((DialogCell) listView.getChildAt(i)).collapsed = collapsedView;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < listView.getCachedChildCount(); i++) {
|
||||
if (listView.getCachedChildAt(i) instanceof DialogCell) {
|
||||
((DialogCell) listView.getCachedChildAt(i)).collapsed = collapsedView;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < listView.getHiddenChildCount(); i++) {
|
||||
if (listView.getHiddenChildAt(i) instanceof DialogCell) {
|
||||
((DialogCell) listView.getHiddenChildAt(i)).collapsed = collapsedView;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < listView.getAttachedScrapChildCount(); i++) {
|
||||
if (listView.getAttachedScrapChildAt(i) instanceof DialogCell) {
|
||||
((DialogCell) listView.getAttachedScrapChildAt(i)).collapsed = collapsedView;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class DialogsPreloader {
|
||||
|
||||
private final int MAX_REQUEST_COUNT = 4;
|
||||
|
|
@ -973,7 +963,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
|
||||
private boolean preloadIsAvilable() {
|
||||
return false;
|
||||
// return DownloadController.getInstance(UserConfig.selectedAccount).getCurrentDownloadMask() != 0;
|
||||
// return DownloadController.getInstance(UserConfig.selectedAccount).getCurrentDownloadMask() != 0;
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
|
|
@ -1029,7 +1019,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int size = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen).size();
|
||||
int size = itemInternals.size();
|
||||
boolean hasArchive = dialogsType == 0 && MessagesController.getInstance(currentAccount).dialogs_dict.get(DialogObject.makeFolderDialogId(1)) != null;
|
||||
View parent = (View) getParent();
|
||||
int height;
|
||||
|
|
@ -1051,7 +1041,17 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
}
|
||||
height -= blurOffset;
|
||||
int cellHeight = AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72);
|
||||
int dialogsHeight = size * cellHeight + (size - 1);
|
||||
int dialogsHeight = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (itemInternals.get(i).viewType == VIEW_TYPE_DIALOG) {
|
||||
if (itemInternals.get(i).isForumCell && !collapsedView) {
|
||||
dialogsHeight += AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 86 : 91);
|
||||
} else {
|
||||
dialogsHeight += cellHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
dialogsHeight += size - 1;
|
||||
if (onlineContacts != null) {
|
||||
dialogsHeight += onlineContacts.size() * AndroidUtilities.dp(58) + (onlineContacts.size() - 1) + AndroidUtilities.dp(52);
|
||||
}
|
||||
|
|
@ -1079,4 +1079,108 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
|
|||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void updateItemList() {
|
||||
itemInternals.clear();
|
||||
updateHasHints();
|
||||
|
||||
MessagesController messagesController = MessagesController.getInstance(currentAccount);
|
||||
ArrayList<TLRPC.Dialog> array = parentFragment.getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
|
||||
dialogsCount = array.size();
|
||||
|
||||
if (!hasHints && dialogsType == 0 && folderId == 0 && messagesController.isDialogsEndReached(folderId) && !forceUpdatingContacts) {
|
||||
if (messagesController.getAllFoldersDialogsCount() <= 10 && ContactsController.getInstance(currentAccount).doneLoadingContacts && !ContactsController.getInstance(currentAccount).contacts.isEmpty()) {
|
||||
onlineContacts = new ArrayList<>(ContactsController.getInstance(currentAccount).contacts);
|
||||
long selfId = UserConfig.getInstance(currentAccount).clientUserId;
|
||||
for (int a = 0, N = onlineContacts.size(); a < N; a++) {
|
||||
long userId = onlineContacts.get(a).user_id;
|
||||
if (userId == selfId || messagesController.dialogs_dict.get(userId) != null) {
|
||||
onlineContacts.remove(a);
|
||||
a--;
|
||||
N--;
|
||||
}
|
||||
}
|
||||
if (onlineContacts.isEmpty()) {
|
||||
onlineContacts = null;
|
||||
} else {
|
||||
sortOnlineContacts(false);
|
||||
}
|
||||
} else {
|
||||
onlineContacts = null;
|
||||
}
|
||||
}
|
||||
|
||||
boolean stopUpdate = false;
|
||||
if (collapsedView || isTransitionSupport) {
|
||||
for (int k = 0; k < array.size(); k++) {
|
||||
if (dialogsType == 2 && array.get(k) instanceof DialogsActivity.DialogsHeader) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER_2, array.get(k)));
|
||||
} else {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_DIALOG, array.get(k)));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (dialogsCount == 0 && forceUpdatingContacts) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_CONTACTS_FLICKER));
|
||||
} else if (onlineContacts != null) {
|
||||
if (dialogsCount == 0) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
} else {
|
||||
for (int k = 0; k < array.size(); k++) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_DIALOG, array.get(k)));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
for (int k = 0; k < onlineContacts.size(); k++) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_USER, onlineContacts.get(k)));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY));
|
||||
}
|
||||
stopUpdate = true;
|
||||
} else if (hasHints) {
|
||||
int count = MessagesController.getInstance(currentAccount).hintDialogs.size();
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_RECENTLY_VIEWED));
|
||||
for (int k = 0; k < count; k++) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_ME_URL, MessagesController.getInstance(currentAccount).hintDialogs.get(k)));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_DIVIDER));
|
||||
} else if (showArchiveHint) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_ARCHIVE));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW));
|
||||
} else if (dialogsType == 11 || dialogsType == 13) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_TEXT));
|
||||
} else if (dialogsType == 12) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER));
|
||||
}
|
||||
|
||||
if (!stopUpdate) {
|
||||
for (int k = 0; k < array.size(); k++) {
|
||||
if (dialogsType == 2 && array.get(k) instanceof DialogsActivity.DialogsHeader) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER_2, array.get(k)));
|
||||
} else {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_DIALOG, array.get(k)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!forceShowEmptyCell && dialogsType != 7 && dialogsType != 8 && !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_FLICKER));
|
||||
} else if (dialogsCount == 0) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_EMPTY));
|
||||
} else {
|
||||
if (folderId == 0 && dialogsCount > 10 && dialogsType == 0) {
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_NEW_CHAT_HINT));
|
||||
}
|
||||
itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import org.telegram.ui.Cells.HashtagSearchCell;
|
|||
import org.telegram.ui.Cells.HintDialogCell;
|
||||
import org.telegram.ui.Cells.ProfileSearchCell;
|
||||
import org.telegram.ui.Cells.TextCell;
|
||||
import org.telegram.ui.Cells.TopicSearchCell;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
import org.telegram.ui.Components.ForegroundColorSpanThemable;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
|
|
@ -64,25 +65,32 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
private final int VIEW_TYPE_PROFILE_CELL = 0;
|
||||
private final int VIEW_TYPE_GRAY_SECTION = 1;
|
||||
private final int VIEW_TYPE_DIALOG_CELL = 2;
|
||||
private final int VIEW_TYPE_LOADING = 3;
|
||||
private final int VIEW_TYPE_HASHTAG_CELL = 4;
|
||||
private final int VIEW_TYPE_CATEGORY_LIST = 5;
|
||||
private final int VIEW_TYPE_ADD_BY_PHONE = 6;
|
||||
private final int VIEW_TYPE_TOPIC_CELL = 3;
|
||||
private final int VIEW_TYPE_LOADING = 4;
|
||||
private final int VIEW_TYPE_HASHTAG_CELL = 5;
|
||||
private final int VIEW_TYPE_CATEGORY_LIST = 6;
|
||||
private final int VIEW_TYPE_ADD_BY_PHONE = 7;
|
||||
|
||||
private Context mContext;
|
||||
private Runnable searchRunnable;
|
||||
private Runnable searchRunnable2;
|
||||
private ArrayList<Object> searchResult = new ArrayList<>();
|
||||
private ArrayList<TLRPC.TL_forumTopic> searchTopics = new ArrayList<>();
|
||||
private ArrayList<CharSequence> searchResultNames = new ArrayList<>();
|
||||
private ArrayList<MessageObject> searchForumResultMessages = new ArrayList<>();
|
||||
private ArrayList<MessageObject> searchResultMessages = new ArrayList<>();
|
||||
private ArrayList<String> searchResultHashtags = new ArrayList<>();
|
||||
private String lastSearchText;
|
||||
private boolean searchWas;
|
||||
private int reqId = 0;
|
||||
private int lastReqId;
|
||||
private DialogsSearchAdapterDelegate delegate;
|
||||
private int reqForumId = 0;
|
||||
private int lastForumReqId;
|
||||
public DialogsSearchAdapterDelegate delegate;
|
||||
private int needMessagesSearch;
|
||||
private boolean messagesSearchEndReached;
|
||||
private boolean localMessagesSearchEndReached;
|
||||
public int localMessagesLoadingRow = -1;
|
||||
private String lastMessagesSearchString;
|
||||
private String currentMessagesQuery;
|
||||
private int nextSearchRate;
|
||||
|
|
@ -105,6 +113,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
|
||||
private ArrayList<RecentSearchObject> recentSearchObjects = new ArrayList<>();
|
||||
private ArrayList<RecentSearchObject> filteredRecentSearchObjects = new ArrayList<>();
|
||||
private ArrayList<RecentSearchObject> filtered2RecentSearchObjects = new ArrayList<>();
|
||||
private String filteredRecentQuery = null;
|
||||
private LongSparseArray<RecentSearchObject> recentSearchObjectsById = new LongSparseArray<>();
|
||||
private ArrayList<FiltersView.DateData> localTipDates = new ArrayList<>();
|
||||
|
|
@ -136,6 +145,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
void needClearList();
|
||||
void runResultsEnterAnimation();
|
||||
boolean isSelected(long dialogId);
|
||||
long getSearchForumDialogId();
|
||||
}
|
||||
|
||||
public static class CategoryAdapterRecycler extends RecyclerListView.SelectionAdapter {
|
||||
|
|
@ -259,20 +269,144 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
|
||||
public boolean isMessagesSearchEndReached() {
|
||||
return messagesSearchEndReached;
|
||||
return (delegate.getSearchForumDialogId() == 0 || localMessagesSearchEndReached) && messagesSearchEndReached;
|
||||
}
|
||||
|
||||
public void loadMoreSearchMessages() {
|
||||
if (reqId != 0) {
|
||||
if (reqForumId != 0 && reqId != 0) {
|
||||
return;
|
||||
}
|
||||
searchMessagesInternal(lastMessagesSearchString, lastMessagesSearchId);
|
||||
if (delegate != null && delegate.getSearchForumDialogId() != 0 && !localMessagesSearchEndReached) {
|
||||
searchForumMessagesInternal(lastMessagesSearchString, lastMessagesSearchId);
|
||||
} else {
|
||||
searchMessagesInternal(lastMessagesSearchString, lastMessagesSearchId);
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastSearchString() {
|
||||
return lastMessagesSearchString;
|
||||
}
|
||||
|
||||
private void searchForumMessagesInternal(final String query, int searchId) {
|
||||
if (delegate == null || delegate.getSearchForumDialogId() == 0) {
|
||||
return;
|
||||
}
|
||||
if (needMessagesSearch == 0 || TextUtils.isEmpty(lastMessagesSearchString) && TextUtils.isEmpty(query)) {
|
||||
return;
|
||||
}
|
||||
if (reqForumId != 0) {
|
||||
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqForumId, true);
|
||||
reqForumId = 0;
|
||||
}
|
||||
if (TextUtils.isEmpty(query)) {
|
||||
filteredRecentQuery = null;
|
||||
searchResultMessages.clear();
|
||||
searchForumResultMessages.clear();
|
||||
lastForumReqId = 0;
|
||||
lastMessagesSearchString = null;
|
||||
searchWas = false;
|
||||
notifyDataSetChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
final long dialogId = delegate.getSearchForumDialogId();
|
||||
|
||||
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
|
||||
req.limit = 20;
|
||||
req.q = query;
|
||||
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(dialogId);
|
||||
if (query.equals(lastMessagesSearchString) && !searchForumResultMessages.isEmpty()) {
|
||||
req.add_offset = searchForumResultMessages.size();
|
||||
}
|
||||
lastMessagesSearchString = query;
|
||||
final int currentReqId = ++lastForumReqId;
|
||||
reqForumId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
||||
final ArrayList<MessageObject> messageObjects = new ArrayList<>();
|
||||
if (error == null) {
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
LongSparseArray<TLRPC.Chat> chatsMap = new LongSparseArray<>();
|
||||
LongSparseArray<TLRPC.User> usersMap = new LongSparseArray<>();
|
||||
for (int a = 0; a < res.chats.size(); a++) {
|
||||
TLRPC.Chat chat = res.chats.get(a);
|
||||
chatsMap.put(chat.id, chat);
|
||||
}
|
||||
for (int a = 0; a < res.users.size(); a++) {
|
||||
TLRPC.User user = res.users.get(a);
|
||||
usersMap.put(user.id, user);
|
||||
}
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
MessageObject messageObject = new MessageObject(currentAccount, message, usersMap, chatsMap, false, true);
|
||||
messageObjects.add(messageObject);
|
||||
messageObject.setQuery(query);
|
||||
}
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (currentReqId == lastForumReqId && (searchId <= 0 || searchId == lastSearchId)) {
|
||||
waitingResponseCount--;
|
||||
if (error == null) {
|
||||
currentMessagesQuery = query;
|
||||
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
|
||||
MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true);
|
||||
MessagesController.getInstance(currentAccount).putUsers(res.users, false);
|
||||
MessagesController.getInstance(currentAccount).putChats(res.chats, false);
|
||||
if (req.add_offset == 0) {
|
||||
searchForumResultMessages.clear();
|
||||
}
|
||||
nextSearchRate = res.next_rate;
|
||||
for (int a = 0; a < res.messages.size(); a++) {
|
||||
TLRPC.Message message = res.messages.get(a);
|
||||
long did = MessageObject.getDialogId(message);
|
||||
int maxId = MessagesController.getInstance(currentAccount).deletedHistory.get(did);
|
||||
if (maxId != 0 && message.id <= maxId) {
|
||||
continue;
|
||||
}
|
||||
searchForumResultMessages.add(messageObjects.get(a));
|
||||
}
|
||||
searchWas = true;
|
||||
localMessagesSearchEndReached = res.messages.size() != 20;
|
||||
if (searchId > 0) {
|
||||
lastMessagesSearchId = searchId;
|
||||
if (lastLocalSearchId != searchId) {
|
||||
searchResult.clear();
|
||||
}
|
||||
if (lastGlobalSearchId != searchId) {
|
||||
searchAdapterHelper.clear();
|
||||
}
|
||||
}
|
||||
searchAdapterHelper.mergeResults(searchResult, filtered2RecentSearchObjects);
|
||||
if (delegate != null) {
|
||||
delegate.searchStateChanged(waitingResponseCount > 0, true);
|
||||
delegate.runResultsEnterAnimation();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
reqForumId = 0;
|
||||
});
|
||||
}, ConnectionsManager.RequestFlagFailOnServerErrors);
|
||||
}
|
||||
|
||||
private void searchTopics(final String query) {
|
||||
searchTopics.clear();
|
||||
if (delegate == null || delegate.getSearchForumDialogId() == 0) {
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(query)) {
|
||||
long dialogId = delegate.getSearchForumDialogId();
|
||||
ArrayList<TLRPC.TL_forumTopic> topics = MessagesController.getInstance(currentAccount).getTopicsController().getTopics(-dialogId);
|
||||
String searchTrimmed = query.trim();
|
||||
for (int i = 0; i < topics.size(); i++) {
|
||||
if (topics.get(i) != null && topics.get(i).title.toLowerCase().contains(searchTrimmed)) {
|
||||
searchTopics.add(topics.get(i));
|
||||
topics.get(i).searchQuery = searchTrimmed;
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void searchMessagesInternal(final String query, int searchId) {
|
||||
if (needMessagesSearch == 0 || TextUtils.isEmpty(lastMessagesSearchString) && TextUtils.isEmpty(query)) {
|
||||
return;
|
||||
|
|
@ -284,6 +418,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (TextUtils.isEmpty(query)) {
|
||||
filteredRecentQuery = null;
|
||||
searchResultMessages.clear();
|
||||
searchForumResultMessages.clear();
|
||||
lastReqId = 0;
|
||||
lastMessagesSearchString = null;
|
||||
searchWas = false;
|
||||
|
|
@ -291,7 +426,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
return;
|
||||
} else {
|
||||
filterRecent(query);
|
||||
searchAdapterHelper.mergeResults(searchResult, filteredRecentSearchObjects);
|
||||
searchAdapterHelper.mergeResults(searchResult, filtered2RecentSearchObjects);
|
||||
}
|
||||
|
||||
final TLRPC.TL_messages_searchGlobal req = new TLRPC.TL_messages_searchGlobal();
|
||||
|
|
@ -354,7 +489,21 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (maxId != 0 && message.id <= maxId) {
|
||||
continue;
|
||||
}
|
||||
searchResultMessages.add(messageObjects.get(a));
|
||||
MessageObject msg = messageObjects.get(a);
|
||||
if (!searchForumResultMessages.isEmpty()) {
|
||||
boolean foundDuplicate = false;
|
||||
for (int i = 0; i < searchForumResultMessages.size(); ++i) {
|
||||
MessageObject msg2 = searchForumResultMessages.get(i);
|
||||
if (msg2 != null && msg != null && msg.getId() == msg2.getId() && msg.getDialogId() == msg2.getDialogId()) {
|
||||
foundDuplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundDuplicate) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
searchResultMessages.add(msg);
|
||||
long dialog_id = MessageObject.getDialogId(message);
|
||||
ConcurrentHashMap<Long, Integer> read_max = message.out ? MessagesController.getInstance(currentAccount).dialogs_read_outbox_max : MessagesController.getInstance(currentAccount).dialogs_read_inbox_max;
|
||||
Integer value = read_max.get(dialog_id);
|
||||
|
|
@ -375,7 +524,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
searchAdapterHelper.clear();
|
||||
}
|
||||
}
|
||||
searchAdapterHelper.mergeResults(searchResult, filteredRecentSearchObjects);
|
||||
searchAdapterHelper.mergeResults(searchResult, filtered2RecentSearchObjects);
|
||||
if (delegate != null) {
|
||||
delegate.searchStateChanged(waitingResponseCount > 0, true);
|
||||
delegate.runResultsEnterAnimation();
|
||||
|
|
@ -545,8 +694,8 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
public void clearRecentSearch() {
|
||||
StringBuilder queryFilter = null;
|
||||
if (searchWas) {
|
||||
while (filteredRecentSearchObjects.size() > 0) {
|
||||
RecentSearchObject obj = filteredRecentSearchObjects.remove(0);
|
||||
while (filtered2RecentSearchObjects.size() > 0) {
|
||||
RecentSearchObject obj = filtered2RecentSearchObjects.remove(0);
|
||||
recentSearchObjects.remove(obj);
|
||||
recentSearchObjectsById.remove(obj.did);
|
||||
if (queryFilter == null) {
|
||||
|
|
@ -562,7 +711,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
queryFilter.append(")");
|
||||
}
|
||||
} else {
|
||||
filteredRecentSearchObjects.clear();
|
||||
filtered2RecentSearchObjects.clear();
|
||||
recentSearchObjects.clear();
|
||||
recentSearchObjectsById.clear();
|
||||
queryFilter = new StringBuilder("1");
|
||||
|
|
@ -613,6 +762,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
MessagesController.getInstance(currentAccount).putEncryptedChat((TLRPC.EncryptedChat) recentSearchObject.object, true);
|
||||
}
|
||||
}
|
||||
filterRecent(null);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
@ -660,7 +810,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
searchResultMessages.clear();
|
||||
}
|
||||
searchWas = true;
|
||||
final int recentCount = filteredRecentSearchObjects.size();
|
||||
final int recentCount = filtered2RecentSearchObjects.size();
|
||||
for (int a = 0; a < result.size(); a++) {
|
||||
Object obj = result.get(a);
|
||||
long dialogId = 0;
|
||||
|
|
@ -700,11 +850,13 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
|
||||
boolean foundInRecent = false;
|
||||
for (int j = 0; j < recentCount; ++j) {
|
||||
RecentSearchObject o = filteredRecentSearchObjects.get(j);
|
||||
if (delegate != null && delegate.getSearchForumDialogId() == dialogId) {
|
||||
foundInRecent = true;
|
||||
}
|
||||
for (int j = 0; !foundInRecent && j < recentCount; ++j) {
|
||||
RecentSearchObject o = filtered2RecentSearchObjects.get(j);
|
||||
if (o != null && o.did == dialogId) {
|
||||
foundInRecent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (foundInRecent) {
|
||||
|
|
@ -716,7 +868,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
MessagesController.getInstance(currentAccount).putUsers(encUsers, true);
|
||||
searchResult = result;
|
||||
searchResultNames = names;
|
||||
searchAdapterHelper.mergeResults(searchResult, filteredRecentSearchObjects);
|
||||
searchAdapterHelper.mergeResults(searchResult, filtered2RecentSearchObjects);
|
||||
notifyDataSetChanged();
|
||||
if (delegate != null) {
|
||||
delegate.searchStateChanged(waitingResponseCount > 0, true);
|
||||
|
|
@ -757,6 +909,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
} else {
|
||||
query = null;
|
||||
}
|
||||
filterRecent(query);
|
||||
if (TextUtils.isEmpty(query)) {
|
||||
filteredRecentQuery = null;
|
||||
searchAdapterHelper.unloadRecentHashtags();
|
||||
|
|
@ -764,7 +917,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
searchResultNames.clear();
|
||||
searchResultHashtags.clear();
|
||||
searchAdapterHelper.mergeResults(null, null);
|
||||
searchAdapterHelper.queryServerSearch(null, true, true, dialogsType != 11, dialogsType != 11, dialogsType == 2 || dialogsType == 11, 0, dialogsType == 0, 0, 0);
|
||||
searchAdapterHelper.queryServerSearch(null, true, true, dialogsType != 11, dialogsType != 11, dialogsType == 2 || dialogsType == 11, 0, dialogsType == 0, 0, 0, delegate != null ? delegate.getSearchForumDialogId() : 0);
|
||||
searchWas = false;
|
||||
lastSearchId = 0;
|
||||
waitingResponseCount = 0;
|
||||
|
|
@ -773,7 +926,9 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (delegate != null) {
|
||||
delegate.searchStateChanged(false, true);
|
||||
}
|
||||
searchTopics(null);
|
||||
searchMessagesInternal(null, 0);
|
||||
searchForumMessagesInternal(null, 0);
|
||||
notifyDataSetChanged();
|
||||
localTipDates.clear();
|
||||
localTipArchive = false;
|
||||
|
|
@ -781,8 +936,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
filtersDelegate.updateFiltersView(false, null, localTipDates, localTipArchive);
|
||||
}
|
||||
} else {
|
||||
filterRecent(query);
|
||||
searchAdapterHelper.mergeResults(searchResult, filteredRecentSearchObjects);
|
||||
searchAdapterHelper.mergeResults(searchResult, filtered2RecentSearchObjects);
|
||||
if (needMessagesSearch != 2 && (query.startsWith("#") && query.length() == 1)) {
|
||||
messagesSearchEndReached = true;
|
||||
if (searchAdapterHelper.loadRecentHashtags()) {
|
||||
|
|
@ -822,14 +976,16 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
return;
|
||||
}
|
||||
if (needMessagesSearch != 2) {
|
||||
searchAdapterHelper.queryServerSearch(query, true, dialogsType != 4, true, dialogsType != 4 && dialogsType != 11, dialogsType == 2 || dialogsType == 1, 0, dialogsType == 0, 0, searchId);
|
||||
searchAdapterHelper.queryServerSearch(query, true, dialogsType != 4, true, dialogsType != 4 && dialogsType != 11, dialogsType == 2 || dialogsType == 1, 0, dialogsType == 0, 0, searchId, delegate != null ? delegate.getSearchForumDialogId() : 0);
|
||||
} else {
|
||||
waitingResponseCount -= 2;
|
||||
}
|
||||
if (needMessagesSearch == 0) {
|
||||
waitingResponseCount--;
|
||||
} else {
|
||||
searchTopics(text);
|
||||
searchMessagesInternal(text, searchId);
|
||||
searchForumMessagesInternal(text, searchId);
|
||||
}
|
||||
});
|
||||
}, 300);
|
||||
|
|
@ -837,12 +993,12 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
|
||||
public int getRecentItemsCount() {
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filteredRecentSearchObjects : recentSearchObjects;
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
|
||||
return (!recent.isEmpty() ? recent.size() + 1 : 0) + (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
|
||||
}
|
||||
|
||||
public int getRecentResultsCount() {
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filteredRecentSearchObjects : recentSearchObjects;
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
|
||||
return recent != null ? recent.size() : 0;
|
||||
}
|
||||
|
||||
|
|
@ -862,6 +1018,10 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
return count;
|
||||
}
|
||||
}
|
||||
if (!searchTopics.isEmpty()) {
|
||||
count++;
|
||||
}
|
||||
count += searchTopics.size();
|
||||
int resultsCount = searchResult.size();
|
||||
count += resultsCount;
|
||||
int localServerCount = searchAdapterHelper.getLocalServerSearch().size();
|
||||
|
|
@ -874,8 +1034,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (phoneCount > 3 && phoneCollapsed) {
|
||||
phoneCount = 3;
|
||||
}
|
||||
int messagesCount = searchResultMessages.size();
|
||||
if (resultsCount + localServerCount > 0 && getRecentItemsCount() > 0) {
|
||||
if (resultsCount + localServerCount > 0 && (getRecentItemsCount() > 0 || !searchTopics.isEmpty())) {
|
||||
count++;
|
||||
}
|
||||
if (globalCount != 0) {
|
||||
|
|
@ -884,8 +1043,22 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (phoneCount != 0) {
|
||||
count += phoneCount;
|
||||
}
|
||||
int localMessagesCount = searchForumResultMessages.size();
|
||||
if (localMessagesCount != 0) {
|
||||
count += 1 + localMessagesCount + (localMessagesSearchEndReached ? 0 : 1);
|
||||
}
|
||||
if (!localMessagesSearchEndReached) {
|
||||
localMessagesLoadingRow = count;
|
||||
}
|
||||
int messagesCount = searchResultMessages.size();
|
||||
if (!searchForumResultMessages.isEmpty() && !localMessagesSearchEndReached) {
|
||||
messagesCount = 0;
|
||||
}
|
||||
if (messagesCount != 0) {
|
||||
count += messagesCount + 1 + (messagesSearchEndReached ? 0 : 1);
|
||||
count += 1 + messagesCount + (messagesSearchEndReached ? 0 : 1);
|
||||
}
|
||||
if (localMessagesSearchEndReached) {
|
||||
localMessagesLoadingRow = count;
|
||||
}
|
||||
return currentItemCount = count;
|
||||
}
|
||||
|
|
@ -900,7 +1073,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
if (isRecentSearchDisplayed()) {
|
||||
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filteredRecentSearchObjects : recentSearchObjects;
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
|
||||
if (i > offset && i - 1 - offset < recent.size()) {
|
||||
TLObject object = recent.get(i - 1 - offset).object;
|
||||
if (object instanceof TLRPC.User) {
|
||||
|
|
@ -919,12 +1092,18 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
i -= getRecentItemsCount();
|
||||
}
|
||||
}
|
||||
if (!searchTopics.isEmpty()) {
|
||||
if (i > 0 && i <= searchTopics.size()) {
|
||||
return searchTopics.get(i - 1);
|
||||
}
|
||||
i -= 1 + searchTopics.size();
|
||||
}
|
||||
ArrayList<TLObject> globalSearch = searchAdapterHelper.getGlobalSearch();
|
||||
ArrayList<TLObject> localServerSearch = searchAdapterHelper.getLocalServerSearch();
|
||||
ArrayList<Object> phoneSearch = searchAdapterHelper.getPhoneSearch();
|
||||
int localCount = searchResult.size();
|
||||
int localServerCount = localServerSearch.size();
|
||||
if (localCount + localServerCount > 0 && getRecentItemsCount() > 0) {
|
||||
if (localCount + localServerCount > 0 && (getRecentItemsCount() > 0 || !searchTopics.isEmpty())) {
|
||||
if (i == 0) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -938,7 +1117,6 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (globalCount > 4 && globalSearchCollapsed) {
|
||||
globalCount = 4;
|
||||
}
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (i >= 0 && i < localCount) {
|
||||
return searchResult.get(i);
|
||||
}
|
||||
|
|
@ -955,9 +1133,16 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
return globalSearch.get(i - 1);
|
||||
}
|
||||
i -= globalCount;
|
||||
if (i > 0 && i < messagesCount) {
|
||||
int localMessagesCount = searchForumResultMessages.isEmpty() ? 0 : searchForumResultMessages.size() + 1;
|
||||
if (i > 0 && i <= searchForumResultMessages.size()) {
|
||||
return searchForumResultMessages.get(i - 1);
|
||||
}
|
||||
i -= localMessagesCount + (!localMessagesSearchEndReached && !searchForumResultMessages.isEmpty() ? 1 : 0);
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (i > 0 && i <= searchResultMessages.size()) {
|
||||
return searchResultMessages.get(i - 1);
|
||||
}
|
||||
// i -= messagesCount;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -970,7 +1155,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
if (isRecentSearchDisplayed()) {
|
||||
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filteredRecentSearchObjects : recentSearchObjects;
|
||||
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
|
||||
if (i > offset && i - 1 - offset < recent.size()) {
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -989,7 +1174,6 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (globalCount > 4 && globalSearchCollapsed) {
|
||||
globalCount = 4;
|
||||
}
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
|
||||
if (i >= 0 && i < localCount) {
|
||||
return false;
|
||||
|
|
@ -1007,6 +1191,12 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
return true;
|
||||
}
|
||||
i -= globalCount;
|
||||
int localMessagesCount = searchForumResultMessages.isEmpty() ? 0 : searchForumResultMessages.size() + 1;
|
||||
if (i > 0 && i < localMessagesCount) {
|
||||
return false;
|
||||
}
|
||||
i -= localMessagesCount;
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (i > 0 && i < messagesCount) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1037,11 +1227,14 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
case VIEW_TYPE_DIALOG_CELL:
|
||||
view = new DialogCell(null, mContext, false, true) {
|
||||
@Override
|
||||
protected boolean isForumCell() {
|
||||
public boolean isForumCell() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
break;
|
||||
case VIEW_TYPE_TOPIC_CELL:
|
||||
view = new TopicSearchCell(mContext);
|
||||
break;
|
||||
case VIEW_TYPE_LOADING:
|
||||
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(mContext);
|
||||
flickerLoadingView.setViewType(FlickerLoadingView.DIALOG_TYPE);
|
||||
|
|
@ -1140,11 +1333,14 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
position -= getRecentItemsCount();
|
||||
}
|
||||
if (!searchTopics.isEmpty()) {
|
||||
position -= 1 + searchTopics.size();
|
||||
}
|
||||
ArrayList<TLObject> globalSearch = searchAdapterHelper.getGlobalSearch();
|
||||
ArrayList<Object> phoneSearch = searchAdapterHelper.getPhoneSearch();
|
||||
int localCount = searchResult.size();
|
||||
int localServerCount = searchAdapterHelper.getLocalServerSearch().size();
|
||||
if (localCount + localServerCount > 0 && getRecentItemsCount() > 0) {
|
||||
if (localCount + localServerCount > 0 && (getRecentItemsCount() > 0 || !searchTopics.isEmpty())) {
|
||||
position--;
|
||||
}
|
||||
int phoneCount = phoneSearch.size();
|
||||
|
|
@ -1249,12 +1445,12 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
});
|
||||
} else {
|
||||
int rawPosition = position;
|
||||
if (isRecentSearchDisplayed()) {
|
||||
if (isRecentSearchDisplayed() || !searchTopics.isEmpty()) {
|
||||
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
|
||||
if (position < offset) {
|
||||
cell.setText(LocaleController.getString("ChatHints", R.string.ChatHints));
|
||||
return;
|
||||
} else if (position == offset) {
|
||||
} else if (position == offset && isRecentSearchDisplayed()) {
|
||||
if (!searchWas) {
|
||||
cell.setText(LocaleController.getString("Recent", R.string.Recent), LocaleController.getString("ClearButton", R.string.ClearButton), v -> {
|
||||
if (delegate != null) {
|
||||
|
|
@ -1269,7 +1465,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
});
|
||||
}
|
||||
return;
|
||||
} else if (position == getRecentItemsCount()) {
|
||||
} else if (position == getRecentItemsCount() + (searchTopics.isEmpty() ? 0 : searchTopics.size() + 1)) {
|
||||
cell.setText(LocaleController.getString("SearchAllChatsShort", R.string.SearchAllChatsShort));
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -1287,87 +1483,99 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (globalCount > 4 && globalSearchCollapsed) {
|
||||
globalCount = 4;
|
||||
}
|
||||
int localMessagesCount = searchForumResultMessages.isEmpty() ? 0 : searchForumResultMessages.size() + 1;
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
position -= localCount + localServerCount;
|
||||
String title;
|
||||
String title = null;
|
||||
boolean showMore = false;
|
||||
Runnable onClick = null;
|
||||
if (position >= 0 && position < phoneCount) {
|
||||
title = LocaleController.getString("PhoneNumberSearch", R.string.PhoneNumberSearch);
|
||||
if (searchAdapterHelper.getPhoneSearch().size() > 3) {
|
||||
showMore = phoneCollapsed;
|
||||
onClick = () -> {
|
||||
phoneCollapsed = !phoneCollapsed;
|
||||
cell.setRightText(phoneCollapsed ? LocaleController.getString("ShowMore", R.string.ShowMore) : LocaleController.getString("ShowLess", R.string.ShowLess));
|
||||
notifyDataSetChanged();
|
||||
};
|
||||
if (!searchTopics.isEmpty()) {
|
||||
if (position == 0) {
|
||||
title = LocaleController.getString("Topics", R.string.Topics);
|
||||
}
|
||||
} else {
|
||||
position -= phoneCount;
|
||||
if (position >= 0 && position < globalCount) {
|
||||
title = LocaleController.getString("GlobalSearch", R.string.GlobalSearch);
|
||||
if (searchAdapterHelper.getGlobalSearch().size() > 3) {
|
||||
showMore = globalSearchCollapsed;
|
||||
position -= 1 + searchTopics.size();
|
||||
}
|
||||
if (title == null) {
|
||||
position -= localCount + localServerCount;
|
||||
if (position >= 0 && position < phoneCount) {
|
||||
title = LocaleController.getString("PhoneNumberSearch", R.string.PhoneNumberSearch);
|
||||
if (searchAdapterHelper.getPhoneSearch().size() > 3) {
|
||||
showMore = phoneCollapsed;
|
||||
onClick = () -> {
|
||||
final long now = SystemClock.elapsedRealtime();
|
||||
if (now - lastShowMoreUpdate < 300) {
|
||||
return;
|
||||
}
|
||||
lastShowMoreUpdate = now;
|
||||
|
||||
int totalGlobalCount = globalSearch.isEmpty() ? 0 : globalSearch.size();
|
||||
boolean disableRemoveAnimation = getItemCount() > rawPosition + Math.min(totalGlobalCount, globalSearchCollapsed ? 4 : Integer.MAX_VALUE) + 1;
|
||||
if (itemAnimator != null) {
|
||||
itemAnimator.setAddDuration(disableRemoveAnimation ? 45 : 200);
|
||||
itemAnimator.setRemoveDuration(disableRemoveAnimation ? 80 : 200);
|
||||
itemAnimator.setRemoveDelay(disableRemoveAnimation ? 270 : 0);
|
||||
}
|
||||
globalSearchCollapsed = !globalSearchCollapsed;
|
||||
cell.setRightText(globalSearchCollapsed ? LocaleController.getString("ShowMore", R.string.ShowMore) : LocaleController.getString("ShowLess", R.string.ShowLess), globalSearchCollapsed);
|
||||
showMoreHeader = null;
|
||||
View parent = (View) cell.getParent();
|
||||
if (parent instanceof RecyclerView) {
|
||||
RecyclerView listView = (RecyclerView) parent;
|
||||
final int nextGraySectionPosition = !globalSearchCollapsed ? rawPosition + 4 : rawPosition + totalGlobalCount + 1;
|
||||
for (int i = 0; i < listView.getChildCount(); ++i) {
|
||||
View child = listView.getChildAt(i);
|
||||
if (listView.getChildAdapterPosition(child) == nextGraySectionPosition) {
|
||||
showMoreHeader = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!globalSearchCollapsed) {
|
||||
notifyItemChanged(rawPosition + 3);
|
||||
notifyItemRangeInserted(rawPosition + 4, (totalGlobalCount - 3));
|
||||
} else {
|
||||
notifyItemRangeRemoved(rawPosition + 4, (totalGlobalCount - 3));
|
||||
if (disableRemoveAnimation) {
|
||||
AndroidUtilities.runOnUIThread(() -> notifyItemChanged(rawPosition + 3), 350);
|
||||
} else {
|
||||
notifyItemChanged(rawPosition + 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelShowMoreAnimation != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(cancelShowMoreAnimation);
|
||||
}
|
||||
if (disableRemoveAnimation) {
|
||||
showMoreAnimation = true;
|
||||
AndroidUtilities.runOnUIThread(cancelShowMoreAnimation = () -> {
|
||||
showMoreAnimation = false;
|
||||
showMoreHeader = null;
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
}, 400);
|
||||
} else {
|
||||
showMoreAnimation = false;
|
||||
}
|
||||
phoneCollapsed = !phoneCollapsed;
|
||||
cell.setRightText(phoneCollapsed ? LocaleController.getString("ShowMore", R.string.ShowMore) : LocaleController.getString("ShowLess", R.string.ShowLess));
|
||||
notifyDataSetChanged();
|
||||
};
|
||||
}
|
||||
} else {
|
||||
title = LocaleController.getString("SearchMessages", R.string.SearchMessages);
|
||||
position -= phoneCount;
|
||||
if (position >= 0 && position < globalCount) {
|
||||
title = LocaleController.getString("GlobalSearch", R.string.GlobalSearch);
|
||||
if (searchAdapterHelper.getGlobalSearch().size() > 3) {
|
||||
showMore = globalSearchCollapsed;
|
||||
onClick = () -> {
|
||||
final long now = SystemClock.elapsedRealtime();
|
||||
if (now - lastShowMoreUpdate < 300) {
|
||||
return;
|
||||
}
|
||||
lastShowMoreUpdate = now;
|
||||
|
||||
int totalGlobalCount = globalSearch.isEmpty() ? 0 : globalSearch.size();
|
||||
boolean disableRemoveAnimation = getItemCount() > rawPosition + Math.min(totalGlobalCount, globalSearchCollapsed ? 4 : Integer.MAX_VALUE) + 1;
|
||||
if (itemAnimator != null) {
|
||||
itemAnimator.setAddDuration(disableRemoveAnimation ? 45 : 200);
|
||||
itemAnimator.setRemoveDuration(disableRemoveAnimation ? 80 : 200);
|
||||
itemAnimator.setRemoveDelay(disableRemoveAnimation ? 270 : 0);
|
||||
}
|
||||
globalSearchCollapsed = !globalSearchCollapsed;
|
||||
cell.setRightText(globalSearchCollapsed ? LocaleController.getString("ShowMore", R.string.ShowMore) : LocaleController.getString("ShowLess", R.string.ShowLess), globalSearchCollapsed);
|
||||
showMoreHeader = null;
|
||||
View parent = (View) cell.getParent();
|
||||
if (parent instanceof RecyclerView) {
|
||||
RecyclerView listView = (RecyclerView) parent;
|
||||
final int nextGraySectionPosition = !globalSearchCollapsed ? rawPosition + 4 : rawPosition + totalGlobalCount + 1;
|
||||
for (int i = 0; i < listView.getChildCount(); ++i) {
|
||||
View child = listView.getChildAt(i);
|
||||
if (listView.getChildAdapterPosition(child) == nextGraySectionPosition) {
|
||||
showMoreHeader = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!globalSearchCollapsed) {
|
||||
notifyItemChanged(rawPosition + 3);
|
||||
notifyItemRangeInserted(rawPosition + 4, (totalGlobalCount - 3));
|
||||
} else {
|
||||
notifyItemRangeRemoved(rawPosition + 4, (totalGlobalCount - 3));
|
||||
if (disableRemoveAnimation) {
|
||||
AndroidUtilities.runOnUIThread(() -> notifyItemChanged(rawPosition + 3), 350);
|
||||
} else {
|
||||
notifyItemChanged(rawPosition + 3);
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelShowMoreAnimation != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(cancelShowMoreAnimation);
|
||||
}
|
||||
if (disableRemoveAnimation) {
|
||||
showMoreAnimation = true;
|
||||
AndroidUtilities.runOnUIThread(cancelShowMoreAnimation = () -> {
|
||||
showMoreAnimation = false;
|
||||
showMoreHeader = null;
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
}, 400);
|
||||
} else {
|
||||
showMoreAnimation = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (delegate != null && localMessagesCount > 0 && position - globalCount <= 1) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-delegate.getSearchForumDialogId());
|
||||
title = LocaleController.formatString("SearchMessagesIn", R.string.SearchMessagesIn, (chat == null ? "null" : chat.title));
|
||||
} else {
|
||||
title = LocaleController.getString("SearchMessages", R.string.SearchMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1385,7 +1593,18 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
cell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
cell.useSeparator = (position != getItemCount() - 1);
|
||||
MessageObject messageObject = (MessageObject) getItem(position);
|
||||
cell.setDialog(messageObject.getDialogId(), messageObject, messageObject.messageOwner.date, false, false);
|
||||
boolean isLocalForum = searchForumResultMessages.contains(messageObject);
|
||||
cell.useFromUserAsAvatar = isLocalForum;
|
||||
if (messageObject == null) {
|
||||
cell.setDialog(0, null, 0, false, false);
|
||||
} else {
|
||||
cell.setDialog(messageObject.getDialogId(), messageObject, messageObject.messageOwner.date, false, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_TOPIC_CELL: {
|
||||
TopicSearchCell topicSearchCell = (TopicSearchCell) holder.itemView;
|
||||
topicSearchCell.setTopic((TLRPC.TL_forumTopic) getItem(position));
|
||||
break;
|
||||
}
|
||||
case VIEW_TYPE_HASHTAG_CELL: {
|
||||
|
|
@ -1431,10 +1650,18 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
i -= getRecentItemsCount();
|
||||
}
|
||||
if (!searchTopics.isEmpty()) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_GRAY_SECTION;
|
||||
} else if (i <= searchTopics.size()) {
|
||||
return VIEW_TYPE_TOPIC_CELL;
|
||||
}
|
||||
i -= 1 + searchTopics.size();
|
||||
}
|
||||
ArrayList<TLObject> globalSearch = searchAdapterHelper.getGlobalSearch();
|
||||
int localCount = searchResult.size();
|
||||
int localServerCount = searchAdapterHelper.getLocalServerSearch().size();
|
||||
if (localCount + localServerCount > 0 && getRecentItemsCount() > 0) {
|
||||
if (localCount + localServerCount > 0 && (getRecentItemsCount() > 0 || !searchTopics.isEmpty())) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_GRAY_SECTION;
|
||||
}
|
||||
|
|
@ -1449,6 +1676,10 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
globalCount = 4;
|
||||
}
|
||||
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
|
||||
if (!searchForumResultMessages.isEmpty() && !localMessagesSearchEndReached) {
|
||||
messagesCount = 0;
|
||||
}
|
||||
int localMessagesCount = (searchForumResultMessages.isEmpty() ? 0 : searchForumResultMessages.size() + 1);
|
||||
|
||||
if (i >= 0 && i < localCount) {
|
||||
return VIEW_TYPE_PROFILE_CELL;
|
||||
|
|
@ -1479,6 +1710,18 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
}
|
||||
i -= globalCount;
|
||||
if (localMessagesCount > 0) {
|
||||
if (i >= 0 && (localMessagesSearchEndReached ? i < localMessagesCount : i <= localMessagesCount)) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_GRAY_SECTION;
|
||||
} else if (i == localMessagesCount) {
|
||||
return VIEW_TYPE_LOADING;
|
||||
} else {
|
||||
return VIEW_TYPE_DIALOG_CELL;
|
||||
}
|
||||
}
|
||||
i -= localMessagesCount + (!localMessagesSearchEndReached ? 1 : 0);
|
||||
}
|
||||
if (i >= 0 && i < messagesCount) {
|
||||
if (i == 0) {
|
||||
return VIEW_TYPE_GRAY_SECTION;
|
||||
|
|
@ -1502,8 +1745,16 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
|
||||
public void filterRecent(String query) {
|
||||
filteredRecentQuery = query;
|
||||
filteredRecentSearchObjects.clear();
|
||||
filtered2RecentSearchObjects.clear();
|
||||
if (TextUtils.isEmpty(query)) {
|
||||
filteredRecentSearchObjects.clear();
|
||||
final int count = recentSearchObjects.size();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (delegate != null && delegate.getSearchForumDialogId() == recentSearchObjects.get(i).did) {
|
||||
continue;
|
||||
}
|
||||
filteredRecentSearchObjects.add(recentSearchObjects.get(i));
|
||||
}
|
||||
return;
|
||||
}
|
||||
String lowerCasedQuery = query.toLowerCase();
|
||||
|
|
@ -1513,6 +1764,9 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
if (obj == null || obj.object == null) {
|
||||
continue;
|
||||
}
|
||||
if (delegate != null && delegate.getSearchForumDialogId() == obj.did) {
|
||||
continue;
|
||||
}
|
||||
String title = null, username = null;
|
||||
if (obj.object instanceof TLRPC.Chat) {
|
||||
title = ((TLRPC.Chat) obj.object).title;
|
||||
|
|
@ -1525,9 +1779,9 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
if (title != null && wordStartsWith(title.toLowerCase(), lowerCasedQuery) ||
|
||||
username != null && wordStartsWith(username.toLowerCase(), lowerCasedQuery)) {
|
||||
filteredRecentSearchObjects.add(obj);
|
||||
filtered2RecentSearchObjects.add(obj);
|
||||
}
|
||||
if (filteredRecentSearchObjects.size() >= 5) {
|
||||
if (filtered2RecentSearchObjects.size() >= 5) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ package org.telegram.ui.Adapters;
|
|||
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.SQLite.SQLitePreparedStatement;
|
||||
|
|
@ -28,7 +30,6 @@ import org.telegram.tgnet.TLRPC;
|
|||
import org.telegram.ui.ChatUsersActivity;
|
||||
import org.telegram.ui.Components.ShareAlert;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -36,8 +37,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
|
||||
public class SearchAdapterHelper {
|
||||
|
||||
public static class HashtagObject {
|
||||
|
|
@ -108,9 +107,12 @@ public class SearchAdapterHelper {
|
|||
return pendingRequestIds.size() > 0;
|
||||
}
|
||||
public void queryServerSearch(String query, boolean allowUsername, boolean allowChats, boolean allowBots, boolean allowSelf, boolean canAddGroupsOnly, long channelId, boolean phoneNumbers, int type, int searchId) {
|
||||
queryServerSearch(query, allowUsername, allowChats, allowBots, allowSelf, canAddGroupsOnly, channelId, phoneNumbers, type, searchId, null);
|
||||
queryServerSearch(query, allowUsername, allowChats, allowBots, allowSelf, canAddGroupsOnly, channelId, phoneNumbers, type, searchId, 0, null);
|
||||
}
|
||||
public void queryServerSearch(String query, boolean allowUsername, boolean allowChats, boolean allowBots, boolean allowSelf, boolean canAddGroupsOnly, long channelId, boolean phoneNumbers, int type, int searchId, Runnable onEnd) {
|
||||
public void queryServerSearch(String query, boolean allowUsername, boolean allowChats, boolean allowBots, boolean allowSelf, boolean canAddGroupsOnly, long channelId, boolean phoneNumbers, int type, int searchId, long exceptDialogId) {
|
||||
queryServerSearch(query, allowUsername, allowChats, allowBots, allowSelf, canAddGroupsOnly, channelId, phoneNumbers, type, searchId, exceptDialogId, null);
|
||||
}
|
||||
public void queryServerSearch(String query, boolean allowUsername, boolean allowChats, boolean allowBots, boolean allowSelf, boolean canAddGroupsOnly, long channelId, boolean phoneNumbers, int type, int searchId, long exceptDialogId, Runnable onEnd) {
|
||||
for (int reqId : pendingRequestIds) {
|
||||
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
|
||||
}
|
||||
|
|
@ -248,13 +250,13 @@ public class SearchAdapterHelper {
|
|||
chat = chatsMap.get(peer.channel_id);
|
||||
}
|
||||
if (chat != null) {
|
||||
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat)) {
|
||||
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat) || -chat.id == exceptDialogId) {
|
||||
continue;
|
||||
}
|
||||
localServerSearch.add(chat);
|
||||
globalSearchMap.put(-chat.id, chat);
|
||||
} else if (user != null) {
|
||||
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self) {
|
||||
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self || user.id == exceptDialogId) {
|
||||
continue;
|
||||
}
|
||||
localServerSearch.add(user);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,334 @@
|
|||
package org.telegram.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.transition.ChangeBounds;
|
||||
import android.transition.Fade;
|
||||
import android.transition.TransitionManager;
|
||||
import android.transition.TransitionSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.tgnet.RequestDelegate;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.HeaderCell;
|
||||
import org.telegram.ui.Cells.RadioCell;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.StickerImageView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AutoDeleteMessagesActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private final static int ONE_DAY = 60 * 24;
|
||||
private final static int ONE_WEEK = 60 * 24 * 7;
|
||||
private final static int ONE_MONTH = 60 * 24 * 31;
|
||||
|
||||
RadioCellInternal offCell;
|
||||
RadioCellInternal afterOneDay;
|
||||
RadioCellInternal afterOneWeek;
|
||||
RadioCellInternal afterOneMonth;
|
||||
RadioCellInternal customTimeButton;
|
||||
LinearLayout checkBoxContainer;
|
||||
|
||||
ArrayList<RadioCellInternal> arrayList = new ArrayList<>();
|
||||
|
||||
public int startFromTtl = 0;
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
startFromTtl = getUserConfig().getGlobalTTl();
|
||||
if (startFromTtl < 0) {
|
||||
startFromTtl = 0;
|
||||
}
|
||||
getUserConfig().loadGlobalTTl();
|
||||
getNotificationCenter().addObserver(this, NotificationCenter.didUpdateGlobalAutoDeleteTimer);
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateGlobalAutoDeleteTimer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setAllowOverlayTitle(true);
|
||||
actionBar.setTitle(LocaleController.getString("AutoDeleteMessages", R.string.AutoDeleteMessages));
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
|
||||
|
||||
ScrollView scrollView = new ScrollView(getContext());
|
||||
LinearLayout mainContainer = new LinearLayout(getContext());
|
||||
mainContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
scrollView.addView(mainContainer);
|
||||
frameLayout.addView(scrollView);
|
||||
|
||||
|
||||
FrameLayout stickerHeaderCell = new FrameLayout(context);
|
||||
StickerImageView backupImageView = new StickerImageView(context, currentAccount);
|
||||
backupImageView.setStickerNum(10);
|
||||
stickerHeaderCell.addView(backupImageView, LayoutHelper.createFrame(130, 130, Gravity.CENTER));
|
||||
|
||||
mainContainer.addView(stickerHeaderCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 170));
|
||||
|
||||
checkBoxContainer = new LinearLayout(getContext());
|
||||
checkBoxContainer.setOrientation(LinearLayout.VERTICAL);
|
||||
checkBoxContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
mainContainer.addView(checkBoxContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
HeaderCell headerCell = new HeaderCell(getContext());
|
||||
headerCell.setText(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
||||
checkBoxContainer.addView(headerCell);
|
||||
|
||||
offCell = new RadioCellInternal(getContext());
|
||||
offCell.setText(LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever), false, true);
|
||||
offCell.time = 0;
|
||||
checkBoxContainer.addView(offCell);
|
||||
|
||||
afterOneDay = new RadioCellInternal(getContext());
|
||||
afterOneDay.setText(LocaleController.getString("AutoDeleteAfter1Day", R.string.AutoDeleteAfter1Day), false, true);
|
||||
afterOneDay.time = ONE_DAY;
|
||||
checkBoxContainer.addView(afterOneDay);
|
||||
|
||||
afterOneWeek = new RadioCellInternal(getContext());
|
||||
afterOneWeek.setText(LocaleController.getString("AutoDeleteAfter1Week", R.string.AutoDeleteAfter1Week), false, true);
|
||||
afterOneWeek.time = ONE_WEEK;
|
||||
checkBoxContainer.addView(afterOneWeek);
|
||||
|
||||
afterOneMonth = new RadioCellInternal(getContext());
|
||||
afterOneMonth.setText(LocaleController.getString("AutoDeleteAfter1Month", R.string.AutoDeleteAfter1Month), false, true);
|
||||
afterOneMonth.time = ONE_MONTH;
|
||||
checkBoxContainer.addView(afterOneMonth);
|
||||
|
||||
customTimeButton = new RadioCellInternal(getContext());
|
||||
customTimeButton.setText(LocaleController.getString("SetCustomTime", R.string.SetCustomTime), false, false);
|
||||
customTimeButton.hideRadioButton();
|
||||
checkBoxContainer.addView(customTimeButton);
|
||||
|
||||
arrayList.add(offCell);
|
||||
arrayList.add(afterOneDay);
|
||||
arrayList.add(afterOneWeek);
|
||||
arrayList.add(afterOneMonth);
|
||||
arrayList.add(customTimeButton);
|
||||
|
||||
updateItems();
|
||||
|
||||
TextInfoPrivacyCell textInfoPrivacyCell = new TextInfoPrivacyCell(context);
|
||||
CharSequence infoText = AndroidUtilities.replaceSingleTag(LocaleController.getString("GlobalAutoDeleteInfo", R.string.GlobalAutoDeleteInfo), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UsersSelectActivity usersSelectActivity = new UsersSelectActivity(UsersSelectActivity.TYPE_AUTO_DELETE_EXISTING_CHATS);
|
||||
usersSelectActivity.setTtlPeriod(getSelectedTime());
|
||||
usersSelectActivity.setDelegate((ids, flags) -> {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (!ids.isEmpty()) {
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
getMessagesController().setDialogHistoryTTL(ids.get(i), getSelectedTime() * 60);
|
||||
}
|
||||
if (getSelectedTime() > 0) {
|
||||
BulletinFactory.of(AutoDeleteMessagesActivity.this).createSimpleBulletin(R.raw.fire_on, AndroidUtilities.replaceTags(LocaleController.formatString("AutodeleteTimerEnabledForChats", R.string.AutodeleteTimerEnabledForChats,
|
||||
LocaleController.formatTTLString(getSelectedTime() * 60),
|
||||
LocaleController.formatPluralString("Chats", ids.size(), ids.size())
|
||||
))).show();
|
||||
} else {
|
||||
BulletinFactory.of(AutoDeleteMessagesActivity.this).createSimpleBulletin(R.raw.fire_off, LocaleController.formatString("AutodeleteTimerDisabledForChats", R.string.AutodeleteTimerDisabledForChats,
|
||||
LocaleController.formatPluralString("Chats", ids.size(), ids.size())
|
||||
)).show();
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
||||
|
||||
});
|
||||
presentFragment(usersSelectActivity);
|
||||
}
|
||||
});
|
||||
textInfoPrivacyCell.setText(infoText);
|
||||
mainContainer.addView(textInfoPrivacyCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
selectDate(startFromTtl, false);
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
private void updateItems() {
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
arrayList.get(i).setBackground(Theme.createSelectorWithBackgroundDrawable(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_listSelector)));
|
||||
arrayList.get(i).setOnClickListener(v -> {
|
||||
if (v == customTimeButton) {
|
||||
AlertsCreator.createAutoDeleteDatePickerDialog(getContext(), 1, null, new AlertsCreator.ScheduleDatePickerDelegate() {
|
||||
@Override
|
||||
public void didSelectDate(boolean notify, int scheduleDate) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
selectDate(scheduleDate, true);
|
||||
}, 50);
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
int time = ((RadioCellInternal)v).time;
|
||||
int selctedTime = getSelectedTime();
|
||||
if (selctedTime == 0 && time > 0) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
||||
builder.setMessage(LocaleController.formatString("AutoDeleteConfirmMessage", R.string.AutoDeleteConfirmMessage, LocaleController.formatTTLString(time * 60)));
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
});
|
||||
builder.setPositiveButton(LocaleController.getString("Enable", R.string.Enable), (dialog, which) -> {
|
||||
dialog.dismiss();
|
||||
selectRadioButton(v, true);
|
||||
});
|
||||
builder.show();
|
||||
} else {
|
||||
selectRadioButton(v, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private int getSelectedTime() {
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (arrayList.get(i).isChecked()) {
|
||||
return arrayList.get(i).time;
|
||||
}
|
||||
}
|
||||
return startFromTtl;
|
||||
}
|
||||
|
||||
private void selectDate(int scheduleDate, boolean showBulletin) {
|
||||
TransitionSet transition = new TransitionSet();
|
||||
ChangeBounds changeBounds = new ChangeBounds();
|
||||
changeBounds.setDuration(150);
|
||||
Fade in = new Fade(Fade.IN);
|
||||
in.setDuration(150);
|
||||
transition
|
||||
.addTransition(new Fade(Fade.OUT).setDuration(150))
|
||||
.addTransition(changeBounds)
|
||||
.addTransition(in);
|
||||
transition.setOrdering(TransitionSet.ORDERING_TOGETHER);
|
||||
transition.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
||||
TransitionManager.beginDelayedTransition(checkBoxContainer, transition);
|
||||
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (arrayList.get(i).time == scheduleDate) {
|
||||
selectRadioButton(arrayList.get(i), showBulletin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (arrayList.get(i).custom) {
|
||||
checkBoxContainer.removeView(arrayList.get(i));
|
||||
arrayList.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
int position = arrayList.size();
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (scheduleDate < arrayList.get(i).time) {
|
||||
position = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
RadioCellInternal customTimeButton = new RadioCellInternal(getContext());
|
||||
customTimeButton.custom = true;
|
||||
customTimeButton.time = scheduleDate;
|
||||
|
||||
customTimeButton.setText(LocaleController.formatString("AutoDeleteAfterShort", R.string.AutoDeleteAfterShort, LocaleController.formatTTLString(scheduleDate * 60)), false, true);
|
||||
arrayList.add(position, customTimeButton);
|
||||
checkBoxContainer.addView(customTimeButton, position);
|
||||
updateItems();
|
||||
selectRadioButton(customTimeButton, showBulletin);
|
||||
}
|
||||
|
||||
private void selectRadioButton(View v, boolean showBulletin) {
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (arrayList.get(i) == v) {
|
||||
arrayList.get(i).setChecked(true, fragmentBeginToShow);
|
||||
} else {
|
||||
arrayList.get(i).setChecked(false, fragmentBeginToShow);
|
||||
}
|
||||
}
|
||||
if (showBulletin) {
|
||||
int time = ((RadioCellInternal) v).time;
|
||||
if (time > 0) {
|
||||
String text = LocaleController.formatString("AutoDeleteGlobalTimerEnabled", R.string.AutoDeleteGlobalTimerEnabled, LocaleController.formatTTLString(time * 60));
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.fire_on, AndroidUtilities.replaceTags(text)).show();
|
||||
} else {
|
||||
// String text = LocaleController.formatString("AutoDeleteGlobalTimerDisabled", R.string.AutoDeleteGlobalTimerDisabled);
|
||||
// BulletinFactory.of(this).createSimpleBulletin(R.raw.fire_off, text).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
// int newTTl = getUserConfig().getGlobalTTl();
|
||||
// if (newTTl != startFromTtl) {
|
||||
// startFromTtl = newTTl;
|
||||
// selectDate(startFromTtl, false);
|
||||
// }
|
||||
}
|
||||
|
||||
private class RadioCellInternal extends RadioCell {
|
||||
|
||||
boolean custom;
|
||||
int time;
|
||||
|
||||
public RadioCellInternal(Context context) {
|
||||
super(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
for (int i = 0; i < arrayList.size(); i++) {
|
||||
if (arrayList.get(i).isChecked()) {
|
||||
if (arrayList.get(i).time != startFromTtl) {
|
||||
startFromTtl = arrayList.get(i).time;
|
||||
TLRPC.TL_messages_setDefaultHistoryTTL setDefaultHistoryTTL = new TLRPC.TL_messages_setDefaultHistoryTTL();
|
||||
setDefaultHistoryTTL.period = arrayList.get(i).time * 60;
|
||||
getConnectionsManager().sendRequest(setDefaultHistoryTTL, new RequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
}
|
||||
});
|
||||
getUserConfig().setGlobalTtl(startFromTtl);
|
||||
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.didUpdateGlobalAutoDeleteTimer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -33,6 +33,8 @@ import org.telegram.messenger.SharedConfig;
|
|||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.DotDividerSpan;
|
||||
import org.telegram.ui.Components.MediaActionDrawable;
|
||||
import org.telegram.ui.Components.RadialProgress2;
|
||||
|
|
@ -49,9 +51,11 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
private int buttonY;
|
||||
|
||||
private int titleY = AndroidUtilities.dp(9);
|
||||
private AnimatedEmojiSpan.EmojiGroupedSpans titleLayoutEmojis;
|
||||
private StaticLayout titleLayout;
|
||||
|
||||
private int descriptionY = AndroidUtilities.dp(29);
|
||||
private AnimatedEmojiSpan.EmojiGroupedSpans descriptionLayoutEmojis;
|
||||
private StaticLayout descriptionLayout;
|
||||
|
||||
private MessageObject currentMessageObject;
|
||||
|
|
@ -100,6 +104,7 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
int width = (int) Math.ceil(Theme.chat_contextResult_titleTextPaint.measureText(title));
|
||||
CharSequence titleFinal = TextUtils.ellipsize(title.replace('\n', ' '), Theme.chat_contextResult_titleTextPaint, Math.min(width, maxWidth), TextUtils.TruncateAt.END);
|
||||
titleLayout = new StaticLayout(titleFinal, Theme.chat_contextResult_titleTextPaint, maxWidth + AndroidUtilities.dp(4), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
titleLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, titleLayoutEmojis, titleLayout);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
@ -111,6 +116,7 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
}
|
||||
CharSequence authorFinal = TextUtils.ellipsize(author, Theme.chat_contextResult_descriptionTextPaint, maxWidth, TextUtils.TruncateAt.END);
|
||||
descriptionLayout = new StaticLayout(authorFinal, Theme.chat_contextResult_descriptionTextPaint, maxWidth + AndroidUtilities.dp(4), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
descriptionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, descriptionLayoutEmojis, descriptionLayout);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
@ -145,12 +151,18 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
super.onDetachedFromWindow();
|
||||
radialProgress.onDetachedFromWindow();
|
||||
DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
|
||||
|
||||
AnimatedEmojiSpan.release(this, titleLayoutEmojis);
|
||||
AnimatedEmojiSpan.release(this, descriptionLayoutEmojis);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
radialProgress.onAttachedToWindow();
|
||||
|
||||
titleLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, titleLayoutEmojis, titleLayout);
|
||||
descriptionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, descriptionLayoutEmojis, descriptionLayout);
|
||||
}
|
||||
|
||||
public MessageObject getMessageObject() {
|
||||
|
|
@ -268,6 +280,7 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), titleY);
|
||||
titleLayout.draw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, titleLayout, titleLayoutEmojis, 0, null, 0, 0, 0, 1f);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +289,7 @@ public class AudioPlayerCell extends View implements DownloadController.FileDown
|
|||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), descriptionY);
|
||||
descriptionLayout.draw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, descriptionLayout, descriptionLayoutEmojis, 0, null, 0, 0, 0, 1f);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -761,7 +761,13 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
private void createLayout(CharSequence text, int width) {
|
||||
int maxWidth = width - AndroidUtilities.dp(30);
|
||||
invalidatePath = true;
|
||||
textLayout = new StaticLayout(text, (TextPaint) getThemedPaint(Theme.key_paint_chatActionText), maxWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
TextPaint paint;
|
||||
if (currentMessageObject != null && currentMessageObject.drawServiceWithDefaultTypeface) {
|
||||
paint = (TextPaint) getThemedPaint(Theme.key_paint_chatActionText2);
|
||||
} else {
|
||||
paint = (TextPaint) getThemedPaint(Theme.key_paint_chatActionText);
|
||||
}
|
||||
textLayout = new StaticLayout(text, paint, maxWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
|
||||
spoilersPool.addAll(spoilers);
|
||||
spoilers.clear();
|
||||
|
|
@ -845,7 +851,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
|
|||
MessageObject messageObject = currentMessageObject;
|
||||
if (messageObject != null) {
|
||||
if (delegate.getTopicId() == 0 && MessageObject.isTopicActionMessage(messageObject)) {
|
||||
TLRPC.TL_forumTopic topic = MessagesController.getInstance(currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), MessageObject.getTopicId(messageObject.messageOwner));
|
||||
TLRPC.TL_forumTopic topic = MessagesController.getInstance(currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), MessageObject.getTopicId(messageObject.messageOwner, true));
|
||||
text = ForumUtilities.createActionTextWithTopic(topic, messageObject);
|
||||
}
|
||||
if (text == null) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ import android.text.TextUtils;
|
|||
import android.text.style.CharacterStyle;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.Log;
|
||||
import android.util.Property;
|
||||
import android.util.SparseArray;
|
||||
import android.util.StateSet;
|
||||
|
|
@ -75,7 +74,6 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
import androidx.core.math.MathUtils;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.AccountInstance;
|
||||
|
|
@ -113,7 +111,6 @@ import org.telegram.tgnet.TLObject;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AnimatedColor;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.AnimatedFileDrawable;
|
||||
|
|
@ -128,7 +125,6 @@ import org.telegram.ui.Components.ClipRoundedDrawable;
|
|||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.EmptyStubSpan;
|
||||
import org.telegram.ui.Components.FloatSeekBarAccessibilityDelegate;
|
||||
import org.telegram.ui.Components.Forum.ForumUtilities;
|
||||
import org.telegram.ui.Components.Forum.MessageTopicButton;
|
||||
import org.telegram.ui.Components.InfiniteProgress;
|
||||
import org.telegram.ui.Components.LinkPath;
|
||||
|
|
@ -224,6 +220,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
setAvatar(currentMessageObject);
|
||||
}
|
||||
}
|
||||
} else if (id == NotificationCenter.emojiLoaded) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -522,11 +520,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
return true;
|
||||
}
|
||||
|
||||
default boolean didPressAnimatedEmoji(AnimatedEmojiSpan span) {
|
||||
default boolean didPressAnimatedEmoji(ChatMessageCell cell, AnimatedEmojiSpan span) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default void didPressTopicButton(ChatMessageCell cell) {}
|
||||
|
||||
default boolean shouldShowTopicButton() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private final static int DOCUMENT_ATTACH_TYPE_NONE = 0;
|
||||
|
|
@ -672,6 +674,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
private StaticLayout authorLayout;
|
||||
private StaticLayout instantViewLayout;
|
||||
private boolean drawInstantView;
|
||||
private boolean pollInstantViewTouchesBottom;
|
||||
private int drawInstantViewType;
|
||||
private int imageBackgroundColor;
|
||||
private float imageBackgroundIntensity;
|
||||
|
|
@ -997,7 +1000,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
private int timeWidth;
|
||||
private int timeTextWidth;
|
||||
private int timeX;
|
||||
private String currentTimeString;
|
||||
private CharSequence currentTimeString;
|
||||
private boolean drawTime = true;
|
||||
private boolean forceNotDrawTime;
|
||||
private Paint drillHolePaint;
|
||||
|
|
@ -1440,7 +1443,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
return true;
|
||||
} else {
|
||||
if (link[0] instanceof AnimatedEmojiSpan && pressedEmoji == link[0]) {
|
||||
if (delegate.didPressAnimatedEmoji(pressedEmoji)) {
|
||||
if (delegate.didPressAnimatedEmoji(this, pressedEmoji)) {
|
||||
resetPressedLink(1);
|
||||
pressedEmoji = null;
|
||||
return true;
|
||||
|
|
@ -1523,7 +1526,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
} else if (pressedLinkType == 3) {
|
||||
if (pressedEmoji != null) {
|
||||
if (delegate.didPressAnimatedEmoji(pressedEmoji)) {
|
||||
if (delegate.didPressAnimatedEmoji(this, pressedEmoji)) {
|
||||
resetPressedLink(3);
|
||||
pressedEmoji = null;
|
||||
return true;
|
||||
|
|
@ -1769,7 +1772,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
((ClickableSpan) pressedLink.getSpan()).onClick(this);
|
||||
}
|
||||
resetPressedLink(2);
|
||||
} else if (pressedEmoji != null && delegate.didPressAnimatedEmoji(pressedEmoji)) {
|
||||
} else if (pressedEmoji != null && delegate.didPressAnimatedEmoji(this, pressedEmoji)) {
|
||||
pressedEmoji = null;
|
||||
resetPressedLink(2);
|
||||
} else {
|
||||
|
|
@ -3031,6 +3034,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (currentMessageObject.hasValidGroupId() && currentMessagesGroup != null && !currentMessagesGroup.isDocuments) {
|
||||
ViewGroup parent = (ViewGroup) getParent();
|
||||
if (parent == null) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < parent.getChildCount(); i++) {
|
||||
View v = parent.getChildAt(i);
|
||||
if (v instanceof ChatMessageCell) {
|
||||
|
|
@ -3656,6 +3662,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.startSpoilers);
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.stopSpoilers);
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
|
||||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.userInfoDidLoad);
|
||||
|
||||
cancelShakeAnimation();
|
||||
|
|
@ -3714,6 +3721,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.startSpoilers);
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.stopSpoilers);
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.userInfoDidLoad);
|
||||
|
||||
// if (currentMessageObject != null) {
|
||||
|
|
@ -4594,8 +4602,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
photo = null;
|
||||
author = null;
|
||||
document = null;
|
||||
if (invoice.photo instanceof TLRPC.TL_webDocument) {
|
||||
webDocument = WebFile.createWithWebDocument(invoice.photo);
|
||||
if (invoice.webPhoto instanceof TLRPC.TL_webDocument) {
|
||||
webDocument = WebFile.createWithWebDocument(invoice.webPhoto);
|
||||
} else {
|
||||
webDocument = null;
|
||||
}
|
||||
|
|
@ -5657,7 +5665,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
lastPoll = media.poll;
|
||||
lastPollResults = media.results.results;
|
||||
lastPollResultsVoters = media.results.total_voters;
|
||||
if (media.poll.multiple_choice && !pollVoted && !pollClosed || !isBot && (media.poll.public_voters && pollVoted || pollClosed && media.results != null && media.results.total_voters != 0 && media.poll.public_voters)) {
|
||||
if (
|
||||
media.poll.multiple_choice && !pollVoted && !pollClosed ||
|
||||
!isBot && media.poll.public_voters && (
|
||||
pollVoted ||
|
||||
pollClosed && media.results != null && media.results.total_voters != 0
|
||||
)
|
||||
) {
|
||||
drawInstantView = true;
|
||||
drawInstantViewType = 8;
|
||||
createInstantViewButton();
|
||||
|
|
@ -5815,10 +5829,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
setMessageObjectInternal(messageObject);
|
||||
|
||||
|
||||
pollInstantViewTouchesBottom = false;
|
||||
if (isBot && !drawInstantView) {
|
||||
height -= AndroidUtilities.dp(10);
|
||||
} else if (media.poll.public_voters || media.poll.multiple_choice) {
|
||||
pollInstantViewTouchesBottom = true;
|
||||
height += AndroidUtilities.dp(13);
|
||||
}
|
||||
totalHeight = AndroidUtilities.dp(46 + 27) + namesOffset + height;
|
||||
|
|
@ -7580,7 +7595,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
if (pressedEmoji != null) {
|
||||
// hadLongPress = true;
|
||||
// if (delegate.didPressAnimatedEmoji(pressedEmoji)) {
|
||||
// if (delegate.didPressAnimatedEmoji(this, pressedEmoji)) {
|
||||
// pressedEmoji = null;
|
||||
// resetPressedLink(-1);
|
||||
// return true;
|
||||
|
|
@ -8316,7 +8331,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
radii[a * 2] = radii[a * 2 + 1] = 0;
|
||||
}
|
||||
if (!out && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL)) {
|
||||
if (!out && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL || pollInstantViewTouchesBottom)) {
|
||||
path.moveTo(rect.left + AndroidUtilities.dp(6), rect.top);
|
||||
path.lineTo(rect.left + AndroidUtilities.dp(6), rect.bottom - AndroidUtilities.dp(6) - AndroidUtilities.dp(2 + 3));
|
||||
AndroidUtilities.rectTmp.set(
|
||||
|
|
@ -9020,7 +9035,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (currentMessageObject.isOutOwner()) {
|
||||
textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(11) + getExtraTextX();
|
||||
} else {
|
||||
textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(!mediaBackground && drawPinnedBottom ? 11 : 17) + getExtraTextX();
|
||||
textX = getCurrentBackgroundLeft() + (currentMessageObject.type == MessageObject.TYPE_EMOJIS ? 0 : AndroidUtilities.dp(!mediaBackground && drawPinnedBottom ? 11 : 17)) + getExtraTextX();
|
||||
}
|
||||
if (hasGamePreview) {
|
||||
textX += AndroidUtilities.dp(11);
|
||||
|
|
@ -9063,13 +9078,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
Rect r = currentBackgroundDrawable.getBounds();
|
||||
if (currentMessageObject.isOutOwner() && !mediaBackground && !pinnedBottom) {
|
||||
canvas.clipRect(
|
||||
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
|
||||
r.right - AndroidUtilities.dp(10), r.bottom - AndroidUtilities.dp(4)
|
||||
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
|
||||
r.right - AndroidUtilities.dp(10), r.bottom - AndroidUtilities.dp(4)
|
||||
);
|
||||
} else {
|
||||
canvas.clipRect(
|
||||
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
|
||||
r.right - AndroidUtilities.dp(4), r.bottom - AndroidUtilities.dp(4)
|
||||
r.left + AndroidUtilities.dp(4), r.top + AndroidUtilities.dp(4),
|
||||
r.right - AndroidUtilities.dp(4), r.bottom - AndroidUtilities.dp(4)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -9114,21 +9129,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
Theme.chat_docBackPaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outBubble : Theme.key_chat_inBubble));
|
||||
canvas.drawCircle(photoImage.getCenterX(), photoImage.getCenterY(), photoImage.getImageWidth() / 2, Theme.chat_docBackPaint);
|
||||
}
|
||||
} else if (currentMessageObject.type == MessageObject.TYPE_GEO) {
|
||||
// rect.set(photoImage.getImageX(), photoImage.getImageY(), photoImage.getImageX2(), photoImage.getImageY2());
|
||||
// Theme.chat_docBackPaint.setColor(getThemedColor(currentMessageObject.isOutOwner() ? Theme.key_chat_outLocationBackground : Theme.key_chat_inLocationBackground));
|
||||
// int[] rad = photoImage.getRoundRadius();
|
||||
// rectPath.reset();
|
||||
// for (int a = 0; a < rad.length; a++) {
|
||||
// radii[a * 2] = radii[a * 2 + 1] = rad[a];
|
||||
// }
|
||||
// rectPath.addRoundRect(rect, radii, Path.Direction.CW);
|
||||
// rectPath.close();
|
||||
// canvas.drawPath(rectPath, Theme.chat_docBackPaint);
|
||||
//
|
||||
// Drawable iconDrawable = Theme.chat_locationDrawable[currentMessageObject.isOutOwner() ? 1 : 0];
|
||||
// setDrawableBounds(iconDrawable, rect.centerX() - iconDrawable.getIntrinsicWidth() / 2, rect.centerY() - iconDrawable.getIntrinsicHeight() / 2);
|
||||
// iconDrawable.draw(canvas);
|
||||
}
|
||||
drawMediaCheckBox = mediaCheckBox != null && (checkBoxVisible || mediaCheckBox.getProgress() != 0 || checkBoxAnimationInProgress) && currentMessagesGroup != null;
|
||||
if (drawMediaCheckBox && (mediaCheckBox.isChecked() || mediaCheckBox.getProgress() != 0 || checkBoxAnimationInProgress) && (!textIsSelectionMode())) {
|
||||
|
|
@ -9237,7 +9237,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) {
|
||||
if (photoImage.getVisible() && !hasGamePreview && !currentMessageObject.needDrawBluredPreview()) {
|
||||
if (drawPhotoImage && photoImage.getVisible() && !hasGamePreview && !currentMessageObject.needDrawBluredPreview()) {
|
||||
int oldAlpha = ((BitmapDrawable) Theme.chat_msgMediaMenuDrawable).getPaint().getAlpha();
|
||||
Theme.chat_msgMediaMenuDrawable.setAlpha((int) (oldAlpha * controlsAlpha));
|
||||
setDrawableBounds(Theme.chat_msgMediaMenuDrawable, otherX = (int) (photoImage.getImageX() + photoImage.getImageWidth() - AndroidUtilities.dp(14)), otherY = (int) (photoImage.getImageY() + AndroidUtilities.dp(8.1f)));
|
||||
|
|
@ -10498,7 +10498,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
return firstLineWidth - AndroidUtilities.dp(31 + (isAvatarVisible ? 48 : 0));
|
||||
} else if (currentMessageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
return AndroidUtilities.displaySize.x - (currentMessageObject.textWidth + AndroidUtilities.dp(14)) - AndroidUtilities.dp(52) - (isAvatarVisible ? AndroidUtilities.dp(48) : 0);
|
||||
return Math.max(currentMessageObject.textWidth, (int) ((AndroidUtilities.displaySize.x - AndroidUtilities.dp(52) - (isAvatarVisible ? AndroidUtilities.dp(48) : 0)) * .5f));
|
||||
} else {
|
||||
return backgroundWidth - AndroidUtilities.dp(mediaBackground ? 22 : 31);
|
||||
}
|
||||
|
|
@ -11534,7 +11534,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
} else {
|
||||
currentTimeString = timeString;
|
||||
}
|
||||
timeTextWidth = timeWidth = (int) Math.ceil(Theme.chat_timePaint.measureText(currentTimeString));
|
||||
timeTextWidth = timeWidth = (int) Math.ceil(Theme.chat_timePaint.measureText(currentTimeString, 0, currentTimeString == null ? 0 : currentTimeString.length()));
|
||||
if (currentMessageObject.scheduled && currentMessageObject.messageOwner.date == 0x7FFFFFFE) {
|
||||
timeWidth -= AndroidUtilities.dp(8);
|
||||
}
|
||||
|
|
@ -11583,6 +11583,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
widthForSign -= AndroidUtilities.dp(96);
|
||||
}
|
||||
}
|
||||
signString = Emoji.replaceEmoji(signString, Theme.chat_timePaint.getFontMetricsInt(), AndroidUtilities.dp(10), false);
|
||||
int width = (int) Math.ceil(Theme.chat_timePaint.measureText(signString, 0, signString.length()));
|
||||
if (width > widthForSign) {
|
||||
if (widthForSign <= 0) {
|
||||
|
|
@ -11593,7 +11594,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
width = widthForSign;
|
||||
}
|
||||
}
|
||||
currentTimeString = signString + currentTimeString;
|
||||
SpannableStringBuilder currentTimeStringBuilder = new SpannableStringBuilder(signString);
|
||||
currentTimeStringBuilder.append(currentTimeString);
|
||||
currentTimeString = currentTimeStringBuilder;
|
||||
timeTextWidth += width;
|
||||
timeWidth += width;
|
||||
}
|
||||
|
|
@ -11907,9 +11910,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
lastLine = TextUtils.ellipsize(lastLine, Theme.chat_forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END);
|
||||
try {
|
||||
lastLine = Emoji.replaceEmoji(lastLine, Theme.chat_forwardNamePaint.getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
;
|
||||
} catch (Exception ignore) {}
|
||||
try {
|
||||
forwardedNameLayout[1] = new StaticLayout(lastLine, Theme.chat_forwardNamePaint, forwardedNameWidth + AndroidUtilities.dp(2), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
lastLine = TextUtils.ellipsize(AndroidUtilities.replaceTags(forwardedString), Theme.chat_forwardNamePaint, forwardedNameWidth, TextUtils.TruncateAt.END);
|
||||
|
|
@ -11920,8 +11921,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
forwardNameOffsetX[0] = forwardedNameLayout[0].getLineLeft(0);
|
||||
forwardNameOffsetX[1] = forwardedNameLayout[1].getLineLeft(0);
|
||||
if (messageObject.type != MessageObject.TYPE_ROUND_VIDEO && !messageObject.isAnyKindOfSticker()) {
|
||||
if (messageObject.type != MessageObject.TYPE_ROUND_VIDEO && !messageObject.isAnyKindOfSticker() || messageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
namesOffset += AndroidUtilities.dp(8) + Theme.chat_forwardNamePaint.getTextSize() * 2;
|
||||
if (messageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
namesOffset += AndroidUtilities.dp(8);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
|
|
@ -11930,9 +11934,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
|
||||
drawTopic = false;
|
||||
if (!isThreadChat && !pinnedTop && (MessageObject.getTopicId(messageObject.messageOwner) != 0 || messageObject.replyToForumTopic != null)) {
|
||||
if (!isThreadChat && (delegate != null && delegate.shouldShowTopicButton()) && !pinnedTop && (MessageObject.getTopicId(messageObject.messageOwner, ChatObject.isForum(currentChat)) != 0 || messageObject.replyToForumTopic != null)) {
|
||||
if (currentPosition == null || currentPosition.minY == 0) {
|
||||
int topicId = MessageObject.getTopicId(messageObject.messageOwner);
|
||||
int topicId = messageObject.replyToForumTopic == null ? MessageObject.getTopicId(messageObject.messageOwner, ChatObject.isForum(currentChat)) : messageObject.replyToForumTopic.id;
|
||||
TLRPC.TL_forumTopic topic = messageObject.replyToForumTopic == null ? MessagesController.getInstance(currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), topicId) : messageObject.replyToForumTopic;
|
||||
if (topic != null) {
|
||||
drawTopic = true;
|
||||
|
|
@ -11967,9 +11971,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if ((!isThreadChat || messageObject.getReplyTopMsgId() != 0) && messageObject.hasValidReplyMessageObject() || messageObject.messageOwner.fwd_from != null && messageObject.isDice()) {
|
||||
if (currentPosition == null || currentPosition.minY == 0) {
|
||||
if (!messageObject.isAnyKindOfSticker() && messageObject.type != MessageObject.TYPE_ROUND_VIDEO) {
|
||||
if (!messageObject.isAnyKindOfSticker() && messageObject.type != MessageObject.TYPE_ROUND_VIDEO || messageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
namesOffset += AndroidUtilities.dp(14) + (Theme.chat_replyTextPaint.getTextSize() + Theme.chat_replyNamePaint.getTextSize());
|
||||
if (messageObject.type != MessageObject.TYPE_TEXT) {
|
||||
if (messageObject.type == MessageObject.TYPE_EMOJIS && !drawForwardedName) {
|
||||
namesOffset += AndroidUtilities.dp(12);
|
||||
} else if (messageObject.type != MessageObject.TYPE_TEXT) {
|
||||
namesOffset += AndroidUtilities.dp(5);
|
||||
}
|
||||
}
|
||||
|
|
@ -12511,7 +12517,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (replyNameLayout != null) {
|
||||
replyHeight = AndroidUtilities.dp(7) + Theme.chat_replyNamePaint.getTextSize() + Theme.chat_replyTextPaint.getTextSize();
|
||||
if (currentMessageObject.shouldDrawWithoutBackground()) {
|
||||
if (currentMessageObject.shouldDrawWithoutBackground() && currentMessageObject.type != MessageObject.TYPE_EMOJIS) {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
replyStartX = AndroidUtilities.dp(23);
|
||||
if (isPlayingRound) {
|
||||
|
|
@ -12534,6 +12540,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
} else {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
replyStartX = backgroundDrawableLeft + AndroidUtilities.dp(12) + getExtraTextX();
|
||||
if (currentMessageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
replyStartX -= Math.max(0, replyStartX + Math.max(replyNameWidth, replyTextWidth) + AndroidUtilities.dp(14) - AndroidUtilities.displaySize.x);
|
||||
}
|
||||
} else {
|
||||
if (mediaBackground) {
|
||||
replyStartX = backgroundDrawableLeft + AndroidUtilities.dp(12) + getExtraTextX();
|
||||
|
|
@ -12541,6 +12550,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
replyStartX = backgroundDrawableLeft + AndroidUtilities.dp(drawPinnedBottom ? 12 : 18) + getExtraTextX();
|
||||
}
|
||||
}
|
||||
if (currentMessageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
replyStartX -= AndroidUtilities.dp(7);
|
||||
}
|
||||
forwardHeight = AndroidUtilities.dp(4) + (int) Theme.chat_forwardNamePaint.getTextSize() * 2;
|
||||
replyStartY = AndroidUtilities.dp(12) + (drawNameLayout && nameLayout != null ? AndroidUtilities.dp(6) + (int) Theme.chat_namePaint.getTextSize() : 0) + (drawForwardedName && forwardedNameLayout[0] != null ? AndroidUtilities.dp(4) + forwardHeight : 0);
|
||||
if (drawTopic && topicButton != null) {
|
||||
|
|
@ -12819,37 +12831,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
|
||||
if (checkBoxVisible || checkBoxAnimationInProgress) {
|
||||
if (checkBoxVisible && checkBoxAnimationProgress == 1.0f || !checkBoxVisible && checkBoxAnimationProgress == 0.0f) {
|
||||
checkBoxAnimationInProgress = false;
|
||||
}
|
||||
Interpolator interpolator = checkBoxVisible ? CubicBezierInterpolator.EASE_OUT : CubicBezierInterpolator.EASE_IN;
|
||||
checkBoxTranslation = (int) Math.ceil(interpolator.getInterpolation(checkBoxAnimationProgress) * AndroidUtilities.dp(35));
|
||||
if (!currentMessageObject.isOutOwner()) {
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
animateCheckboxTranslation();
|
||||
int size = AndroidUtilities.dp(21);
|
||||
checkBox.setBounds(AndroidUtilities.dp(8 - 35) + checkBoxTranslation, currentBackgroundDrawable.getBounds().bottom - AndroidUtilities.dp(8) - size, size, size);
|
||||
|
||||
if (checkBoxAnimationInProgress) {
|
||||
long newTime = SystemClock.elapsedRealtime();
|
||||
long dt = newTime - lastCheckBoxAnimationTime;
|
||||
lastCheckBoxAnimationTime = newTime;
|
||||
|
||||
if (checkBoxVisible) {
|
||||
checkBoxAnimationProgress += dt / 200.0f;
|
||||
if (checkBoxAnimationProgress > 1.0f) {
|
||||
checkBoxAnimationProgress = 1.0f;
|
||||
}
|
||||
} else {
|
||||
checkBoxAnimationProgress -= dt / 200.0f;
|
||||
if (checkBoxAnimationProgress <= 0.0f) {
|
||||
checkBoxAnimationProgress = 0.0f;
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
((View) getParent()).invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (!fromParent && drawBackgroundInParent()) {
|
||||
|
|
@ -12992,6 +12976,39 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
canvas.restoreToCount(restoreCount);
|
||||
}
|
||||
|
||||
private void animateCheckboxTranslation() {
|
||||
if (checkBoxVisible || checkBoxAnimationInProgress) {
|
||||
if (checkBoxVisible && checkBoxAnimationProgress == 1.0f || !checkBoxVisible && checkBoxAnimationProgress == 0.0f) {
|
||||
checkBoxAnimationInProgress = false;
|
||||
}
|
||||
Interpolator interpolator = checkBoxVisible ? CubicBezierInterpolator.EASE_OUT : CubicBezierInterpolator.EASE_IN;
|
||||
checkBoxTranslation = (int) Math.ceil(interpolator.getInterpolation(checkBoxAnimationProgress) * AndroidUtilities.dp(35));
|
||||
if (!currentMessageObject.isOutOwner()) {
|
||||
updateTranslation();
|
||||
}
|
||||
|
||||
if (checkBoxAnimationInProgress) {
|
||||
long newTime = SystemClock.elapsedRealtime();
|
||||
long dt = newTime - lastCheckBoxAnimationTime;
|
||||
lastCheckBoxAnimationTime = newTime;
|
||||
|
||||
if (checkBoxVisible) {
|
||||
checkBoxAnimationProgress += dt / 200.0f;
|
||||
if (checkBoxAnimationProgress > 1.0f) {
|
||||
checkBoxAnimationProgress = 1.0f;
|
||||
}
|
||||
} else {
|
||||
checkBoxAnimationProgress -= dt / 200.0f;
|
||||
if (checkBoxAnimationProgress <= 0.0f) {
|
||||
checkBoxAnimationProgress = 0.0f;
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
((View) getParent()).invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean drawBackgroundInParent() {
|
||||
if (canDrawBackgroundInParent && currentMessageObject != null && currentMessageObject.isOutOwner()) {
|
||||
if (resourcesProvider != null) {
|
||||
|
|
@ -13331,6 +13348,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
}
|
||||
sideStartY = layoutHeight + transitionParams.deltaBottom - AndroidUtilities.dp(41);
|
||||
if (currentMessageObject.type == MessageObject.TYPE_EMOJIS && currentMessageObject.textWidth < timeTextWidth) {
|
||||
sideStartY -= AndroidUtilities.dp(22);
|
||||
}
|
||||
if (currentMessagesGroup != null) {
|
||||
sideStartY += currentMessagesGroup.transitionParams.offsetBottom;
|
||||
if (currentMessagesGroup.transitionParams.backgroundChangeBounds) {
|
||||
|
|
@ -13536,6 +13556,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
currentBackgroundDrawable.drawCached(canvas, backgroundCacheParams);
|
||||
currentBackgroundDrawable.setAlpha(255);
|
||||
}
|
||||
|
||||
animateCheckboxTranslation();
|
||||
}
|
||||
|
||||
public boolean hasNameLayout() {
|
||||
|
|
@ -13761,7 +13783,25 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
if (drawForwardedNameLocal && forwardedNameLayoutLocal[0] != null && forwardedNameLayoutLocal[1] != null && (currentPosition == null || currentPosition.minY == 0 && currentPosition.minX == 0)) {
|
||||
if (currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO || currentMessageObject.isAnyKindOfSticker()) {
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(Theme.key_chat_stickerReplyNameText));
|
||||
if (currentMessageObject.needDrawForwarded()) {
|
||||
if (currentMessageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
if (currentMessageObject.needDrawForwarded()) {
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(11) + getExtraTextX();
|
||||
forwardNameXLocal += transitionParams.deltaLeft;
|
||||
} else {
|
||||
forwardNameXLocal = transitionParams.animateForwardNameX;
|
||||
}
|
||||
int width = Math.max(forwardedNameWidthLocal + AndroidUtilities.dp(14), hasReply ? Math.max(replyNameWidth, replyTextWidth) + AndroidUtilities.dp(14) : 0);
|
||||
forwardNameXLocal -= Math.max(0, forwardNameXLocal + width - AndroidUtilities.displaySize.x);
|
||||
} else {
|
||||
if (currentMessageObject.needDrawForwarded()) {
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(mediaBackground || drawPinnedBottom ? 11 : 17) + getExtraTextX();
|
||||
} else {
|
||||
forwardNameXLocal = transitionParams.animateForwardNameX;
|
||||
}
|
||||
}
|
||||
forwardNameXLocal -= AndroidUtilities.dp(7);
|
||||
} else if (currentMessageObject.needDrawForwarded()) {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
forwardNameXLocal = forwardNameX = AndroidUtilities.dp(23);
|
||||
} else {
|
||||
|
|
@ -13808,11 +13848,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
forwardNameY = AndroidUtilities.dp(10) + (drawNameLayout ? AndroidUtilities.dp(5) + (int) Theme.chat_namePaint.getTextSize() : 0) + (drawTopic && topicButton != null ? topicButton.height() + AndroidUtilities.dp(7 + (currentMessageObject.type != MessageObject.TYPE_TEXT ? 3 : 0)) : 0);
|
||||
forwardHeight = AndroidUtilities.dp(4) + (int) Theme.chat_forwardNamePaint.getTextSize() * 2;
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
if (hasPsaHint) {
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(Theme.key_chat_outPsaNameText));
|
||||
} else {
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(Theme.key_chat_outForwardedNameText));
|
||||
}
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(hasPsaHint ? Theme.key_chat_outPsaNameText : Theme.key_chat_outForwardedNameText));
|
||||
if (currentMessageObject.needDrawForwarded()) {
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(11) + getExtraTextX();
|
||||
forwardNameXLocal += transitionParams.deltaLeft;
|
||||
|
|
@ -13820,17 +13856,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
forwardNameXLocal = transitionParams.animateForwardNameX;
|
||||
}
|
||||
} else {
|
||||
if (hasPsaHint) {
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(Theme.key_chat_inPsaNameText));
|
||||
} else {
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(Theme.key_chat_inForwardedNameText));
|
||||
}
|
||||
Theme.chat_forwardNamePaint.setColor(getThemedColor(hasPsaHint ? Theme.key_chat_inPsaNameText : Theme.key_chat_inForwardedNameText));
|
||||
if (currentMessageObject.needDrawForwarded()) {
|
||||
if (mediaBackground) {
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(11) + getExtraTextX();
|
||||
} else {
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(drawPinnedBottom ? 11 : 17) + getExtraTextX();
|
||||
}
|
||||
forwardNameXLocal = forwardNameX = backgroundDrawableLeft + AndroidUtilities.dp(mediaBackground || drawPinnedBottom ? 11 : 17) + getExtraTextX();
|
||||
} else {
|
||||
forwardNameXLocal = transitionParams.animateForwardNameX;
|
||||
}
|
||||
|
|
@ -13911,7 +13939,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
if (drawTopic && topicButton != null && (animatingAlpha > 0 && replyForwardAlpha > 0) && (currentPosition == null || currentPosition.minY == 0 && currentPosition.minX == 0)) {
|
||||
float x, y;
|
||||
if (currentMessageObject.shouldDrawWithoutBackground()) {
|
||||
if (currentMessageObject.shouldDrawWithoutBackground() && currentMessageObject.type != MessageObject.TYPE_EMOJIS) {
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
x = AndroidUtilities.dp(23);
|
||||
if (isPlayingRound) {
|
||||
|
|
@ -14011,9 +14039,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
int offset = (int) Math.min(AndroidUtilities.dp(10), (replyHeight - AndroidUtilities.dp(35)) / 1.5f + AndroidUtilities.dp(10));
|
||||
forwardNameX = replyStartX - replyTextOffset + offset + (needReplyImage ? offset - AndroidUtilities.dp(1) + replyHeight : 0);
|
||||
if ((currentPosition == null || currentPosition.minY == 0 && currentPosition.minX == 0) && !(enterTransitionInProgress && !currentMessageObject.isVoice())) {
|
||||
int restoreToCount = -1;
|
||||
if (getAlpha() * replyForwardAlpha != 1f) {
|
||||
AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
|
||||
canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (0xFF * getAlpha() * replyForwardAlpha), Canvas.ALL_SAVE_FLAG);
|
||||
restoreToCount = canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (0xFF * getAlpha() * replyForwardAlpha), Canvas.ALL_SAVE_FLAG);
|
||||
}
|
||||
|
||||
int leftRad, rightRad, bottomRad = AndroidUtilities.dp(Math.min(2, SharedConfig.bubbleRadius));
|
||||
|
|
@ -14084,8 +14113,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
canvas.restore();
|
||||
}
|
||||
|
||||
if (getAlpha() * replyForwardAlpha != 1f) {
|
||||
canvas.restore();
|
||||
if (restoreToCount >= 0) {
|
||||
canvas.restoreToCount(restoreToCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14302,7 +14331,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
buttonX -= AndroidUtilities.dp(10);
|
||||
}
|
||||
commentButtonRect.set(
|
||||
buttonX - AndroidUtilities.dp((currentMessageObject == null || !currentMessageObject.isOut()) && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL) ? 6 : 0),
|
||||
buttonX - AndroidUtilities.dp((currentMessageObject == null || !currentMessageObject.isOut()) && !drawPinnedBottom && currentPosition == null && (currentMessageObject == null || currentMessageObject.type != MessageObject.TYPE_POLL || pollInstantViewTouchesBottom) ? 6 : 0),
|
||||
(int) buttonY,
|
||||
endX - AndroidUtilities.dp(14),
|
||||
layoutHeight - AndroidUtilities.dp(h)
|
||||
|
|
@ -16240,7 +16269,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
|
||||
instantButtonRect.set(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(44));
|
||||
if (selectorDrawable[0] != null && selectorDrawableMaskType[0] == 2) {
|
||||
selectorDrawable[0].setBounds(textX, instantY, textX + instantWidth, instantY + AndroidUtilities.dp(44));
|
||||
selectorDrawable[0].setBounds(textX - AndroidUtilities.dp(pollInstantViewTouchesBottom ? 6 : 0), instantY, textX + instantWidth, instantY + AndroidUtilities.dp(44));
|
||||
selectorDrawable[0].draw(canvas);
|
||||
}
|
||||
if (instantViewLayout != null) {
|
||||
|
|
@ -18014,14 +18043,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
if (edited && !lastDrawingEdited && timeLayout != null) {
|
||||
String editedStr = LocaleController.getString("EditedMessage", R.string.EditedMessage);
|
||||
String text = timeLayout.getText().toString();
|
||||
int i = text.indexOf(editedStr);
|
||||
CharSequence text = timeLayout.getText();
|
||||
int i = text.toString().indexOf(editedStr);
|
||||
if (i >= 0) {
|
||||
if (i == 0) {
|
||||
animateEditedLayout = new StaticLayout(editedStr, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
spannableStringBuilder.append(editedStr);
|
||||
spannableStringBuilder.append(text.substring(editedStr.length()));
|
||||
spannableStringBuilder.append(text.subSequence(editedStr.length(), text.length()));
|
||||
spannableStringBuilder.setSpan(new EmptyStubSpan(), 0, editedStr.length(), 0);
|
||||
animateTimeLayout = new StaticLayout(spannableStringBuilder, Theme.chat_timePaint, timeTextWidth + AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
animateEditedWidthDiff = timeWidth - lastTimeWidth;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class CheckBoxCell extends FrameLayout {
|
|||
} else {
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||
if (type == 2) {
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 29), 0, (LocaleController.isRTL ? 29 : 0), 0));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 8 : 29), 0, (LocaleController.isRTL ? 29 : 8), 0));
|
||||
} else {
|
||||
int offset = type == 4 ? 56 : 46;
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? padding : offset + (padding - 17)), 0, (LocaleController.isRTL ? offset + (padding - 17) : padding), 0));
|
||||
|
|
@ -238,7 +238,7 @@ public class CheckBoxCell extends FrameLayout {
|
|||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (needDivider) {
|
||||
int offset = currentType == TYPE_CHECK_BOX_ROUND ? 50 : 20;
|
||||
int offset = currentType == TYPE_CHECK_BOX_ROUND ? 60 : 20;
|
||||
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(offset), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(offset) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,28 +10,27 @@ package org.telegram.ui.Cells;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.SimpleTextView;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.CheckBoxSquare;
|
||||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Switch;
|
||||
|
||||
public class CheckBoxUserCell extends FrameLayout {
|
||||
|
||||
private TextView textView;
|
||||
private SimpleTextView textView;
|
||||
private BackupImageView imageView;
|
||||
private CheckBoxSquare checkBox;
|
||||
private Switch checkBox;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean needDivider;
|
||||
|
||||
|
|
@ -40,23 +39,21 @@ public class CheckBoxUserCell extends FrameLayout {
|
|||
public CheckBoxUserCell(Context context, boolean alert) {
|
||||
super(context);
|
||||
|
||||
textView = new TextView(context);
|
||||
textView = new SimpleTextView(context);
|
||||
textView.setTextColor(Theme.getColor(alert ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
textView.setLines(1);
|
||||
textView.setMaxLines(1);
|
||||
textView.setSingleLine(true);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textView.setTextSize(16);
|
||||
textView.setEllipsizeByGradient(true);
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 94), 0, (LocaleController.isRTL ? 94 : 21), 0));
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 21 : 69), 0, (LocaleController.isRTL ? 69 : 21), 0));
|
||||
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
imageView = new BackupImageView(context);
|
||||
imageView.setRoundRadius(AndroidUtilities.dp(36));
|
||||
addView(imageView, LayoutHelper.createFrame(36, 36, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 48, 7, 48, 0));
|
||||
addView(imageView, LayoutHelper.createFrame(36, 36, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 23, 7, 23, 0));
|
||||
|
||||
checkBox = new CheckBoxSquare(context, alert, null);
|
||||
addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 21), 16, (LocaleController.isRTL ? 21 : 0), 0));
|
||||
checkBox = new Switch(context, null);
|
||||
checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
|
||||
addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -72,9 +69,22 @@ public class CheckBoxUserCell extends FrameLayout {
|
|||
return currentUser;
|
||||
}
|
||||
|
||||
private static Drawable verifiedDrawable;
|
||||
private Drawable getVerifiedDrawable() {
|
||||
if (verifiedDrawable == null) {
|
||||
verifiedDrawable = new CombinedDrawable(Theme.dialogs_verifiedDrawable, Theme.dialogs_verifiedCheckDrawable);
|
||||
}
|
||||
return verifiedDrawable;
|
||||
}
|
||||
|
||||
public void setUser(TLRPC.User user, boolean checked, boolean divider) {
|
||||
currentUser = user;
|
||||
textView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
if (user != null) {
|
||||
textView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
} else {
|
||||
textView.setText("");
|
||||
}
|
||||
textView.setRightDrawable(user != null && user.verified ? getVerifiedDrawable() : null);
|
||||
checkBox.setChecked(checked, false);
|
||||
avatarDrawable.setInfo(user);
|
||||
imageView.setForUserOrChat(user, avatarDrawable);
|
||||
|
|
@ -90,11 +100,11 @@ public class CheckBoxUserCell extends FrameLayout {
|
|||
return checkBox.isChecked();
|
||||
}
|
||||
|
||||
public TextView getTextView() {
|
||||
public SimpleTextView getTextView() {
|
||||
return textView;
|
||||
}
|
||||
|
||||
public CheckBoxSquare getCheckBox() {
|
||||
public Switch getCheckBox() {
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -21,8 +21,10 @@ import android.widget.FrameLayout;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
|
|
@ -86,7 +88,14 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
|
||||
addView(avatarImageView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : (13 + padding), 6, LocaleController.isRTL ? (13 + padding) : 0, 0));
|
||||
|
||||
nameTextView = new SimpleTextView(context);
|
||||
nameTextView = new SimpleTextView(context) {
|
||||
@Override
|
||||
public boolean setText(CharSequence value, boolean force) {
|
||||
value = Emoji.replaceEmoji(value, getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
return super.setText(value, force);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(nameTextView);
|
||||
nameTextView.setTextColor(Theme.getColor(forceDarkTheme ? Theme.key_voipgroup_nameText : Theme.key_windowBackgroundWhiteBlackText));
|
||||
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
nameTextView.setTextSize(16);
|
||||
|
|
@ -203,6 +212,7 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
TLRPC.FileLocation photo = null;
|
||||
String newName = null;
|
||||
|
||||
TLRPC.Chat currentChat = null;
|
||||
if (currentObject instanceof String) {
|
||||
((LayoutParams) nameTextView.getLayoutParams()).topMargin = AndroidUtilities.dp(15);
|
||||
avatarImageView.getLayoutParams().width = avatarImageView.getLayoutParams().height = AndroidUtilities.dp(38);
|
||||
|
|
@ -332,7 +342,7 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
|
||||
avatarImageView.setForUserOrChat(currentUser, avatarDrawable);
|
||||
} else {
|
||||
TLRPC.Chat currentChat = (TLRPC.Chat) currentObject;
|
||||
currentChat = (TLRPC.Chat) currentObject;
|
||||
if (currentChat.photo != null) {
|
||||
photo = currentChat.photo.photo_small;
|
||||
}
|
||||
|
|
@ -394,6 +404,8 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
avatarImageView.setRoundRadius(currentChat != null && currentChat.forum ? AndroidUtilities.dp(14) : AndroidUtilities.dp(24));
|
||||
if (currentStatus != null) {
|
||||
statusTextView.setText(currentStatus, true);
|
||||
statusTextView.setTag(Theme.key_windowBackgroundWhiteGrayText);
|
||||
|
|
@ -435,4 +447,8 @@ public class GroupCreateUserCell extends FrameLayout {
|
|||
info.setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleTextView getStatusTextView() {
|
||||
return statusTextView;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,18 @@ public class HeaderCell extends FrameLayout {
|
|||
textView.setMinHeight(AndroidUtilities.dp(height = value) - ((LayoutParams) textView.getLayoutParams()).topMargin);
|
||||
}
|
||||
|
||||
public void setTopMargin(int topMargin) {
|
||||
((LayoutParams) textView.getLayoutParams()).topMargin = AndroidUtilities.dp(topMargin);
|
||||
setHeight(height);
|
||||
}
|
||||
|
||||
public void setBottomMargin(int bottomMargin) {
|
||||
((LayoutParams) textView.getLayoutParams()).bottomMargin = AndroidUtilities.dp(bottomMargin);
|
||||
if (textView2 != null) {
|
||||
((LayoutParams) textView2.getLayoutParams()).bottomMargin = AndroidUtilities.dp(bottomMargin);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabled(boolean value, ArrayList<Animator> animators) {
|
||||
if (animators != null) {
|
||||
animators.add(ObjectAnimator.ofFloat(textView, View.ALPHA, value ? 1.0f : 0.5f));
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
|
|
@ -59,7 +61,14 @@ public class HintDialogCell extends FrameLayout {
|
|||
imageView.setRoundRadius(AndroidUtilities.dp(27));
|
||||
addView(imageView, LayoutHelper.createFrame(54, 54, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView = new TextView(context) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(10), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(nameTextView);
|
||||
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||
nameTextView.setMaxLines(1);
|
||||
|
|
|
|||
|
|
@ -12,14 +12,13 @@ import android.content.Context;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
|
|
@ -242,7 +241,7 @@ public class ManageChatUserCell extends FrameLayout {
|
|||
nameTextView.setText(currentName);
|
||||
} else {
|
||||
lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
|
||||
nameTextView.setText(lastName);
|
||||
nameTextView.setText(Emoji.replaceEmoji(lastName, nameTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(15), false));
|
||||
}
|
||||
if (currrntStatus != null) {
|
||||
statusTextView.setTextColor(statusColor);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class PaymentInfoCell extends FrameLayout {
|
|||
}
|
||||
|
||||
public void setInvoice(TLRPC.TL_messageMediaInvoice invoice, String botname) {
|
||||
setInfo(invoice.title, invoice.description, invoice.photo, botname, invoice);
|
||||
setInfo(invoice.title, invoice.description, invoice.webPhoto, botname, invoice);
|
||||
}
|
||||
|
||||
public void setReceipt(TLRPC.TL_payments_paymentReceipt receipt, String botname) {
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public class RadioCell extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
public void hideRadioButton() {
|
||||
radioButton.setVisibility(View.GONE);
|
||||
}
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (needDivider) {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,16 @@ package org.telegram.ui.Cells;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
|
@ -23,11 +27,12 @@ import android.widget.FrameLayout;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
|
|
@ -40,15 +45,13 @@ import org.telegram.ui.Components.AnimatedFloat;
|
|||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
import org.telegram.ui.Components.DotDividerSpan;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class SessionCell extends FrameLayout {
|
||||
|
||||
private int currentType;
|
||||
private TextView nameTextView;
|
||||
private TextView onlineTextView;
|
||||
private TextView detailTextView;
|
||||
|
|
@ -71,6 +74,8 @@ public class SessionCell extends FrameLayout {
|
|||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
linearLayout.setWeightSum(1);
|
||||
|
||||
currentType = type;
|
||||
|
||||
if (type == 1) {
|
||||
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 49), 11, (LocaleController.isRTL ? 49 : 15), 0));
|
||||
|
||||
|
|
@ -83,19 +88,19 @@ public class SessionCell extends FrameLayout {
|
|||
} else {
|
||||
placeholderImageView = new BackupImageView(context);
|
||||
placeholderImageView.setRoundRadius(AndroidUtilities.dp(10));
|
||||
addView(placeholderImageView, LayoutHelper.createFrame(42, 42, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 16), 13, (LocaleController.isRTL ? 16 : 0), 0));
|
||||
addView(placeholderImageView, LayoutHelper.createFrame(42, 42, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 16), 9, (LocaleController.isRTL ? 16 : 0), 0));
|
||||
|
||||
imageView = new BackupImageView(context);
|
||||
imageView.setRoundRadius(AndroidUtilities.dp(10));
|
||||
addView(imageView, LayoutHelper.createFrame(42, 42, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 16), 13, (LocaleController.isRTL ? 16 : 0), 0));
|
||||
addView(imageView, LayoutHelper.createFrame(42, 42, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 16), 9, (LocaleController.isRTL ? 16 : 0), 0));
|
||||
|
||||
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 72), 11, (LocaleController.isRTL ? 72 : 15), 0));
|
||||
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 72), 7.333f, (LocaleController.isRTL ? 72 : 15), 0));
|
||||
}
|
||||
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, type == 0 ? 15 : 16);
|
||||
nameTextView.setLines(1);
|
||||
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
nameTextView.setMaxLines(1);
|
||||
|
|
@ -104,7 +109,7 @@ public class SessionCell extends FrameLayout {
|
|||
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
|
||||
onlineTextView = new TextView(context);
|
||||
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, type == 0 ? 12 : 13);
|
||||
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);
|
||||
|
||||
if (LocaleController.isRTL) {
|
||||
|
|
@ -127,23 +132,23 @@ public class SessionCell extends FrameLayout {
|
|||
|
||||
detailTextView = new TextView(context);
|
||||
detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, type == 0 ? 13 : 14);
|
||||
detailTextView.setLines(1);
|
||||
detailTextView.setMaxLines(1);
|
||||
detailTextView.setSingleLine(true);
|
||||
detailTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 36, rightMargin, 0));
|
||||
addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, type == 0 ? 28 : 36, rightMargin, 0));
|
||||
|
||||
detailExTextView = new TextView(context);
|
||||
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
|
||||
detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, type == 0 ? 13 : 14);
|
||||
detailExTextView.setLines(1);
|
||||
detailExTextView.setMaxLines(1);
|
||||
detailExTextView.setSingleLine(true);
|
||||
detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 59, rightMargin, 0));
|
||||
addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, type == 0 ? 46 : 59, rightMargin, 0));
|
||||
}
|
||||
|
||||
private void setContentAlpha(float alpha) {
|
||||
|
|
@ -172,7 +177,7 @@ public class SessionCell extends FrameLayout {
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(90) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(currentType == 0 ? 70 : 90) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setSession(TLObject object, boolean divider) {
|
||||
|
|
@ -288,52 +293,106 @@ public class SessionCell extends FrameLayout {
|
|||
}
|
||||
String deviceModel = session.device_model.toLowerCase();
|
||||
int iconId;
|
||||
String colorKey;
|
||||
String colorKey, colorKey2;
|
||||
if (deviceModel.contains("safari")) {
|
||||
iconId = R.drawable.device_web_safari;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (deviceModel.contains("edge")) {
|
||||
iconId = R.drawable.device_web_edge;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (deviceModel.contains("chrome")) {
|
||||
iconId = R.drawable.device_web_chrome;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (deviceModel.contains("opera")) {
|
||||
iconId = R.drawable.device_web_opera;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (deviceModel.contains("firefox")) {
|
||||
iconId = R.drawable.device_web_firefox;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (deviceModel.contains("vivaldi")) {
|
||||
iconId = R.drawable.device_web_other;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
} else if (platform.contains("ios")) {
|
||||
iconId = deviceModel.contains("ipad") ? R.drawable.device_tablet_ios : R.drawable.device_phone_ios;
|
||||
colorKey = Theme.key_avatar_backgroundBlue;
|
||||
colorKey2 = Theme.key_avatar_background2Blue;
|
||||
} else if (platform.contains("windows")) {
|
||||
iconId = R.drawable.device_desktop_win;
|
||||
colorKey = Theme.key_avatar_backgroundCyan;
|
||||
colorKey2 = Theme.key_avatar_background2Cyan;
|
||||
} else if (platform.contains("macos")) {
|
||||
iconId = R.drawable.device_desktop_osx;
|
||||
colorKey = Theme.key_avatar_backgroundCyan;
|
||||
colorKey2 = Theme.key_avatar_background2Cyan;
|
||||
} else if (platform.contains("android")) {
|
||||
iconId = deviceModel.contains("tab") ? R.drawable.device_tablet_android : R.drawable.device_phone_android;
|
||||
colorKey = Theme.key_avatar_backgroundGreen;
|
||||
colorKey2 = Theme.key_avatar_background2Green;
|
||||
} else {
|
||||
if (session.app_name.toLowerCase().contains("desktop")) {
|
||||
iconId = R.drawable.device_desktop_other;
|
||||
colorKey = Theme.key_avatar_backgroundCyan;
|
||||
colorKey2 = Theme.key_avatar_background2Cyan;
|
||||
} else {
|
||||
iconId = R.drawable.device_web_other;
|
||||
colorKey = Theme.key_avatar_backgroundPink;
|
||||
colorKey2 = Theme.key_avatar_background2Pink;
|
||||
}
|
||||
}
|
||||
Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, iconId).mutate();
|
||||
iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_text), PorterDuff.Mode.SRC_IN));
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(42), Theme.getColor(colorKey)), iconDrawable);
|
||||
Drawable bgDrawable = new CircleGradientDrawable(AndroidUtilities.dp(42), Theme.getColor(colorKey), Theme.getColor(colorKey2));
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(bgDrawable, iconDrawable);
|
||||
return combinedDrawable;
|
||||
}
|
||||
|
||||
public static class CircleGradientDrawable extends Drawable {
|
||||
|
||||
private Paint paint;
|
||||
private int size, colorTop, colorBottom;
|
||||
public CircleGradientDrawable(int size, int colorTop, int colorBottom) {
|
||||
this.size = size;
|
||||
this.colorTop = colorTop;
|
||||
this.colorBottom = colorBottom;
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setShader(new LinearGradient(0, 0, 0, size, new int[] {colorTop, colorBottom}, new float[] {0, 1}, Shader.TileMode.CLAMP));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
canvas.drawCircle(getBounds().centerX(), getBounds().centerY(), Math.min(getBounds().width(), getBounds().height()) / 2f, paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int i) {
|
||||
paint.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSPARENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
float stubAlpha = showStubValue.set(showStub ? 1 : 0);
|
||||
|
|
@ -381,7 +440,7 @@ public class SessionCell extends FrameLayout {
|
|||
this.globalGradient = globalGradient;
|
||||
showStub = true;
|
||||
|
||||
Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, AndroidUtilities.isTablet() ? R.drawable.device_tablet_android : R.drawable.device_phone_android).mutate();
|
||||
Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, AndroidUtilities.isTablet() ? R.drawable.device_tablet_android : R.drawable.device_phone_android).mutate();
|
||||
iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_text), PorterDuff.Mode.SRC_IN));
|
||||
CombinedDrawable combinedDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(42), Theme.getColor(Theme.key_avatar_backgroundGreen)), iconDrawable);
|
||||
if (placeholderImageView != null) {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ import androidx.dynamicanimation.animation.SpringForce;
|
|||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
|
|
@ -80,7 +82,14 @@ public class ShareDialogCell extends FrameLayout {
|
|||
addView(imageView, LayoutHelper.createFrame(56, 56, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 7, 0, 0));
|
||||
}
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView = new TextView(context) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(10), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(nameTextView);
|
||||
nameTextView.setTextColor(getThemedColor(type == TYPE_CALL ? Theme.key_voipgroup_nameText : Theme.key_dialogTextBlack));
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
||||
nameTextView.setMaxLines(2);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.CheckBox2;
|
||||
import org.telegram.ui.Components.DotDividerSpan;
|
||||
import org.telegram.ui.Components.FlickerLoadingView;
|
||||
|
|
@ -55,11 +57,14 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
|
||||
private int titleY = AndroidUtilities.dp(9);
|
||||
private StaticLayout titleLayout;
|
||||
AnimatedEmojiSpan.EmojiGroupedSpans titleLayoutEmojis;
|
||||
|
||||
private int descriptionY = AndroidUtilities.dp(29);
|
||||
AnimatedEmojiSpan.EmojiGroupedSpans descriptionLayoutEmojis;
|
||||
private StaticLayout descriptionLayout;
|
||||
|
||||
private int captionY = AndroidUtilities.dp(29);
|
||||
AnimatedEmojiSpan.EmojiGroupedSpans captionLayoutEmojis;
|
||||
private StaticLayout captionLayout;
|
||||
|
||||
private MessageObject currentMessageObject;
|
||||
|
|
@ -159,6 +164,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
}
|
||||
CharSequence titleFinal = TextUtils.ellipsize(title, Theme.chat_contextResult_titleTextPaint, maxWidth - dateWidth, TextUtils.TruncateAt.END);
|
||||
titleLayout = new StaticLayout(titleFinal, Theme.chat_contextResult_titleTextPaint, maxWidth + AndroidUtilities.dp(4) - dateWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
titleLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, titleLayoutEmojis, titleLayout);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
@ -170,6 +176,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
sequence = TextUtils.ellipsize(AndroidUtilities.ellipsizeCenterEnd(sequence, currentMessageObject.highlightedWords.get(0), maxWidth, captionTextPaint, 130), captionTextPaint, maxWidth, TextUtils.TruncateAt.END);
|
||||
captionLayout = new StaticLayout(sequence, captionTextPaint, maxWidth + AndroidUtilities.dp(4), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
captionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, captionLayoutEmojis, captionLayout);
|
||||
}
|
||||
try {
|
||||
if (viewType == VIEW_TYPE_GLOBAL_SEARCH && (currentMessageObject.isVoice() || currentMessageObject.isRoundVideo())) {
|
||||
|
|
@ -190,6 +197,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
author = TextUtils.ellipsize(author, paint, maxWidth, TextUtils.TruncateAt.END);
|
||||
descriptionLayout = new StaticLayout(author, paint, maxWidth + AndroidUtilities.dp(4), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
descriptionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, descriptionLayoutEmojis, descriptionLayout);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
@ -249,6 +257,10 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidReset);
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
|
||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidStart);
|
||||
|
||||
titleLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, titleLayoutEmojis, titleLayout);
|
||||
descriptionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, descriptionLayoutEmojis, descriptionLayout);
|
||||
captionLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, captionLayoutEmojis, captionLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -259,6 +271,10 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidReset);
|
||||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
|
||||
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidStart);
|
||||
|
||||
AnimatedEmojiSpan.release(this, titleLayoutEmojis);
|
||||
AnimatedEmojiSpan.release(this, descriptionLayoutEmojis);
|
||||
AnimatedEmojiSpan.release(this, captionLayoutEmojis);
|
||||
}
|
||||
|
||||
public MessageObject getMessage() {
|
||||
|
|
@ -617,6 +633,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline) + (LocaleController.isRTL && dateLayout != null ? dateLayout.getWidth() + AndroidUtilities.dp(4) : 0), titleY);
|
||||
titleLayout.draw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, titleLayout, titleLayoutEmojis, 0, null, 0, 0, 0, 1f);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
|
@ -633,6 +650,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
|
|||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), descriptionY);
|
||||
descriptionLayout.draw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, descriptionLayout, descriptionLayoutEmojis, 0, null, 0, 0, 0, 1f);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.CheckBox2;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
|
|
@ -63,7 +64,7 @@ public class SharedDocumentCell extends FrameLayout implements DownloadControlle
|
|||
private BackupImageView thumbImageView;
|
||||
private TextView nameTextView;
|
||||
private TextView extTextView;
|
||||
private TextView dateTextView;
|
||||
private AnimatedEmojiSpan.TextViewEmojis dateTextView;
|
||||
private RLottieImageView statusImageView;
|
||||
private LineProgressView progressView;
|
||||
private CheckBox2 checkBox;
|
||||
|
|
@ -211,7 +212,7 @@ public class SharedDocumentCell extends FrameLayout implements DownloadControlle
|
|||
addView(statusImageView, LayoutHelper.createFrame(14, 14, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 8 : 70, 33, LocaleController.isRTL ? 72 : 8, 0));
|
||||
}
|
||||
|
||||
dateTextView = new TextView(context);
|
||||
dateTextView = new AnimatedEmojiSpan.TextViewEmojis(context);
|
||||
dateTextView.setTextColor(getThemedColor(Theme.key_windowBackgroundWhiteGrayText3));
|
||||
dateTextView.setLines(1);
|
||||
dateTextView.setMaxLines(1);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ package org.telegram.ui.Cells;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.CornerPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.Rect;
|
||||
|
|
@ -34,19 +33,22 @@ import android.widget.FrameLayout;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.ImageReceiver;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaDataController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
import org.telegram.ui.Components.CheckBox2;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.LetterDrawable;
|
||||
import org.telegram.ui.Components.LinkPath;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.LinkSpanDrawable;
|
||||
import org.telegram.ui.Components.TextStyleSpan;
|
||||
import org.telegram.ui.Components.spoilers.SpoilerEffect;
|
||||
import org.telegram.ui.FilteredSearchView;
|
||||
|
|
@ -90,8 +92,8 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
|
||||
checkingForLongPress = false;
|
||||
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
|
||||
if (pressedLink >= 0) {
|
||||
delegate.onLinkPress(links.get(pressedLink).toString(), true);
|
||||
if (pressedLinkIndex >= 0) {
|
||||
delegate.onLinkPress(links.get(pressedLinkIndex).toString(), true);
|
||||
}
|
||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
|
||||
onTouchEvent(event);
|
||||
|
|
@ -121,9 +123,10 @@ public class SharedLinkCell extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
private LinkSpanDrawable.LinkCollector linksCollector = new LinkSpanDrawable.LinkCollector(this);
|
||||
private boolean linkPreviewPressed;
|
||||
private LinkPath urlPath;
|
||||
private int pressedLink;
|
||||
private int pressedLinkIndex;
|
||||
private LinkSpanDrawable pressedLink;
|
||||
|
||||
private ImageReceiver linkImageView;
|
||||
private boolean drawLinkImageView;
|
||||
|
|
@ -170,6 +173,7 @@ public class SharedLinkCell extends FrameLayout {
|
|||
private StaticLayout dateLayout;
|
||||
private int fromInfoLayoutY = AndroidUtilities.dp(30);
|
||||
private StaticLayout fromInfoLayout;
|
||||
private AnimatedEmojiSpan.EmojiGroupedSpans fromInfoLayoutEmojis;
|
||||
|
||||
private Theme.ResourcesProvider resourcesProvider;
|
||||
private int viewType;
|
||||
|
|
@ -190,9 +194,6 @@ public class SharedLinkCell extends FrameLayout {
|
|||
this.viewType = viewType;
|
||||
setFocusable(true);
|
||||
|
||||
urlPath = new LinkPath();
|
||||
urlPath.setUseRoundRect(true);
|
||||
|
||||
titleTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
titleTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
titleTextPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
|
||||
|
|
@ -477,6 +478,7 @@ public class SharedLinkCell extends FrameLayout {
|
|||
|
||||
if (viewType == VIEW_TYPE_GLOBAL_SEARCH) {
|
||||
fromInfoLayout = ChatMessageCell.generateStaticLayout(FilteredSearchView.createFromInfoString(message), description2TextPaint, maxWidth, maxWidth, 0, desctiptionLines);
|
||||
fromInfoLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, fromInfoLayoutEmojis, fromInfoLayout);
|
||||
}
|
||||
|
||||
int height = 0;
|
||||
|
|
@ -538,6 +540,7 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (drawLinkImageView) {
|
||||
linkImageView.onDetachedFromWindow();
|
||||
}
|
||||
AnimatedEmojiSpan.release(this, fromInfoLayoutEmojis);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -546,6 +549,7 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (drawLinkImageView) {
|
||||
linkImageView.onAttachedToWindow();
|
||||
}
|
||||
fromInfoLayoutEmojis = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, fromInfoLayoutEmojis, fromInfoLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -562,15 +566,18 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (layout.getLineCount() > 0) {
|
||||
int height = layout.getLineBottom(layout.getLineCount() - 1);
|
||||
int linkPosX = AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline);
|
||||
if (x >= linkPosX + layout.getLineLeft(0) && x <= linkPosX + layout.getLineWidth(0) && y >= linkY + offset && y <= linkY + offset + height) {
|
||||
if (
|
||||
x >= linkPosX + layout.getLineLeft(0) && x <= linkPosX + layout.getLineWidth(0) &&
|
||||
y >= linkY + offset && y <= linkY + offset + height
|
||||
) {
|
||||
ok = true;
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
resetPressedLink();
|
||||
|
||||
spoilerPressed = null;
|
||||
if (linkSpoilers.get(a, null) != null) {
|
||||
for (SpoilerEffect eff : linkSpoilers.get(a)) {
|
||||
if (eff.getBounds().contains(x - linkPosX, y - linkY - offset)) {
|
||||
resetPressedLink();
|
||||
spoilerPressed = eff;
|
||||
spoilerTypePressed = SPOILER_TYPE_LINK;
|
||||
break;
|
||||
|
|
@ -581,24 +588,30 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (spoilerPressed != null) {
|
||||
result = true;
|
||||
} else {
|
||||
pressedLink = a;
|
||||
linkPreviewPressed = true;
|
||||
startCheckLongPress();
|
||||
try {
|
||||
urlPath.setCurrentLayout(layout, 0, 0);
|
||||
layout.getSelectionPath(0, layout.getText().length(), urlPath);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
if (pressedLinkIndex != a || pressedLink == null || !linkPreviewPressed) {
|
||||
resetPressedLink();
|
||||
pressedLinkIndex = a;
|
||||
pressedLink = new LinkSpanDrawable(null, resourcesProvider, x - linkPosX, y - linkY - offset);
|
||||
LinkPath urlPath = pressedLink.obtainNewPath();
|
||||
linkPreviewPressed = true;
|
||||
linksCollector.addLink(pressedLink);
|
||||
startCheckLongPress();
|
||||
try {
|
||||
urlPath.setCurrentLayout(layout, 0, linkPosX, linkY + offset);
|
||||
layout.getSelectionPath(0, layout.getText().length(), urlPath);
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
} else if (linkPreviewPressed) {
|
||||
try {
|
||||
TLRPC.WebPage webPage = pressedLink == 0 && message.messageOwner.media != null ? message.messageOwner.media.webpage : null;
|
||||
TLRPC.WebPage webPage = pressedLinkIndex == 0 && message.messageOwner.media != null ? message.messageOwner.media.webpage : null;
|
||||
if (webPage != null && webPage.embed_url != null && webPage.embed_url.length() != 0) {
|
||||
delegate.needOpenWebView(webPage, message);
|
||||
} else {
|
||||
delegate.onLinkPress(links.get(pressedLink).toString(), false);
|
||||
delegate.onLinkPress(links.get(pressedLinkIndex).toString(), false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
|
|
@ -738,7 +751,9 @@ public class SharedLinkCell extends FrameLayout {
|
|||
}
|
||||
|
||||
protected void resetPressedLink() {
|
||||
pressedLink = -1;
|
||||
linksCollector.clear(true);
|
||||
pressedLinkIndex = -1;
|
||||
pressedLink = null;
|
||||
linkPreviewPressed = false;
|
||||
cancelCheckLongPress();
|
||||
invalidate();
|
||||
|
|
@ -751,8 +766,6 @@ public class SharedLinkCell extends FrameLayout {
|
|||
checkBox.setChecked(checked, animated);
|
||||
}
|
||||
|
||||
private Paint urlPaint;
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (viewType == VIEW_TYPE_GLOBAL_SEARCH) {
|
||||
|
|
@ -815,16 +828,8 @@ public class SharedLinkCell extends FrameLayout {
|
|||
path.addRect(b.left, b.top, b.right, b.bottom, Path.Direction.CW);
|
||||
}
|
||||
}
|
||||
if (urlPaint == null) {
|
||||
urlPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
urlPaint.setPathEffect(new CornerPathEffect(AndroidUtilities.dp(4)));
|
||||
}
|
||||
urlPaint.setColor(Theme.getColor(Theme.key_chat_linkSelectBackground, resourcesProvider));
|
||||
canvas.save();
|
||||
canvas.clipPath(path, Region.Op.DIFFERENCE);
|
||||
if (pressedLink == a) {
|
||||
canvas.drawPath(urlPath, urlPaint);
|
||||
}
|
||||
layout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
|
|
@ -834,10 +839,6 @@ public class SharedLinkCell extends FrameLayout {
|
|||
if (spoilers != null && !spoilers.isEmpty())
|
||||
spoilers.get(0).getRipplePath(path);
|
||||
canvas.clipPath(path);
|
||||
|
||||
if (pressedLink == a) {
|
||||
canvas.drawPath(urlPath, urlPaint);
|
||||
}
|
||||
layout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
|
|
@ -848,12 +849,17 @@ public class SharedLinkCell extends FrameLayout {
|
|||
offset += layout.getLineBottom(layout.getLineCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (linksCollector.draw(canvas)) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (fromInfoLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(LocaleController.isRTL ? 8 : AndroidUtilities.leftBaseline), fromInfoLayoutY );
|
||||
fromInfoLayout.draw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, fromInfoLayout, fromInfoLayoutEmojis, 0, null, 0, 0, 0, 1f);
|
||||
canvas.restore();
|
||||
}
|
||||
letterDrawable.draw(canvas);
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.DocumentObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaDataController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
|
|
@ -50,10 +50,7 @@ import org.telegram.ui.Components.Easings;
|
|||
import org.telegram.ui.Components.ForegroundColorSpanThemable;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Premium.PremiumButtonView;
|
||||
import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet;
|
||||
import org.telegram.ui.Components.RadialProgressView;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PremiumPreviewFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
|
@ -182,7 +179,14 @@ public class StickerSetCell extends FrameLayout {
|
|||
}
|
||||
});
|
||||
|
||||
textView = new TextView(context);
|
||||
textView = new TextView(context) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(textView);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ package org.telegram.ui.Cells;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
|
@ -39,11 +40,17 @@ public class TextCell extends FrameLayout {
|
|||
private int leftPadding;
|
||||
private boolean needDivider;
|
||||
private int offsetFromImage = 71;
|
||||
public int heightDp = 48;
|
||||
public int imageLeft = 21;
|
||||
private boolean inDialogs;
|
||||
private boolean prioritizeTitleOverValue;
|
||||
private Theme.ResourcesProvider resourcesProvider;
|
||||
private boolean attached;
|
||||
private int loadingSize;
|
||||
private boolean drawLoading;
|
||||
private boolean measureDelay;
|
||||
private float loadingProgress;
|
||||
private float drawLoadingProgress;
|
||||
|
||||
|
||||
public TextCell(Context context) {
|
||||
|
|
@ -97,6 +104,10 @@ public class TextCell extends FrameLayout {
|
|||
setFocusable(true);
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checkBox != null && checkBox.isChecked();
|
||||
}
|
||||
|
||||
public Switch getCheckBox() {
|
||||
return checkBox;
|
||||
}
|
||||
|
|
@ -129,7 +140,7 @@ public class TextCell extends FrameLayout {
|
|||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = AndroidUtilities.dp(48);
|
||||
int height = AndroidUtilities.dp(heightDp);
|
||||
|
||||
if (prioritizeTitleOverValue) {
|
||||
textView.measure(MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(71 + leftPadding), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.EXACTLY));
|
||||
|
|
@ -301,6 +312,21 @@ public class TextCell extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
public void setTextAndCheck(String text, boolean checked, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
textView.setText(text);
|
||||
imageView.setVisibility(GONE);
|
||||
valueImageView.setVisibility(GONE);
|
||||
needDivider = divider;
|
||||
if (checkBox != null) {
|
||||
checkBox.setVisibility(VISIBLE);
|
||||
checkBox.setChecked(checked, false);
|
||||
}
|
||||
needDivider = divider;
|
||||
setWillNotDraw(!needDivider);
|
||||
}
|
||||
|
||||
public void setTextAndCheckAndIcon(String text, boolean checked, int resId, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
|
|
@ -318,6 +344,23 @@ public class TextCell extends FrameLayout {
|
|||
setWillNotDraw(!needDivider);
|
||||
}
|
||||
|
||||
public void setTextAndCheckAndIcon(String text, boolean checked, Drawable resDrawable, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
textView.setText(text);
|
||||
valueTextView.setVisibility(GONE);
|
||||
valueImageView.setVisibility(GONE);
|
||||
if (checkBox != null) {
|
||||
checkBox.setVisibility(VISIBLE);
|
||||
checkBox.setChecked(checked, false);
|
||||
}
|
||||
imageView.setVisibility(VISIBLE);
|
||||
imageView.setPadding(0, AndroidUtilities.dp(7), 0, 0);
|
||||
imageView.setImageDrawable(resDrawable);
|
||||
needDivider = divider;
|
||||
setWillNotDraw(!needDivider);
|
||||
}
|
||||
|
||||
public void setTextAndValueDrawable(String text, Drawable drawable, boolean divider) {
|
||||
imageLeft = 21;
|
||||
offsetFromImage = 71;
|
||||
|
|
@ -411,4 +454,71 @@ public class TextCell extends FrameLayout {
|
|||
super.onDetachedFromWindow();
|
||||
attached = false;
|
||||
}
|
||||
|
||||
public void setDrawLoading(boolean drawLoading, int size, boolean animated) {
|
||||
this.drawLoading = drawLoading;
|
||||
this.loadingSize = size;
|
||||
|
||||
if (!animated) {
|
||||
drawLoadingProgress = drawLoading ? 1f : 0f;
|
||||
} else {
|
||||
measureDelay = true;
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
Paint paint;
|
||||
private boolean incrementLoadingProgress;
|
||||
private int changeProgressStartDelay;
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
if (drawLoading || drawLoadingProgress != 0) {
|
||||
if (paint == null) {
|
||||
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
paint.setColor(Theme.getColor(Theme.key_dialogSearchBackground, resourcesProvider));
|
||||
}
|
||||
//LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT;
|
||||
if (incrementLoadingProgress) {
|
||||
loadingProgress += 16 / 1000f;
|
||||
if (loadingProgress > 1f) {
|
||||
loadingProgress = 1f;
|
||||
incrementLoadingProgress = false;
|
||||
}
|
||||
} else {
|
||||
loadingProgress -= 16 / 1000f;
|
||||
if (loadingProgress < 0) {
|
||||
loadingProgress = 0;
|
||||
incrementLoadingProgress = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (changeProgressStartDelay > 0) {
|
||||
changeProgressStartDelay -= 15;
|
||||
} else if (drawLoading && drawLoadingProgress != 1f) {
|
||||
drawLoadingProgress += 16 / 150f;
|
||||
if (drawLoadingProgress > 1f) {
|
||||
drawLoadingProgress = 1f;
|
||||
}
|
||||
} else if (!drawLoading && drawLoadingProgress != 0) {
|
||||
drawLoadingProgress -= 16 / 150f;
|
||||
if (drawLoadingProgress < 0) {
|
||||
drawLoadingProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
float alpha = (0.6f + 0.4f * loadingProgress) * drawLoadingProgress;
|
||||
paint.setAlpha((int) (255 * alpha));
|
||||
int cy = getMeasuredHeight() >> 1;
|
||||
AndroidUtilities.rectTmp.set(getMeasuredWidth() - AndroidUtilities.dp(11) - AndroidUtilities.dp(loadingSize), cy - AndroidUtilities.dp(3), getMeasuredWidth() - AndroidUtilities.dp(11), cy + AndroidUtilities.dp(3));
|
||||
if (LocaleController.isRTL) {
|
||||
AndroidUtilities.rectTmp.left = getMeasuredWidth() - AndroidUtilities.rectTmp.left;
|
||||
AndroidUtilities.rectTmp.right = getMeasuredWidth() - AndroidUtilities.rectTmp.right;
|
||||
}
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(3), AndroidUtilities.dp(3), paint);
|
||||
invalidate();
|
||||
}
|
||||
valueTextView.setAlpha(1f - drawLoadingProgress);
|
||||
super.dispatchDraw(canvas);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import android.widget.TextView;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Switch;
|
||||
|
|
@ -169,6 +168,10 @@ public class TextCheckCell2 extends FrameLayout {
|
|||
return checkBox.isChecked();
|
||||
}
|
||||
|
||||
public Switch getCheckBox() {
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (needDivider) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
|
|
@ -27,7 +26,6 @@ import android.widget.TextView;
|
|||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.ui.ActionBar.SimpleTextView;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.LinkSpanDrawable;
|
||||
|
|
@ -146,6 +144,9 @@ public class TextDetailCell extends FrameLayout {
|
|||
|
||||
public void setImageClickListener(View.OnClickListener clickListener) {
|
||||
imageView.setOnClickListener(clickListener);
|
||||
if (clickListener == null) {
|
||||
imageView.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextWithEmojiAndValue(CharSequence text, CharSequence value, boolean divider) {
|
||||
|
|
|
|||
|
|
@ -1800,6 +1800,10 @@ public abstract class TextSelectionHelper<Cell extends TextSelectionHelper.Selec
|
|||
yOffset = lastBlock.textYOffset;
|
||||
}
|
||||
|
||||
if (lastLayout == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
y = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,11 +215,19 @@ public class TextSettingsCell extends FrameLayout {
|
|||
MarginLayoutParams params = (MarginLayoutParams) textView.getLayoutParams();
|
||||
if (resId == 0) {
|
||||
imageView.setVisibility(GONE);
|
||||
params.leftMargin = 0;
|
||||
if (LocaleController.isRTL) {
|
||||
params.rightMargin = AndroidUtilities.dp(this.padding);
|
||||
} else {
|
||||
params.leftMargin = AndroidUtilities.dp(this.padding);
|
||||
}
|
||||
} else {
|
||||
imageView.setImageResource(resId);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
params.leftMargin = AndroidUtilities.dp(71);
|
||||
if (LocaleController.isRTL) {
|
||||
params.rightMargin = AndroidUtilities.dp(71);
|
||||
} else {
|
||||
params.leftMargin = AndroidUtilities.dp(71);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ public class TopicExceptionCell extends FrameLayout {
|
|||
|
||||
public void setTopic(long dialogId, TLRPC.TL_forumTopic topic) {
|
||||
ForumUtilities.setTopicIcon(backupImageView, topic);
|
||||
if (backupImageView != null && backupImageView.getImageReceiver() != null && backupImageView.getImageReceiver().getDrawable() instanceof ForumUtilities.GeneralTopicDrawable) {
|
||||
((ForumUtilities.GeneralTopicDrawable) backupImageView.getImageReceiver().getDrawable()).setColor(Theme.getColor(Theme.key_chats_archiveBackground));
|
||||
}
|
||||
title.setText(topic.title);
|
||||
subtitle.setText(MessagesController.getInstance(UserConfig.selectedAccount).getMutedString(dialogId, topic.id));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ public class TopicSearchCell extends FrameLayout {
|
|||
textView.setText(AndroidUtilities.highlightText(topic.title, topic.searchQuery, null));
|
||||
}
|
||||
ForumUtilities.setTopicIcon(backupImageView, topic);
|
||||
if (backupImageView != null && backupImageView.getImageReceiver() != null && backupImageView.getImageReceiver().getDrawable() instanceof ForumUtilities.GeneralTopicDrawable) {
|
||||
((ForumUtilities.GeneralTopicDrawable) backupImageView.getImageReceiver().getDrawable()).setColor(Theme.getColor(Theme.key_chats_archiveBackground));
|
||||
}
|
||||
}
|
||||
|
||||
public TLRPC.TL_forumTopic getTopic() {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import org.telegram.ui.Components.BackupImageView;
|
|||
import org.telegram.ui.Components.CheckBox;
|
||||
import org.telegram.ui.Components.CheckBoxSquare;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.Premium.PremiumGradient;
|
||||
import org.telegram.ui.NotificationsSettingsActivity;
|
||||
|
||||
public class UserCell extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
|
@ -546,6 +545,8 @@ public class UserCell extends FrameLayout implements NotificationCenter.Notifica
|
|||
avatarImageView.setImageDrawable(avatarDrawable);
|
||||
}
|
||||
|
||||
avatarImageView.setRoundRadius(currentChat != null && currentChat.forum ? AndroidUtilities.dp(14) : AndroidUtilities.dp(24));
|
||||
|
||||
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
|
||||
if (adminTextView != null) {
|
||||
adminTextView.setTextColor(Theme.getColor(Theme.key_profile_creatorIcon, resourcesProvider));
|
||||
|
|
|
|||
|
|
@ -12,15 +12,16 @@ import android.content.Context;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
|
|
@ -79,7 +80,14 @@ public class UserCell2 extends FrameLayout {
|
|||
avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
|
||||
addView(avatarImageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 7 + padding, 11, LocaleController.isRTL ? 7 + padding : 0, 0));
|
||||
|
||||
nameTextView = new SimpleTextView(context);
|
||||
nameTextView = new SimpleTextView(context) {
|
||||
@Override
|
||||
public boolean setText(CharSequence value) {
|
||||
value = Emoji.replaceEmoji(value, getPaint().getFontMetricsInt(), AndroidUtilities.dp(15), false);
|
||||
return super.setText(value);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(nameTextView);
|
||||
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
|
||||
nameTextView.setTextSize(17);
|
||||
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
|
|
@ -296,6 +304,8 @@ public class UserCell2 extends FrameLayout {
|
|||
avatarImageView.setImageDrawable(avatarDrawable);
|
||||
}
|
||||
|
||||
avatarImageView.setRoundRadius(currentChat != null && currentChat.forum ? AndroidUtilities.dp(14) : AndroidUtilities.dp(24));
|
||||
|
||||
if (imageView.getVisibility() == VISIBLE && currentDrawable == 0 || imageView.getVisibility() == GONE && currentDrawable != 0) {
|
||||
imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE);
|
||||
imageView.setImageResource(currentDrawable);
|
||||
|
|
|
|||
|
|
@ -25,22 +25,31 @@ import android.graphics.Path;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.CharacterStyle;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.TextureView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
|
|
@ -48,6 +57,7 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.core.content.FileProvider;
|
||||
import androidx.recyclerview.widget.ChatListItemAnimator;
|
||||
|
|
@ -74,6 +84,7 @@ import org.telegram.messenger.MessagesController;
|
|||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
|
|
@ -81,6 +92,8 @@ import org.telegram.tgnet.TLRPC;
|
|||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
|
||||
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BackDrawable;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
|
@ -94,8 +107,10 @@ import org.telegram.ui.Cells.ChatMessageCell;
|
|||
import org.telegram.ui.Cells.ChatUnreadCell;
|
||||
import org.telegram.ui.Components.AdminLogFilterAlert;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.ChatAvatarContainer;
|
||||
import org.telegram.ui.Components.ChatScrimPopupContainerLayout;
|
||||
import org.telegram.ui.Components.ClearHistoryAlert;
|
||||
import org.telegram.ui.Components.EmbedBottomSheet;
|
||||
import org.telegram.ui.Components.InviteLinkBottomSheet;
|
||||
|
|
@ -265,6 +280,14 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
|
||||
loadMessages(true);
|
||||
loadAdmins();
|
||||
|
||||
Bulletin.addDelegate(this, new Bulletin.Delegate() {
|
||||
@Override
|
||||
public int getBottomOffset(int tag) {
|
||||
return AndroidUtilities.dp(51);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +718,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
||||
}
|
||||
|
||||
updateMessagesVisisblePart();
|
||||
updateMessagesVisiblePart();
|
||||
notifyHeightChanged();
|
||||
}
|
||||
|
||||
|
|
@ -844,7 +867,12 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
return result;
|
||||
}
|
||||
};
|
||||
chatListView.setOnItemClickListener((view, position) -> createMenu(view));
|
||||
chatListView.setOnItemClickListener(new RecyclerListView.OnItemClickListenerExtended() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position, float x, float y) {
|
||||
createMenu(view, x, y);
|
||||
}
|
||||
});
|
||||
chatListView.setTag(1);
|
||||
chatListView.setVerticalScrollBarEnabled(true);
|
||||
chatListView.setAdapter(chatAdapter = new ChatActivityAdapter(context));
|
||||
|
|
@ -945,7 +973,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
}
|
||||
checkScrollForLoad(true);
|
||||
updateMessagesVisisblePart();
|
||||
updateMessagesVisiblePart();
|
||||
}
|
||||
});
|
||||
if (scrollToPositionOnRecreate != -1) {
|
||||
|
|
@ -1108,7 +1136,33 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
return fragmentView;
|
||||
}
|
||||
|
||||
private ActionBarPopupWindow scrimPopupWindow;
|
||||
private int scrimPopupX, scrimPopupY;
|
||||
private void closeMenu() {
|
||||
if (scrimPopupWindow != null) {
|
||||
scrimPopupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private final static int OPTION_COPY = 3;
|
||||
private final static int OPTION_SAVE_TO_GALLERY = 4;
|
||||
private final static int OPTION_APPLY_FILE = 5;
|
||||
private final static int OPTION_SHARE = 6;
|
||||
private final static int OPTION_SAVE_TO_GALLERY2 = 7;
|
||||
private final static int OPTION_SAVE_STICKER = 9;
|
||||
private final static int OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC = 10;
|
||||
private final static int OPTION_SAVE_TO_GIFS = 11;
|
||||
private final static int OPTION_ADD_CONTACT = 15;
|
||||
private final static int OPTION_COPY_PHONE = 16;
|
||||
private final static int OPTION_CALL = 17;
|
||||
private final static int OPTION_RESTRICT = 33;
|
||||
private final static int OPTION_REPORT_FALSE_POSITIVE = 34;
|
||||
|
||||
private boolean createMenu(View v) {
|
||||
return createMenu(v, 0, 0);
|
||||
}
|
||||
|
||||
private boolean createMenu(View v, float x, float y) {
|
||||
MessageObject message = null;
|
||||
if (v instanceof ChatMessageCell) {
|
||||
message = ((ChatMessageCell) v).getMessageObject();
|
||||
|
|
@ -1123,14 +1177,56 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
if (getParentActivity() == null) {
|
||||
return false;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
ArrayList<CharSequence> items = new ArrayList<>();
|
||||
final ArrayList<Integer> options = new ArrayList<>();
|
||||
final ArrayList<Integer> icons = new ArrayList<>();
|
||||
|
||||
if (message.currentEvent != null && message.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage && message.currentEvent.user_id == getMessagesController().telegramAntispamUserId) {
|
||||
if (v instanceof ChatActionCell) {
|
||||
SpannableString arrow = new SpannableString(">");
|
||||
Drawable arrowDrawable = getContext().getResources().getDrawable(R.drawable.attach_arrow_right).mutate();
|
||||
arrowDrawable.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_undo_cancelColor), PorterDuff.Mode.MULTIPLY));
|
||||
arrowDrawable.setBounds(0, 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
||||
arrow.setSpan(new ImageSpan(arrowDrawable, DynamicDrawableSpan.ALIGN_CENTER), 0, arrow.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
SpannableStringBuilder link = new SpannableStringBuilder();
|
||||
link
|
||||
.append(LocaleController.getString("EventLogFilterGroupInfo", R.string.EventLogFilterGroupInfo))
|
||||
.append(" ")
|
||||
.append(arrow)
|
||||
.append(" ")
|
||||
.append(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators));
|
||||
link.setSpan(new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View view) {
|
||||
finishFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
ds.setUnderlineText(false);
|
||||
}
|
||||
}, 0, link.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
CharSequence text = LocaleController.getString("ChannelAntiSpamInfo2", R.string.ChannelAntiSpamInfo2);
|
||||
text = AndroidUtilities.replaceCharSequence("%s", text, link);
|
||||
Bulletin bulletin = BulletinFactory.of(this).createSimpleBulletin(R.raw.msg_antispam, LocaleController.getString("ChannelAntiSpamUser", R.string.ChannelAntiSpamUser), text);
|
||||
bulletin.setDuration(Bulletin.DURATION_PROLONG);
|
||||
bulletin.show();
|
||||
return true;
|
||||
}
|
||||
items.add(LocaleController.getString("ReportFalsePositive", R.string.ReportFalsePositive));
|
||||
icons.add(R.drawable.msg_notspam);
|
||||
options.add(OPTION_REPORT_FALSE_POSITIVE);
|
||||
items.add(null);
|
||||
icons.add(null);
|
||||
options.add(null);
|
||||
}
|
||||
|
||||
if (selectedObject.type == MessageObject.TYPE_TEXT || selectedObject.caption != null) {
|
||||
items.add(LocaleController.getString("Copy", R.string.Copy));
|
||||
options.add(3);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
options.add(OPTION_COPY);
|
||||
}
|
||||
if (type == 1) {
|
||||
if (selectedObject.currentEvent != null && selectedObject.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionChangeStickerSet) {
|
||||
|
|
@ -1162,60 +1258,79 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
} else if (type == 3) {
|
||||
if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
|
||||
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
|
||||
options.add(11);
|
||||
icons.add(R.drawable.msg_gif);
|
||||
options.add(OPTION_SAVE_TO_GIFS);
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (selectedObject.isVideo()) {
|
||||
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
|
||||
options.add(4);
|
||||
icons.add(R.drawable.msg_gallery);
|
||||
options.add(OPTION_SAVE_TO_GALLERY);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else if (selectedObject.isMusic()) {
|
||||
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
|
||||
options.add(10);
|
||||
icons.add(R.drawable.msg_download);
|
||||
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else if (selectedObject.getDocument() != null) {
|
||||
if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
|
||||
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
|
||||
options.add(11);
|
||||
icons.add(R.drawable.msg_gif);
|
||||
options.add(OPTION_SAVE_TO_GIFS);
|
||||
}
|
||||
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
|
||||
options.add(10);
|
||||
icons.add(R.drawable.msg_download);
|
||||
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else {
|
||||
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
|
||||
options.add(4);
|
||||
icons.add(R.drawable.msg_gallery);
|
||||
options.add(OPTION_SAVE_TO_GALLERY);
|
||||
}
|
||||
} else if (type == 5) {
|
||||
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
|
||||
options.add(5);
|
||||
icons.add(R.drawable.msg_language);
|
||||
options.add(OPTION_APPLY_FILE);
|
||||
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
|
||||
options.add(10);
|
||||
icons.add(R.drawable.msg_download);
|
||||
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else if (type == 10) {
|
||||
items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
|
||||
options.add(5);
|
||||
icons.add(R.drawable.msg_theme);
|
||||
options.add(OPTION_APPLY_FILE);
|
||||
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
|
||||
options.add(10);
|
||||
icons.add(R.drawable.msg_download);
|
||||
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else if (type == 6) {
|
||||
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
|
||||
options.add(7);
|
||||
icons.add(R.drawable.msg_gallery);
|
||||
options.add(OPTION_SAVE_TO_GALLERY2);
|
||||
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
|
||||
options.add(10);
|
||||
icons.add(R.drawable.msg_download);
|
||||
options.add(OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC);
|
||||
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
|
||||
options.add(6);
|
||||
icons.add(R.drawable.msg_share);
|
||||
options.add(OPTION_SHARE);
|
||||
} else if (type == 7) {
|
||||
if (selectedObject.isMask()) {
|
||||
items.add(LocaleController.getString("AddToMasks", R.string.AddToMasks));
|
||||
} else {
|
||||
items.add(LocaleController.getString("AddToStickers", R.string.AddToStickers));
|
||||
}
|
||||
options.add(9);
|
||||
icons.add(R.drawable.msg_sticker);
|
||||
options.add(OPTION_SAVE_STICKER);
|
||||
} else if (type == 8) {
|
||||
long uid = selectedObject.messageOwner.media.user_id;
|
||||
TLRPC.User user = null;
|
||||
|
|
@ -1224,29 +1339,156 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
if (user != null && user.id != UserConfig.getInstance(currentAccount).getClientUserId() && ContactsController.getInstance(currentAccount).contactsDict.get(user.id) == null) {
|
||||
items.add(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
|
||||
options.add(15);
|
||||
icons.add(R.drawable.msg_addcontact);
|
||||
options.add(OPTION_ADD_CONTACT);
|
||||
}
|
||||
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
|
||||
items.add(LocaleController.getString("Copy", R.string.Copy));
|
||||
options.add(16);
|
||||
icons.add(R.drawable.msg_copy);
|
||||
options.add(OPTION_COPY_PHONE);
|
||||
items.add(LocaleController.getString("Call", R.string.Call));
|
||||
options.add(17);
|
||||
icons.add(R.drawable.msg_calls);
|
||||
options.add(OPTION_CALL);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final CharSequence[] finalItems = items.toArray(new CharSequence[0]);
|
||||
builder.setItems(finalItems, (dialogInterface, i) -> {
|
||||
if (selectedObject == null || i < 0 || i >= options.size()) {
|
||||
boolean callbackSent = false;
|
||||
|
||||
Runnable proceed = () -> {
|
||||
if (options.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
processSelectedOption(options.get(i));
|
||||
});
|
||||
|
||||
builder.setTitle(LocaleController.getString("Message", R.string.Message));
|
||||
showDialog(builder.create());
|
||||
ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity(), R.drawable.popup_fixed_alert, getResourceProvider(), 0);
|
||||
popupLayout.setMinimumWidth(AndroidUtilities.dp(200));
|
||||
Rect backgroundPaddings = new Rect();
|
||||
Drawable shadowDrawable = getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
|
||||
shadowDrawable.getPadding(backgroundPaddings);
|
||||
popupLayout.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
|
||||
|
||||
for (int a = 0, N = items.size(); a < N; ++a) {
|
||||
if (options.get(a) == null) {
|
||||
popupLayout.addView(new ActionBarPopupWindow.GapView(getContext(), getResourceProvider()), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
|
||||
} else {
|
||||
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1, getResourceProvider());
|
||||
cell.setMinimumWidth(AndroidUtilities.dp(200));
|
||||
cell.setTextAndIcon(items.get(a), icons.get(a));
|
||||
final Integer option = options.get(a);
|
||||
popupLayout.addView(cell);
|
||||
final int i = a;
|
||||
cell.setOnClickListener(v1 -> {
|
||||
if (selectedObject == null || i >= options.size()) {
|
||||
return;
|
||||
}
|
||||
processSelectedOption(option);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ChatScrimPopupContainerLayout scrimPopupContainerLayout = new ChatScrimPopupContainerLayout(contentView.getContext()) {
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
|
||||
closeMenu();
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
boolean b = super.dispatchTouchEvent(ev);
|
||||
if (ev.getAction() == MotionEvent.ACTION_DOWN && !b) {
|
||||
closeMenu();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
};
|
||||
scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinearRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT, 0, 0, 0, 0));
|
||||
scrimPopupContainerLayout.setPopupWindowLayout(popupLayout);
|
||||
|
||||
scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (scrimPopupWindow != this) {
|
||||
return;
|
||||
}
|
||||
Bulletin.hideVisible();
|
||||
scrimPopupWindow = null;
|
||||
}
|
||||
};
|
||||
scrimPopupWindow.setPauseNotifications(true);
|
||||
scrimPopupWindow.setDismissAnimationDuration(220);
|
||||
scrimPopupWindow.setOutsideTouchable(true);
|
||||
scrimPopupWindow.setClippingEnabled(true);
|
||||
scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
|
||||
scrimPopupWindow.setFocusable(true);
|
||||
scrimPopupContainerLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
|
||||
scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
|
||||
scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
|
||||
popupLayout.setFitItems(true);
|
||||
|
||||
int popupX = v.getLeft() + (int) x - scrimPopupContainerLayout.getMeasuredWidth() + backgroundPaddings.left - AndroidUtilities.dp(28);
|
||||
if (popupX < AndroidUtilities.dp(6)) {
|
||||
popupX = AndroidUtilities.dp(6);
|
||||
} else if (popupX > chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth()) {
|
||||
popupX = chatListView.getMeasuredWidth() - AndroidUtilities.dp(6) - scrimPopupContainerLayout.getMeasuredWidth();
|
||||
}
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
int[] location = new int[2];
|
||||
fragmentView.getLocationInWindow(location);
|
||||
popupX += location[0];
|
||||
}
|
||||
int totalHeight = contentView.getHeight();
|
||||
int height = scrimPopupContainerLayout.getMeasuredHeight() + AndroidUtilities.dp(48);
|
||||
int keyboardHeight = contentView.measureKeyboardHeight();
|
||||
if (keyboardHeight > AndroidUtilities.dp(20)) {
|
||||
totalHeight += keyboardHeight;
|
||||
}
|
||||
int popupY;
|
||||
if (height < totalHeight) {
|
||||
popupY = (int) (chatListView.getY() + v.getTop() + y);
|
||||
if (height - backgroundPaddings.top - backgroundPaddings.bottom > AndroidUtilities.dp(240)) {
|
||||
popupY += AndroidUtilities.dp(240) - height;
|
||||
}
|
||||
if (popupY < chatListView.getY() + AndroidUtilities.dp(24)) {
|
||||
popupY = (int) (chatListView.getY() + AndroidUtilities.dp(24));
|
||||
} else if (popupY > totalHeight - height - AndroidUtilities.dp(8)) {
|
||||
popupY = totalHeight - height - AndroidUtilities.dp(8);
|
||||
}
|
||||
} else {
|
||||
popupY = inBubbleMode ? 0 : AndroidUtilities.statusBarHeight;
|
||||
}
|
||||
final int finalPopupX = scrimPopupX = popupX;
|
||||
final int finalPopupY = scrimPopupY = popupY;
|
||||
scrimPopupContainerLayout.setMaxHeight(totalHeight - popupY);
|
||||
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
|
||||
scrimPopupWindow.dimBehind();
|
||||
};
|
||||
|
||||
if (
|
||||
ChatObject.canBlockUsers(currentChat) &&
|
||||
message.currentEvent != null && message.currentEvent.action instanceof TLRPC.TL_channelAdminLogEventActionDeleteMessage && message.currentEvent.user_id == getMessagesController().telegramAntispamUserId &&
|
||||
message.messageOwner != null && message.messageOwner.from_id != null && !UserObject.isUserSelf(getMessagesController().getUser(message.messageOwner.from_id.user_id))
|
||||
) {
|
||||
TLRPC.User user = getMessagesController().getUser(selectedObject.messageOwner.from_id.user_id);
|
||||
if (user != null) {
|
||||
callbackSent = true;
|
||||
getMessagesController().checkIsInChat(true, currentChat, user, (isInChat, rights, rank) -> {
|
||||
if (isInChat) {
|
||||
items.add(LocaleController.getString("BanUser", R.string.BanUser));
|
||||
icons.add(R.drawable.msg_block2);
|
||||
options.add(OPTION_RESTRICT);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(proceed);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!callbackSent) {
|
||||
proceed.run();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1366,15 +1608,17 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
|
||||
private void processSelectedOption(int option) {
|
||||
closeMenu();
|
||||
if (selectedObject == null) {
|
||||
return;
|
||||
}
|
||||
switch (option) {
|
||||
case 3: {
|
||||
case OPTION_COPY: {
|
||||
AndroidUtilities.addToClipboard(getMessageContent(selectedObject, 0, true));
|
||||
BulletinFactory.of(ChannelAdminLogActivity.this).createCopyBulletin(LocaleController.getString("MessageCopied", R.string.MessageCopied)).show();
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case OPTION_SAVE_TO_GALLERY: {
|
||||
String path = selectedObject.messageOwner.attachPath;
|
||||
if (path != null && path.length() > 0) {
|
||||
File temp = new File(path);
|
||||
|
|
@ -1395,7 +1639,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
case OPTION_APPLY_FILE: {
|
||||
File locFile = null;
|
||||
if (selectedObject.messageOwner.attachPath != null && selectedObject.messageOwner.attachPath.length() != 0) {
|
||||
File f = new File(selectedObject.messageOwner.attachPath);
|
||||
|
|
@ -1458,7 +1702,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case OPTION_SHARE: {
|
||||
String path = selectedObject.messageOwner.attachPath;
|
||||
if (path != null && path.length() > 0) {
|
||||
File temp = new File(path);
|
||||
|
|
@ -1488,7 +1732,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
case OPTION_SAVE_TO_GALLERY2: {
|
||||
String path = selectedObject.messageOwner.attachPath;
|
||||
if (path != null && path.length() > 0) {
|
||||
File temp = new File(path);
|
||||
|
|
@ -1507,11 +1751,11 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
MediaController.saveFile(path, getParentActivity(), 0, null, null);
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
case OPTION_SAVE_STICKER: {
|
||||
showDialog(new StickersAlert(getParentActivity(), this, selectedObject.getInputStickerSet(), null, null));
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
case OPTION_SAVE_TO_DOWNLOADS_OR_MUSIC: {
|
||||
if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && getParentActivity().checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
getParentActivity().requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
|
||||
selectedObject = null;
|
||||
|
|
@ -1534,12 +1778,12 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
MediaController.saveFile(path, getParentActivity(), selectedObject.isMusic() ? 3 : 2, fileName, selectedObject.getDocument() != null ? selectedObject.getDocument().mime_type : "");
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
case OPTION_SAVE_TO_GIFS: {
|
||||
TLRPC.Document document = selectedObject.getDocument();
|
||||
MessagesController.getInstance(currentAccount).saveGif(selectedObject, document);
|
||||
break;
|
||||
}
|
||||
case 15: {
|
||||
case OPTION_ADD_CONTACT: {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("user_id", selectedObject.messageOwner.media.user_id);
|
||||
args.putString("phone", selectedObject.messageOwner.media.phone_number);
|
||||
|
|
@ -1547,11 +1791,12 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
presentFragment(new ContactAddActivity(args));
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
case OPTION_COPY_PHONE: {
|
||||
AndroidUtilities.addToClipboard(selectedObject.messageOwner.media.phone_number);
|
||||
BulletinFactory.of(ChannelAdminLogActivity.this).createCopyBulletin(LocaleController.getString("PhoneCopied", R.string.PhoneCopied)).show();
|
||||
break;
|
||||
}
|
||||
case 17: {
|
||||
case OPTION_CALL: {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + selectedObject.messageOwner.media.phone_number));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
|
@ -1561,6 +1806,33 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
break;
|
||||
}
|
||||
case OPTION_REPORT_FALSE_POSITIVE: {
|
||||
TLRPC.TL_channels_reportAntiSpamFalsePositive req = new TLRPC.TL_channels_reportAntiSpamFalsePositive();
|
||||
req.channel = getMessagesController().getInputChannel(currentChat.id);
|
||||
req.msg_id = selectedObject.getRealId();
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (res instanceof TLRPC.TL_boolTrue) {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.msg_antispam, LocaleController.getString("ChannelAntiSpamFalsePositiveReported", R.string.ChannelAntiSpamFalsePositiveReported)).show();
|
||||
} else if (res instanceof TLRPC.TL_boolFalse) {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.error, LocaleController.getString("UnknownError", R.string.UnknownError)).show();
|
||||
} else {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.error, LocaleController.getString("UnknownError", R.string.UnknownError)).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
case OPTION_RESTRICT: {
|
||||
getMessagesController().deleteParticipantFromChat(currentChat.id, getMessagesController().getInputPeer(selectedObject.messageOwner.from_id));
|
||||
if (currentChat != null && selectedObject.messageOwner.from_id instanceof TLRPC.TL_peerUser && BulletinFactory.canShowBulletin(this)) {
|
||||
TLRPC.User user = getMessagesController().getUser(selectedObject.messageOwner.from_id.user_id);
|
||||
if (user != null) {
|
||||
BulletinFactory.createRemoveFromChatBulletin(this, user, currentChat.title).show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
selectedObject = null;
|
||||
}
|
||||
|
|
@ -1640,6 +1912,16 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
getMessagesController().putUsers(res.users, false);
|
||||
getMessagesController().putChats(res.chats, false);
|
||||
admins = res.participants;
|
||||
if (currentChat != null) {
|
||||
TLRPC.ChatFull chatFull = getMessagesController().getChatFull(currentChat.id);
|
||||
if (chatFull != null && chatFull.antispam) {
|
||||
TLRPC.ChannelParticipant antispamParticipant = new TLRPC.ChannelParticipant() {};
|
||||
antispamParticipant.user_id = getMessagesController().telegramAntispamUserId;
|
||||
antispamParticipant.peer = getMessagesController().getPeer(antispamParticipant.user_id);
|
||||
loadAntispamUser(getMessagesController().telegramAntispamUserId);
|
||||
admins.add(0, antispamParticipant);
|
||||
}
|
||||
}
|
||||
if (visibleDialog instanceof AdminLogFilterAlert) {
|
||||
((AdminLogFilterAlert) visibleDialog).setCurrentAdmins(admins);
|
||||
}
|
||||
|
|
@ -1648,6 +1930,28 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid);
|
||||
}
|
||||
|
||||
private void loadAntispamUser(long userId) {
|
||||
if (getMessagesController().getUser(userId) != null) {
|
||||
return;
|
||||
}
|
||||
TLRPC.TL_users_getUsers req = new TLRPC.TL_users_getUsers();
|
||||
TLRPC.TL_inputUser inputUser = new TLRPC.TL_inputUser();
|
||||
inputUser.user_id = userId;
|
||||
req.id.add(inputUser);
|
||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> {
|
||||
if (res instanceof TLRPC.Vector) {
|
||||
ArrayList<Object> objects = ((TLRPC.Vector) res).objects;
|
||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
for (int i = 0; i < objects.size(); ++i) {
|
||||
if (objects.get(i) instanceof TLRPC.User) {
|
||||
users.add((TLRPC.User) objects.get(i));
|
||||
}
|
||||
}
|
||||
getMessagesController().putUsers(users, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveFromParent() {
|
||||
MediaController.getInstance().setTextureView(videoTextureView, null, null, false);
|
||||
|
|
@ -1741,7 +2045,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
|
|||
}
|
||||
}
|
||||
|
||||
private void updateMessagesVisisblePart() {
|
||||
private void updateMessagesVisiblePart() {
|
||||
if (chatListView == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
|
|||
createAfterUpload = true;
|
||||
return;
|
||||
}
|
||||
doneRequestId = MessagesController.getInstance(currentAccount).createChat(nameTextView.getText().toString(), new ArrayList<>(), descriptionTextView.getText().toString(), ChatObject.CHAT_TYPE_CHANNEL, false, null, null, ChannelCreateActivity.this);
|
||||
doneRequestId = MessagesController.getInstance(currentAccount).createChat(nameTextView.getText().toString(), new ArrayList<>(), descriptionTextView.getText().toString(), ChatObject.CHAT_TYPE_CHANNEL, false, null, null, 0, ChannelCreateActivity.this);
|
||||
} else if (currentStep == 1) {
|
||||
if (!isPrivate) {
|
||||
if (descriptionTextView.length() == 0) {
|
||||
|
|
|
|||
|
|
@ -323,6 +323,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
public boolean shareAlertDebugTopicsSlowMotion;
|
||||
|
||||
public boolean justCreatedTopic = false;
|
||||
public boolean justCreatedChat = false;
|
||||
protected TLRPC.Chat currentChat;
|
||||
protected TLRPC.User currentUser;
|
||||
protected TLRPC.EncryptedChat currentEncryptedChat;
|
||||
|
|
@ -394,6 +395,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private FrameLayout mentiondownButton;
|
||||
private SimpleTextView mentiondownButtonCounter;
|
||||
private ImageView mentiondownButtonImage;
|
||||
private Bulletin messageSeenPrivacyBulletin;
|
||||
|
||||
private int reactionsMentionCount;
|
||||
private FrameLayout reactionsMentiondownButton;
|
||||
|
|
@ -1501,6 +1503,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
int migrated_to = arguments.getInt("migrated_to", 0);
|
||||
scrollToTopOnResume = arguments.getBoolean("scrollToTopOnResume", false);
|
||||
needRemovePreviousSameChatActivity = arguments.getBoolean("need_remove_previous_same_chat_activity", true);
|
||||
justCreatedChat = arguments.getBoolean("just_created_chat", false);
|
||||
|
||||
if (chatId != 0) {
|
||||
currentChat = getMessagesController().getChat(chatId);
|
||||
|
|
@ -1705,7 +1708,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
getNotificationCenter().addObserver(this, NotificationCenter.chatAvailableReactionsUpdated);
|
||||
getNotificationCenter().addObserver(this, NotificationCenter.dialogsUnreadReactionsCounterChanged);
|
||||
getNotificationCenter().addObserver(this, NotificationCenter.groupStickersDidLoad);
|
||||
getNotificationCenter().addObserver(this, NotificationCenter.chatSwithcedToForum);
|
||||
|
||||
super.onFragmentCreate();
|
||||
|
||||
|
|
@ -1824,7 +1826,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
if (AndroidUtilities.isTablet() && !isComments) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, false);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, getTopicId(), false);
|
||||
}
|
||||
|
||||
if (currentUser != null && !UserObject.isReplyUser(currentUser)) {
|
||||
|
|
@ -1867,6 +1869,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}, timeout * 1000L);
|
||||
}
|
||||
|
||||
if (isTopic) {
|
||||
getMessagesController().getTopicsController().getTopicRepliesCount(dialog_id, getTopicId());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2030,14 +2036,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
getNotificationCenter().removeObserver(this, NotificationCenter.didLoadSendAsPeers);
|
||||
getNotificationCenter().removeObserver(this, NotificationCenter.dialogsUnreadReactionsCounterChanged);
|
||||
getNotificationCenter().removeObserver(this, NotificationCenter.groupStickersDidLoad);
|
||||
getNotificationCenter().removeObserver(this, NotificationCenter.chatSwithcedToForum);
|
||||
if (currentEncryptedChat != null) {
|
||||
getNotificationCenter().removeObserver(this, NotificationCenter.didVerifyMessagesStickers);
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.needSetDayNightTheme);
|
||||
|
||||
if (chatMode == 0 && AndroidUtilities.isTablet()) {
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
|
||||
getNotificationCenter().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, getTopicId(), true);
|
||||
}
|
||||
if (currentUser != null) {
|
||||
MediaController.getInstance().stopMediaObserver();
|
||||
|
|
@ -2622,7 +2627,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
attachItem.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
if (threadMessageId == 0 && !UserObject.isReplyUser(currentUser) || threadMessageObject != null && threadMessageObject.getRepliesCount() == 0) {
|
||||
if (threadMessageId == 0 && !UserObject.isReplyUser(currentUser) || threadMessageObject != null && threadMessageObject.getRepliesCount() < 10) {
|
||||
searchItem.setVisibility(View.GONE);
|
||||
}
|
||||
searchItemVisible = false;
|
||||
|
|
@ -2695,7 +2700,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
});
|
||||
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
|
||||
if (threadMessageId == 0 && !UserObject.isReplyUser(currentUser) || threadMessageObject != null && threadMessageObject.getRepliesCount() == 0) {
|
||||
if (threadMessageId == 0 && !UserObject.isReplyUser(currentUser) || threadMessageObject != null && threadMessageObject.getRepliesCount() < 10) {
|
||||
searchItem.setVisibility(View.GONE);
|
||||
}
|
||||
searchItemVisible = false;
|
||||
|
|
@ -4636,7 +4641,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (chatMode != 0 || threadMessageObjects != null && threadMessageObjects.contains(message) ||
|
||||
getMessageType(message) == 1 && (message.getDialogId() == mergeDialogId || message.needDrawBluredPreview()) ||
|
||||
currentEncryptedChat == null && message.getId() < 0 ||
|
||||
bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && message != null && (MessageObject.getTopicId(message.messageOwner) != 0 || message.wasJustSent)) ||
|
||||
bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && message != null && (MessageObject.getTopicId(message.messageOwner, ChatObject.isForum(currentChat)) != 0 || message.wasJustSent)) ||
|
||||
currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat)) ||
|
||||
textSelectionHelper.isSelectionMode()) {
|
||||
slidingView.setSlidingOffset(0);
|
||||
|
|
@ -4875,7 +4880,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private boolean isSkeletonVisible() {
|
||||
if (justCreatedTopic || currentUser != null || !SharedConfig.animationsEnabled()) {
|
||||
if (justCreatedTopic || justCreatedChat || currentUser != null || !SharedConfig.animationsEnabled()) {
|
||||
return false;
|
||||
}
|
||||
int childHeight = 0;
|
||||
|
|
@ -5035,6 +5040,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
int wasOutlineAlpha = skeletonOutlinePaint.getAlpha();
|
||||
skeletonServicePaint.setAlpha((int) (0xFF * topSkeletonAlpha));
|
||||
skeletonPaint.setAlpha((int) (topSkeletonAlpha * alpha));
|
||||
skeletonOutlinePaint.setAlpha((int) (wasOutlineAlpha * alpha));
|
||||
while (lastTop > blurredViewTopOffset) {
|
||||
lastTop -= AndroidUtilities.dp(3f);
|
||||
|
||||
|
|
@ -5109,6 +5115,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
skeletonColor0 = color0;
|
||||
skeletonColor1 = color1;
|
||||
skeletonGradient = new LinearGradient(0, 0, skeletonGradientWidth = AndroidUtilities.dp(200), 0, new int[]{color1, color0, color0, color1}, new float[]{0.0f, 0.4f, 0.6f, 1f}, Shader.TileMode.CLAMP);
|
||||
skeletonTotalTranslation = -skeletonGradientWidth * 2;
|
||||
skeletonPaint.setShader(skeletonGradient);
|
||||
|
||||
int outlineColor = Color.argb(dark ? 0x2B : 0x60, 0xFF, 0xFF, 0xFF);
|
||||
|
|
@ -6000,7 +6007,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
boolean computingScroll;
|
||||
|
||||
@Override
|
||||
public int getStarForFixGap() {
|
||||
public int getStartForFixGap() {
|
||||
int padding = (int) chatListViewPaddingTop;
|
||||
if (isThreadChat() && (!isTopic || topicStarterMessageObject != null) && pinnedMessageView != null && pinnedMessageView.getVisibility() == View.VISIBLE) {
|
||||
padding -= Math.max(0, AndroidUtilities.dp(48) + pinnedMessageEnterOffset);
|
||||
|
|
@ -7769,7 +7776,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
if (ChatObject.isForum(currentChat) && !isTopic && replyingMessageObject != null) {
|
||||
int topicId = replyingMessageObject.replyToForumTopic != null ? replyingMessageObject.replyToForumTopic.id : MessageObject.getTopicId(replyingMessageObject.messageOwner);
|
||||
int topicId = replyingMessageObject.replyToForumTopic != null ? replyingMessageObject.replyToForumTopic.id : MessageObject.getTopicId(replyingMessageObject.messageOwner, true);
|
||||
if (topicId != 0) {
|
||||
getMediaDataController().cleanDraft(dialog_id, topicId, false);
|
||||
}
|
||||
|
|
@ -8296,7 +8303,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
replyCloseImageView.setOnClickListener(v -> {
|
||||
if (forwardingMessages == null || forwardingMessages.messages.isEmpty()) {
|
||||
if (ChatObject.isForum(currentChat) && !isTopic && replyingMessageObject != null) {
|
||||
int topicId = MessageObject.getTopicId(replyingMessageObject.messageOwner);
|
||||
int topicId = MessageObject.getTopicId(replyingMessageObject.messageOwner, true);
|
||||
if (topicId != 0) {
|
||||
getMediaDataController().cleanDraft(dialog_id, topicId, false);
|
||||
}
|
||||
|
|
@ -10345,7 +10352,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
|
||||
@Override
|
||||
public void onDismissAnimationStart() {
|
||||
chatAttachAlert.setFocusable(false);
|
||||
if (chatAttachAlert != null) {
|
||||
chatAttachAlert.setFocusable(false);
|
||||
}
|
||||
chatActivityEnterView.getEditField().requestFocus();
|
||||
if (chatAttachAlert != null && chatAttachAlert.isShowing()) {
|
||||
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
||||
|
|
@ -10714,6 +10723,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean checkSlowModeAlert() {
|
||||
CharSequence time = chatActivityEnterView.getSlowModeTimer();
|
||||
if (time != null) {
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(LocaleController.getString("Slowmode", R.string.Slowmode))
|
||||
.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("SlowModeHint", R.string.SlowModeHint, time)))
|
||||
.setPositiveButton(LocaleController.getString("OK", R.string.OK), null)
|
||||
.show();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void hideHints(boolean scroll) {
|
||||
if (!scroll) {
|
||||
if (slowModeHint != null) {
|
||||
|
|
@ -11531,8 +11553,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
public void openPollCreate(Boolean quiz) {
|
||||
PollCreateActivity pollCreateActivity = new PollCreateActivity(ChatActivity.this, quiz);
|
||||
pollCreateActivity.setDelegate((poll, params, notify, scheduleDate) -> {
|
||||
getSendMessagesHelper().sendMessage(poll, dialog_id, replyingMessageObject, getThreadMessage(), null, params, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
if (checkSlowModeAlert()) {
|
||||
getSendMessagesHelper().sendMessage(poll, dialog_id, replyingMessageObject, getThreadMessage(), null, params, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
});
|
||||
presentFragment(pollCreateActivity);
|
||||
}
|
||||
|
|
@ -11540,13 +11564,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
@Override
|
||||
public void didSelectFiles(ArrayList<String> files, String caption, ArrayList<MessageObject> fmessages, boolean notify, int scheduleDate) {
|
||||
fillEditingMediaWithCaption(caption, null);
|
||||
if (!fmessages.isEmpty() && !TextUtils.isEmpty(caption)) {
|
||||
SendMessagesHelper.getInstance(currentAccount).sendMessage(caption, dialog_id, null, null, null, true, null, null, null, true, 0, null, false);
|
||||
caption = null;
|
||||
if (checkSlowModeAlert()) {
|
||||
if (!fmessages.isEmpty() && !TextUtils.isEmpty(caption)) {
|
||||
SendMessagesHelper.getInstance(currentAccount).sendMessage(caption, dialog_id, null, null, null, true, null, null, null, true, 0, null, false);
|
||||
caption = null;
|
||||
}
|
||||
getSendMessagesHelper().sendMessage(fmessages, dialog_id, false, false, true, 0);
|
||||
SendMessagesHelper.prepareSendingDocuments(getAccountInstance(), files, files, null, caption, null, dialog_id, replyingMessageObject, getThreadMessage(), null, editingMessageObject, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
getSendMessagesHelper().sendMessage(fmessages, dialog_id, false, false,true, 0);
|
||||
SendMessagesHelper.prepareSendingDocuments(getAccountInstance(), files, files, null, caption, null, dialog_id, replyingMessageObject, getThreadMessage(), null, editingMessageObject, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -11567,6 +11593,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (photos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!checkSlowModeAlert()) {
|
||||
return;
|
||||
}
|
||||
boolean hasNoGifs = false;
|
||||
for (int a = 0; a < photos.size(); a++) {
|
||||
SendMessagesHelper.SendingMediaInfo info = photos.get(a);
|
||||
|
|
@ -11778,6 +11807,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (arrayList == null || arrayList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!checkSlowModeAlert()) {
|
||||
return;
|
||||
}
|
||||
if ((scheduleDate != 0) == (chatMode == MODE_SCHEDULED)) {
|
||||
waitingForSendingMessageLoad = true;
|
||||
}
|
||||
|
|
@ -14241,7 +14273,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private void updateTopicTitleIcon() {
|
||||
if (forumTopic != null && avatarContainer != null) {
|
||||
avatarContainer.getAvatarImageView().setVisibility(View.VISIBLE);
|
||||
ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true);
|
||||
ForumUtilities.setTopicIcon(avatarContainer.getAvatarImageView(), forumTopic, true, themeDelegate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16630,7 +16662,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (forwardEndReached[0]) {
|
||||
forwardEndReached[0] = false;
|
||||
hideForwardEndReached = false;
|
||||
chatAdapter.notifyItemInserted(0);
|
||||
if (chatAdapter != null) {
|
||||
chatAdapter.notifyItemInserted(0);
|
||||
}
|
||||
}
|
||||
getMessagesController().addToViewsQueue(threadMessageObject);
|
||||
} else {
|
||||
|
|
@ -17167,7 +17201,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (object == null && replaceObjects != null) {
|
||||
object = replaceObjects.get(mid);
|
||||
}
|
||||
if (object != null && (!isTopic || getTopicId() == MessageObject.getTopicId(object.messageOwner))) {
|
||||
if (object != null && (!isTopic || getTopicId() == MessageObject.getTopicId(object.messageOwner, ChatObject.isForum(currentChat)))) {
|
||||
pinnedMessageIds.add(mid);
|
||||
pinnedMessageObjects.put(mid, object);
|
||||
if (replaceObjects == null) {
|
||||
|
|
@ -17562,7 +17596,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
i--;
|
||||
continue;
|
||||
}
|
||||
int messageTopicId = MessageObject.getTopicId(pinnedMessageObjects.get(messageId).messageOwner);
|
||||
int messageTopicId = MessageObject.getTopicId(pinnedMessageObjects.get(messageId).messageOwner, true);
|
||||
if (getTopicId() != messageTopicId) {
|
||||
pinnedMessageObjects.remove(messageId);
|
||||
pinnedMessageIds.remove(i);
|
||||
|
|
@ -17809,24 +17843,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else if (id == NotificationCenter.topicsDidLoaded) {
|
||||
if (isTopic) {
|
||||
updateTopicTitleIcon();
|
||||
updateTopicHeader();
|
||||
updateBottomOverlay();
|
||||
updateTopPanel(true);
|
||||
if (avatarContainer != null) {
|
||||
avatarContainer.updateSubtitle();
|
||||
}
|
||||
}
|
||||
} else if (id == NotificationCenter.chatSwithcedToForum) {
|
||||
// long chatId = (long) args[0];
|
||||
// if (-dialog_id == chatId) {
|
||||
// if (chatMode == 0 && getMessagesController().getChat(-dialog_id).forum) {
|
||||
// if (getParentLayout() != null) {
|
||||
// if (getParentLayout().checkTransitionAnimation()) {
|
||||
// AndroidUtilities.runOnUIThread(() -> {
|
||||
// TopicsFragment.prepareToSwitchAnimation(ChatActivity.this);
|
||||
// }, 500);
|
||||
// } else {
|
||||
// TopicsFragment.prepareToSwitchAnimation(ChatActivity.this);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -18633,6 +18656,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (!isAd && placeToPaste < sponsoredMessagesCount && (currentChat == null || ChatObject.isChannelAndNotMegaGroup(currentChat))) {
|
||||
placeToPaste = sponsoredMessagesCount;
|
||||
}
|
||||
if (obj.messageOwner.action instanceof TLRPC.TL_messageActionSetMessagesTTL && messages.size() == 2) {
|
||||
placeToPaste = 1;
|
||||
}
|
||||
if (dayArray == null) {
|
||||
dayArray = new ArrayList<>();
|
||||
messagesByDays.put(obj.dateKey, dayArray);
|
||||
|
|
@ -20065,7 +20091,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private void updateTopicHeader() {
|
||||
avatarContainer.setTitle(forumTopic.title);
|
||||
if (avatarContainer != null && forumTopic != null) {
|
||||
avatarContainer.setTitle(forumTopic.title);
|
||||
}
|
||||
updateTopicTitleIcon();
|
||||
}
|
||||
|
||||
|
|
@ -21033,7 +21061,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
int chatWithAdminDate = preferences.getInt("dialog_bar_chat_with_date" + did, 0);
|
||||
boolean showAddMembersToGroup = preferences.getBoolean("dialog_bar_invite" + did, false);
|
||||
TLRPC.EmojiStatus showEmojiStatusReport = currentUser != null && (showReport || showBlock) && (currentUser.emoji_status instanceof TLRPC.TL_emojiStatus || currentUser.emoji_status instanceof TLRPC.TL_emojiStatusUntil && ((TLRPC.TL_emojiStatusUntil) currentUser.emoji_status).until > (int) (System.currentTimeMillis() / 1000)) ? currentUser.emoji_status : null;
|
||||
boolean showRestartTopic = !isInPreviewMode() && forumTopic != null && forumTopic.closed && ChatObject.canManageTopic(currentAccount, currentChat, forumTopic);
|
||||
boolean showRestartTopic = !isInPreviewMode() && forumTopic != null && forumTopic.closed && !forumTopic.hidden && ChatObject.canManageTopic(currentAccount, currentChat, forumTopic);
|
||||
if (showRestartTopic) {
|
||||
shownRestartTopic = true;
|
||||
}
|
||||
|
|
@ -21630,7 +21658,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (replyMessage.replyToForumTopic != null) {
|
||||
draftThreadId = replyMessage.replyToForumTopic.id;
|
||||
} else {
|
||||
draftThreadId = MessageObject.getTopicId(replyMessage.messageOwner);
|
||||
draftThreadId = MessageObject.getTopicId(replyMessage.messageOwner, ChatObject.isForum(currentChat));
|
||||
}
|
||||
} else {
|
||||
draftThreadId = threadMessageId;
|
||||
|
|
@ -22269,7 +22297,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
message.isSponsored() || type == 1 && message.getDialogId() == mergeDialogId ||
|
||||
message.messageOwner.action instanceof TLRPC.TL_messageActionSecureValuesSent ||
|
||||
currentEncryptedChat == null && message.getId() < 0 ||
|
||||
bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && selectedObject != null && (MessageObject.getTopicId(selectedObject.messageOwner) != 0 || selectedObject.wasJustSent)) ||
|
||||
bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE && !(bottomOverlayChatWaitsReply && selectedObject != null && (MessageObject.getTopicId(selectedObject.messageOwner, ChatObject.isForum(currentChat)) != 0 || selectedObject.wasJustSent)) ||
|
||||
currentChat != null && (ChatObject.isNotInChat(currentChat) && !isThreadChat() || ChatObject.isChannel(currentChat) && !ChatObject.canPost(currentChat) && !currentChat.megagroup || !ChatObject.canSendMessages(currentChat))) {
|
||||
allowChatActions = false;
|
||||
}
|
||||
|
|
@ -22322,28 +22350,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
undoView.showWithAction(dialog_id, action, currentUser, userInfo != null ? userInfo.ttl_period : chatInfo.ttl_period, null, null);
|
||||
}
|
||||
}
|
||||
}, true, getResourceProvider());
|
||||
}, true, 0, getResourceProvider());
|
||||
autoDeletePopupWrapper.updateItems(userInfo != null ? userInfo.ttl_period : chatInfo.ttl_period);
|
||||
optionsView = autoDeletePopupWrapper.windowLayout;
|
||||
} else if (type >= 0 || type == -1 && single && (message.isSending() || message.isEditing()) && currentEncryptedChat == null) {
|
||||
selectedObject = message;
|
||||
selectedObjectGroup = groupedMessages;
|
||||
messageTextToTranslate = getMessageCaption(selectedObject, selectedObjectGroup);
|
||||
if (messageTextToTranslate == null && selectedObject.isPoll()) {
|
||||
try {
|
||||
TLRPC.Poll poll = ((TLRPC.TL_messageMediaPoll) selectedObject.messageOwner.media).poll;
|
||||
StringBuilder pollText = new StringBuilder();
|
||||
pollText = new StringBuilder(poll.question).append("\n");
|
||||
for (TLRPC.TL_pollAnswer answer : poll.answers)
|
||||
pollText.append("\n\uD83D\uDD18 ").append(answer.text);
|
||||
messageTextToTranslate = pollText.toString();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
if (messageTextToTranslate == null) {
|
||||
messageTextToTranslate = getMessageContent(selectedObject, 0, false);
|
||||
}
|
||||
if (messageTextToTranslate != null && Emoji.fullyConsistsOfEmojis(messageTextToTranslate)) {
|
||||
messageTextToTranslate = null; // message fully consists of emojis, do not translate
|
||||
if (selectedObject.type != MessageObject.TYPE_EMOJIS && selectedObject.type != MessageObject.TYPE_ANIMATED_STICKER && selectedObject.type != MessageObject.TYPE_STICKER) {
|
||||
messageTextToTranslate = getMessageCaption(selectedObject, selectedObjectGroup);
|
||||
if (messageTextToTranslate == null && selectedObject.isPoll()) {
|
||||
try {
|
||||
TLRPC.Poll poll = ((TLRPC.TL_messageMediaPoll) selectedObject.messageOwner.media).poll;
|
||||
StringBuilder pollText = new StringBuilder();
|
||||
pollText = new StringBuilder(poll.question).append("\n");
|
||||
for (TLRPC.TL_pollAnswer answer : poll.answers)
|
||||
pollText.append("\n\uD83D\uDD18 ").append(answer.text);
|
||||
messageTextToTranslate = pollText.toString();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
if (messageTextToTranslate == null) {
|
||||
messageTextToTranslate = getMessageContent(selectedObject, 0, false);
|
||||
}
|
||||
if (messageTextToTranslate != null && Emoji.fullyConsistsOfEmojis(messageTextToTranslate)) {
|
||||
messageTextToTranslate = null; // message fully consists of emojis, do not translate
|
||||
}
|
||||
}
|
||||
|
||||
if (message.isSponsored() && !getMessagesController().premiumLocked) {
|
||||
|
|
@ -23111,17 +23142,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
int totalHeight = contentView.getHeightWithKeyboard();
|
||||
int availableHeight = totalHeight - scrimPopupY - AndroidUtilities.dp(46 + 16) - (isReactionsAvailable ? AndroidUtilities.dp(52) : 0);
|
||||
|
||||
// if (SharedConfig.messageSeenHintCount > 0 && contentView.getKeyboardHeight() < AndroidUtilities.dp(20)) {
|
||||
availableHeight -= AndroidUtilities.dp(52);
|
||||
Bulletin bulletin = BulletinFactory.of(Bulletin.BulletinWindow.make(getContext()), themeDelegate).createErrorBulletin(AndroidUtilities.replaceTags(LocaleController.getString("MessageSeenTooltipMessage", R.string.MessageSeenTooltipMessage)));
|
||||
bulletin.setDuration(4000);
|
||||
bulletin.show();
|
||||
if (SharedConfig.messageSeenHintCount > 0 && contentView.getKeyboardHeight() < AndroidUtilities.dp(20)) {
|
||||
messageSeenPrivacyBulletin = BulletinFactory.of(Bulletin.BulletinWindow.make(getContext()), themeDelegate).createErrorBulletin(AndroidUtilities.replaceTags(LocaleController.getString("MessageSeenTooltipMessage", R.string.MessageSeenTooltipMessage)));
|
||||
messageSeenPrivacyBulletin.setDuration(4000);
|
||||
messageSeenPrivacyBulletin.show();
|
||||
SharedConfig.updateMessageSeenHintCount(SharedConfig.messageSeenHintCount - 1);
|
||||
// } else if (contentView.getKeyboardHeight() > AndroidUtilities.dp(20)) {
|
||||
// availableHeight -= contentView.getKeyboardHeight() / 3f;
|
||||
// }
|
||||
}
|
||||
|
||||
listView2.requestLayout();
|
||||
linearLayout.requestLayout();
|
||||
|
|
@ -23175,9 +23202,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
if (addGap) {
|
||||
View gap = new FrameLayout(contentView.getContext());
|
||||
gap.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuSeparator));
|
||||
popupLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
|
||||
popupLayout.addView(new ActionBarPopupWindow.GapView(contentView.getContext(), themeDelegate), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
|
||||
}
|
||||
|
||||
if (popupLayout.getSwipeBack() != null) {
|
||||
|
|
@ -23331,7 +23356,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return true;
|
||||
};
|
||||
TLRPC.InputPeer inputPeer = getMessagesController().getInputPeer(dialog_id);
|
||||
int messageId = selectedObject.messageOwner.id;
|
||||
int messageId = selectedObject == null || selectedObject.messageOwner == null ? 0 : selectedObject.messageOwner.id;
|
||||
if (LanguageDetector.hasSupport()) {
|
||||
final String[] fromLang = {null};
|
||||
cell.setVisibility(View.GONE);
|
||||
|
|
@ -23342,7 +23367,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
fromLang[0] = lang;
|
||||
if (fromLang[0] != null && (!fromLang[0].equals(toLang) || fromLang[0].equals("und")) && (
|
||||
translateButtonEnabled && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(fromLang[0]) ||
|
||||
(currentChat != null && (currentChat.has_link || ChatObject.isPublic(currentChat))) && ("uk".equals(fromLang[0]) || "ru".equals(fromLang[0]))
|
||||
(currentChat != null && (currentChat.has_link || ChatObject.isPublic(currentChat)) || selectedObject.messageOwner.fwd_from != null) && ("uk".equals(fromLang[0]) || "ru".equals(fromLang[0]))
|
||||
)) {
|
||||
cell.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
@ -23573,7 +23598,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (scrimPopupWindow != this) {
|
||||
return;
|
||||
}
|
||||
Bulletin.hideVisible();
|
||||
if (Bulletin.getVisibleBulletin() == messageSeenPrivacyBulletin && messageSeenPrivacyBulletin != null) {
|
||||
messageSeenPrivacyBulletin.hide();
|
||||
messageSeenPrivacyBulletin = null;
|
||||
}
|
||||
scrimPopupWindow = null;
|
||||
menuDeleteItem = null;
|
||||
scrimPopupWindowItems = null;
|
||||
|
|
@ -24183,7 +24211,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
} else {
|
||||
saveMessageToGallery(selectedObject);
|
||||
if (getParentActivity() != null) {
|
||||
BulletinFactory.createSaveToGalleryBulletin(this, selectedObject.isVideo(), themeDelegate).show();
|
||||
BulletinFactory.of(this).createDownloadBulletin(selectedObject.isVideo() ? BulletinFactory.FileType.VIDEO : BulletinFactory.FileType.PHOTO, themeDelegate).show();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -24663,7 +24691,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
break;
|
||||
}
|
||||
case OPTION_VIEW_IN_TOPIC: {
|
||||
int topicId = MessageObject.getTopicId(selectedObject.messageOwner);
|
||||
int topicId = MessageObject.getTopicId(selectedObject.messageOwner, true);
|
||||
if (topicId != 0) {
|
||||
TLRPC.TL_forumTopic topic = getMessagesController().getTopicsController().findTopic(currentChat.id, topicId);
|
||||
if (topic != null) {
|
||||
|
|
@ -25227,19 +25255,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
public void sendAudio(ArrayList<MessageObject> audios, CharSequence caption, boolean notify, int scheduleDate) {
|
||||
fillEditingMediaWithCaption(caption, null);
|
||||
SendMessagesHelper.prepareSendingAudioDocuments(getAccountInstance(), audios, caption != null ? caption : null, dialog_id, replyingMessageObject, getThreadMessage(), editingMessageObject, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
if (checkSlowModeAlert()) {
|
||||
fillEditingMediaWithCaption(caption, null);
|
||||
SendMessagesHelper.prepareSendingAudioDocuments(getAccountInstance(), audios, caption != null ? caption : null, dialog_id, replyingMessageObject, getThreadMessage(), editingMessageObject, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendContact(TLRPC.User user, boolean notify, int scheduleDate) {
|
||||
getSendMessagesHelper().sendMessage(user, dialog_id, replyingMessageObject, getThreadMessage(), null, null, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
if (checkSlowModeAlert()) {
|
||||
getSendMessagesHelper().sendMessage(user, dialog_id, replyingMessageObject, getThreadMessage(), null, null, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPoll(TLRPC.TL_messageMediaPoll poll, HashMap<String, String> params, boolean notify, int scheduleDate) {
|
||||
getSendMessagesHelper().sendMessage(poll, dialog_id, replyingMessageObject, getThreadMessage(), null, params, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
if (checkSlowModeAlert()) {
|
||||
getSendMessagesHelper().sendMessage(poll, dialog_id, replyingMessageObject, getThreadMessage(), null, params, notify, scheduleDate);
|
||||
afterMessageSend();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMedia(MediaController.PhotoEntry photoEntry, VideoEditedInfo videoEditedInfo, boolean notify, int scheduleDate, boolean forceDocument) {
|
||||
|
|
@ -25782,7 +25816,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
username = username.toLowerCase();
|
||||
if (ChatObject.hasPublicLink(currentChat, username) ||
|
||||
currentUser != null && !TextUtils.isEmpty(currentUser.username) && username.equals(currentUser.username.toLowerCase())) {
|
||||
shakeContent();
|
||||
if (avatarContainer != null) {
|
||||
avatarContainer.openProfile(false);
|
||||
} else {
|
||||
shakeContent();
|
||||
}
|
||||
} else if (str.startsWith("@")) {
|
||||
getMessagesController().openByUserName(username, ChatActivity.this, 0);
|
||||
} else {
|
||||
|
|
@ -26447,7 +26485,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
didPressInstantButton(cell, 10);
|
||||
return;
|
||||
}
|
||||
openProfile(user);
|
||||
openProfile(user, ChatObject.isForum(currentChat) || isThreadChat());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -26550,9 +26588,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private void openProfile(TLRPC.User user) {
|
||||
openProfile(user, false);
|
||||
}
|
||||
|
||||
private void openProfile(TLRPC.User user, boolean expandPhoto) {
|
||||
if (user != null && user.id != getUserConfig().getClientUserId()) {
|
||||
if (user.photo == null || user.photo instanceof TLRPC.TL_userProfilePhotoEmpty) {
|
||||
expandPhoto = false;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("user_id", user.id);
|
||||
args.putBoolean("expandPhoto", expandPhoto);
|
||||
ProfileActivity fragment = new ProfileActivity(args);
|
||||
fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id ? 1 : 0);
|
||||
AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
|
||||
|
|
@ -26561,9 +26607,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
private void openProfile(TLRPC.Chat chat) {
|
||||
openProfile(chat, false);
|
||||
}
|
||||
|
||||
private void openProfile(TLRPC.Chat chat, boolean expandPhoto) {
|
||||
if (chat != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("chat_id", chat.id);
|
||||
args.putBoolean("expandPhoto", expandPhoto);
|
||||
presentFragment(new ProfileActivity(args));
|
||||
}
|
||||
}
|
||||
|
|
@ -26875,7 +26926,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean didPressAnimatedEmoji(AnimatedEmojiSpan span) {
|
||||
public boolean didPressAnimatedEmoji(ChatMessageCell cell, AnimatedEmojiSpan span) {
|
||||
if (getMessagesController().premiumLocked || span == null || span.standard) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -26884,29 +26935,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (document == null) {
|
||||
return false;
|
||||
}
|
||||
TLRPC.InputStickerSet inputStickerSet = MessageObject.getInputStickerSet(document);
|
||||
if (inputStickerSet == null) {
|
||||
return false;
|
||||
}
|
||||
TLRPC.TL_messages_stickerSet set = MediaDataController.getInstance(currentAccount).getStickerSet(inputStickerSet, false);
|
||||
if (set == null || set.set == null) {
|
||||
return false;
|
||||
}
|
||||
BulletinFactory.of(ChatActivity.this).createEmojiBulletin(document, AndroidUtilities.replaceTags(LocaleController.formatString("MessageContainsEmojiPackSingle", R.string.MessageContainsEmojiPackSingle, set.set.title)), LocaleController.getString("ViewAction", R.string.ViewAction), () -> {
|
||||
Bulletin bulletin = BulletinFactory.of(ChatActivity.this).createContainsEmojiBulletin(document, false, set -> {
|
||||
ArrayList<TLRPC.InputStickerSet> inputSets = new ArrayList<>(1);
|
||||
inputSets.add(inputStickerSet);
|
||||
inputSets.add(set);
|
||||
EmojiPacksAlert alert = new EmojiPacksAlert(ChatActivity.this, getParentActivity(), themeDelegate, inputSets);
|
||||
alert.setCalcMandatoryInsets(isKeyboardVisible());
|
||||
showDialog(alert);
|
||||
}).show();
|
||||
return true;
|
||||
});
|
||||
if (bulletin != null) {
|
||||
bulletin.show();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didPressTopicButton(ChatMessageCell cell) {
|
||||
MessageObject message = cell.getMessageObject();
|
||||
if (message != null) {
|
||||
int topicId = MessageObject.getTopicId(message.messageOwner);
|
||||
int topicId = MessageObject.getTopicId(message.messageOwner, true);
|
||||
if (topicId != 0) {
|
||||
TLRPC.TL_forumTopic topic = getMessagesController().getTopicsController().findTopic(currentChat.id, topicId);
|
||||
if (topic != null) {
|
||||
|
|
@ -26916,6 +26963,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldShowTopicButton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didPressExtendedMediaPreview(ChatMessageCell cell, TLRPC.KeyboardButton button) {
|
||||
getSendMessagesHelper().sendCallback(true, cell.getMessageObject(), button, ChatActivity.this);
|
||||
|
|
@ -26988,7 +27040,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
return;
|
||||
}
|
||||
if (message.isDice()) {
|
||||
undoView.showWithAction(0, chatActivityEnterView.getVisibility() == View.VISIBLE && bottomOverlay.getVisibility() != View.VISIBLE ? UndoView.ACTION_DICE_INFO : UndoView.ACTION_DICE_NO_SEND_INFO, message.getDiceEmoji(), null, () -> getSendMessagesHelper().sendMessage(message.getDiceEmoji(), dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0, null, false));
|
||||
undoView.showWithAction(0, chatActivityEnterView.getVisibility() == View.VISIBLE && bottomOverlay.getVisibility() != View.VISIBLE ? UndoView.ACTION_DICE_INFO : UndoView.ACTION_DICE_NO_SEND_INFO, message.getDiceEmoji(), null, () -> {
|
||||
if (checkSlowModeAlert()) {
|
||||
getSendMessagesHelper().sendMessage(message.getDiceEmoji(), dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0, null, false);
|
||||
}
|
||||
});
|
||||
} else if (message.isAnimatedEmoji() && (!message.isAnimatedAnimatedEmoji() || emojiAnimationsOverlay.supports(MessageObject.findAnimatedEmojiEmoticon(message.getDocument())) && currentUser != null) || message.isPremiumSticker()) {
|
||||
restartSticker(cell);
|
||||
emojiAnimationsOverlay.onTapItem(cell, ChatActivity.this, true);
|
||||
|
|
@ -28225,18 +28281,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
} else {
|
||||
if (privateMsgUrlPattern == null) {
|
||||
privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)");
|
||||
privateMsgUrlPattern = Pattern.compile("(https://)?t.me/c/([0-9]+)/([0-9]+)/?([0-9]+)?");
|
||||
}
|
||||
|
||||
Matcher matcher = privateMsgUrlPattern.matcher(urlFinal);
|
||||
if (matcher.find(2) && matcher.find(3)) {
|
||||
if (matcher.find(2) && matcher.find(3) && !matcher.find(4)) {
|
||||
long channelId = Long.parseLong(matcher.group(2));
|
||||
int messageId = Integer.parseInt(matcher.group(3));
|
||||
if (channelId == currentChat.id && messageId != 0) {
|
||||
Uri data = Uri.parse(urlFinal);
|
||||
int threadId = Utilities.parseInt(data.getQueryParameter("thread"));
|
||||
int topicId = Utilities.parseInt(data.getQueryParameter("topic"));
|
||||
int commentId = Utilities.parseInt(data.getQueryParameter("comment"));
|
||||
if (threadId != 0 || commentId != 0) {
|
||||
if (threadId != 0 || topicId != 0 || commentId != 0) {
|
||||
return false;
|
||||
} else {
|
||||
showScrollToMessageError = true;
|
||||
|
|
@ -28868,9 +28925,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
themeDescriptions.add(new ThemeDescription(emptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, Theme.key_chat_serviceBackground));
|
||||
themeDescriptions.add(new ThemeDescription(bigEmptyView, ThemeDescription.FLAG_SERVICEBACKGROUND, null, null, null, null, Theme.key_chat_serviceBackground));
|
||||
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_SERVICEBACKGROUND, new Class[]{ChatLoadingCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chat_serviceBackground));
|
||||
themeDescriptions.add(new ThemeDescription(chatListView, ThemeDescription.FLAG_PROGRESSBAR, new Class[]{ChatLoadingCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chat_serviceText));
|
||||
|
||||
if (mentionContainer != null) {
|
||||
themeDescriptions.add(new ThemeDescription(mentionContainer.getListView(), ThemeDescription.FLAG_TEXTCOLOR, new Class[]{BotSwitchCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chat_botSwitchToInlineText));
|
||||
themeDescriptions.add(new ThemeDescription(mentionContainer.getListView(), ThemeDescription.FLAG_TEXTCOLOR, new Class[]{MentionCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ import org.telegram.ui.Cells.TextSettingsCell;
|
|||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.Bulletin;
|
||||
import org.telegram.ui.Components.BulletinFactory;
|
||||
import org.telegram.ui.Components.CombinedDrawable;
|
||||
import org.telegram.ui.Components.CubicBezierInterpolator;
|
||||
|
|
@ -830,7 +829,9 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
|
|||
settingsSectionCell.setBackground(combinedDrawable);
|
||||
linearLayout1.addView(settingsSectionCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
if (forumsCell != null) {
|
||||
settingsSectionCell.setText(LocaleController.getString(R.string.ForumToggleDescription));
|
||||
settingsSectionCell.setText(LocaleController.getString("ForumToggleDescription", R.string.ForumToggleDescription));
|
||||
} else {
|
||||
settingsSectionCell.setText(LocaleController.getString("ChannelSignMessagesInfo", R.string.ChannelSignMessagesInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -490,7 +490,6 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
public void onClick(@NonNull View view) {
|
||||
Browser.openUrl(getContext(), "https://fragment.com/username/" + username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
super.updateDrawState(ds);
|
||||
|
|
@ -507,6 +506,46 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
}
|
||||
super.setText(text);
|
||||
}
|
||||
|
||||
ValueAnimator translateAnimator;
|
||||
int prevHeight = -1;
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (prevHeight != -1 && linearLayout != null) {
|
||||
ArrayList<View> viewsToTranslate = new ArrayList<>();
|
||||
boolean passedMe = false;
|
||||
for (int i = 0; i < linearLayout.getChildCount(); ++i) {
|
||||
View child = linearLayout.getChildAt(i);
|
||||
if (passedMe) {
|
||||
viewsToTranslate.add(child);
|
||||
} else if (child == this) {
|
||||
passedMe = true;
|
||||
}
|
||||
}
|
||||
|
||||
float diff = prevHeight - getHeight();
|
||||
if (translateAnimator != null) {
|
||||
translateAnimator.cancel();
|
||||
}
|
||||
translateAnimator = ValueAnimator.ofFloat(0, 1);
|
||||
translateAnimator.addUpdateListener(anm -> {
|
||||
float t = 1f - (float) anm.getAnimatedValue();
|
||||
for (int i = 0; i < viewsToTranslate.size(); ++i) {
|
||||
View view = viewsToTranslate.get(i);
|
||||
if (view != null) {
|
||||
view.setTranslationY(diff * t);
|
||||
}
|
||||
}
|
||||
});
|
||||
translateAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
translateAnimator.setDuration(350);
|
||||
translateAnimator.start();
|
||||
}
|
||||
prevHeight = getHeight();
|
||||
}
|
||||
};
|
||||
checkTextView.setBackgroundDrawable(Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
|
||||
checkTextView.setBottomPadding(6);
|
||||
|
|
@ -846,7 +885,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
|
|||
|
||||
@Override
|
||||
protected void onMeasure(int widthSpec, int heightSpec) {
|
||||
super.onMeasure(widthSpec, MeasureSpec.makeMeasureSpec(999999999, MeasureSpec.AT_MOST));
|
||||
super.onMeasure(widthSpec, MeasureSpec.makeMeasureSpec(9999999, MeasureSpec.AT_MOST));
|
||||
}
|
||||
|
||||
public class TouchHelperCallback extends ItemTouchHelper.Callback {
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import org.telegram.ui.Cells.LoadingCell;
|
|||
import org.telegram.ui.Cells.ManageChatTextCell;
|
||||
import org.telegram.ui.Cells.ManageChatUserCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextCell;
|
||||
import org.telegram.ui.Cells.TextCheckCell2;
|
||||
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
|
|
@ -124,6 +125,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
private int gigaInfoRow;
|
||||
|
||||
private int recentActionsRow;
|
||||
private boolean antiSpamToggleLoading;
|
||||
private int antiSpamRow;
|
||||
private int antiSpamInfoRow;
|
||||
private int addNewRow;
|
||||
private int addNew2Row;
|
||||
private int removedUsersRow;
|
||||
|
|
@ -233,6 +237,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return;
|
||||
}
|
||||
recentActionsRow = -1;
|
||||
antiSpamRow = -1;
|
||||
antiSpamInfoRow = -1;
|
||||
addNewRow = -1;
|
||||
addNew2Row = -1;
|
||||
addNewSectionRow = -1;
|
||||
|
|
@ -364,7 +370,12 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
} else if (type == TYPE_ADMIN) {
|
||||
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && !currentChat.gigagroup && (info == null || info.participants_count <= 200 || !isChannel && info.can_set_stickers)) {
|
||||
recentActionsRow = rowCount++;
|
||||
addNewSectionRow = rowCount++;
|
||||
if (ChatObject.hasAdminRights(currentChat)) {
|
||||
antiSpamRow = rowCount++;
|
||||
antiSpamInfoRow = rowCount++;
|
||||
} else {
|
||||
addNewSectionRow = rowCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (ChatObject.canAddAdmins(currentChat)) {
|
||||
|
|
@ -839,6 +850,36 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
} else if (position == recentActionsRow) {
|
||||
presentFragment(new ChannelAdminLogActivity(currentChat));
|
||||
return;
|
||||
} else if (position == antiSpamRow) {
|
||||
final TextCell textCell = (TextCell) view;
|
||||
if (info != null && !info.antispam && info.participants_count < getMessagesController().telegramAntispamGroupSizeMin) {
|
||||
BulletinFactory.of(this).createSimpleBulletin(R.raw.msg_antispam, AndroidUtilities.replaceTags(LocaleController.formatPluralString("ChannelAntiSpamForbidden", getMessagesController().telegramAntispamGroupSizeMin))).show();
|
||||
} else if (info != null && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && !antiSpamToggleLoading) {
|
||||
antiSpamToggleLoading = true;
|
||||
boolean wasAntispam = info.antispam;
|
||||
TLRPC.TL_channels_toggleAntiSpam req = new TLRPC.TL_channels_toggleAntiSpam();
|
||||
req.channel = getMessagesController().getInputChannel(chatId);
|
||||
textCell.setChecked(req.enabled = (info.antispam = !info.antispam));
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
getConnectionsManager().sendRequest(req, (res, err) -> {
|
||||
if (res != null) {
|
||||
getMessagesController().processUpdates((TLRPC.Updates) res, false);
|
||||
getMessagesController().putChatFull(info);
|
||||
}
|
||||
if (err != null && !"".equals(err.text)) {
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
textCell.setChecked(info.antispam = wasAntispam);
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || !info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
BulletinFactory.of(ChatUsersActivity.this).createSimpleBulletin(R.raw.error, LocaleController.getString("UnknownError", R.string.UnknownError)).show();
|
||||
});
|
||||
}
|
||||
antiSpamToggleLoading = false;
|
||||
});
|
||||
}
|
||||
return;
|
||||
} else if (position == removedUsersRow) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("chat_id", chatId);
|
||||
|
|
@ -2551,7 +2592,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
} else {
|
||||
searchInProgress = false;
|
||||
}
|
||||
searchAdapterHelper.queryServerSearch(query, selectType != SELECT_TYPE_MEMBERS, false, true, false, false, ChatObject.isChannel(currentChat) ? chatId : 0, false, type, 1, addContacts);
|
||||
searchAdapterHelper.queryServerSearch(query, selectType != SELECT_TYPE_MEMBERS, false, true, false, false, ChatObject.isChannel(currentChat) ? chatId : 0, false, type, 1, 0, addContacts);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -2869,7 +2910,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
return true;
|
||||
}
|
||||
return viewType == 0 || viewType == 2 || viewType == 6;
|
||||
return viewType == 0 || viewType == 2 || viewType == 6 || viewType == 12 && ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2944,6 +2985,12 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
flickerLoadingView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
view = flickerLoadingView;
|
||||
break;
|
||||
case 12:
|
||||
TextCell textCell = new TextCell(mContext, 23, false, true, getResourceProvider());
|
||||
textCell.heightDp = 50;
|
||||
textCell.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
||||
view = textCell;
|
||||
break;
|
||||
case 9:
|
||||
default:
|
||||
SlideChooseView chooseView = new SlideChooseView(mContext);
|
||||
|
|
@ -3068,7 +3115,10 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
break;
|
||||
case 1:
|
||||
TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
|
||||
if (position == participantsInfoRow) {
|
||||
if (position == antiSpamInfoRow) {
|
||||
privacyCell.setText(LocaleController.getString("ChannelAntiSpamInfo", R.string.ChannelAntiSpamInfo));
|
||||
privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
|
||||
} else if (position == participantsInfoRow) {
|
||||
if (type == TYPE_BANNED || type == TYPE_KICKED) {
|
||||
if (isChannel) {
|
||||
privacyCell.setText(LocaleController.getString("NoBlockedChannel2", R.string.NoBlockedChannel2));
|
||||
|
|
@ -3130,7 +3180,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
}
|
||||
}
|
||||
} else if (position == recentActionsRow) {
|
||||
actionCell.setText(LocaleController.getString("EventLog", R.string.EventLog), null, R.drawable.msg_log, false);
|
||||
actionCell.setText(LocaleController.getString("EventLog", R.string.EventLog), null, R.drawable.msg_log, antiSpamRow > recentActionsRow);
|
||||
} else if (position == addNew2Row) {
|
||||
actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
|
||||
boolean showDivider = !(loadingUsers && !firstLoaded) && membersHeaderRow == -1 && !participants.isEmpty();
|
||||
|
|
@ -3241,6 +3291,13 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
flickerLoadingView.setItemsCount(1);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
TextCell textCell = (TextCell) holder.itemView;
|
||||
if (position == antiSpamRow) {
|
||||
textCell.getCheckBox().setIcon(ChatObject.canUserDoAdminAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES) && (info == null || info.antispam || info.participants_count >= getMessagesController().telegramAntispamGroupSizeMin) ? 0 : R.drawable.permission_locked);
|
||||
textCell.setTextAndCheckAndIcon(LocaleController.getString("ChannelAntiSpam", R.string.ChannelAntiSpam), info != null && info.antispam, R.drawable.msg_policy, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3263,7 +3320,7 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return 3;
|
||||
} else if (position == restricted1SectionRow || position == permissionsSectionRow || position == slowmodeRow || position == gigaHeaderRow) {
|
||||
return 5;
|
||||
} else if (position == participantsInfoRow || position == slowmodeInfoRow || position == gigaInfoRow) {
|
||||
} else if (position == participantsInfoRow || position == slowmodeInfoRow || position == gigaInfoRow || position == antiSpamInfoRow) {
|
||||
return 1;
|
||||
} else if (position == blockedEmptyRow) {
|
||||
return 4;
|
||||
|
|
@ -3280,6 +3337,8 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
|
|||
return 10;
|
||||
} else if (position == loadingUserCellRow) {
|
||||
return 11;
|
||||
} else if (position == antiSpamRow) {
|
||||
return 12;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
|
|
@ -29,18 +33,14 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.CheckBoxCell;
|
||||
import org.telegram.ui.Cells.CheckBoxUserCell;
|
||||
import org.telegram.ui.Cells.ShadowSectionCell;
|
||||
import org.telegram.ui.Cells.TextCell;
|
||||
import org.telegram.ui.ContentPreviewViewer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import androidx.collection.LongSparseArray;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class AdminLogFilterAlert extends BottomSheet {
|
||||
|
||||
public interface AdminLogFilterAlertDelegate {
|
||||
|
|
@ -222,10 +222,10 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
}
|
||||
});
|
||||
listView.setOnItemClickListener((view, position) -> {
|
||||
if (view instanceof CheckBoxCell) {
|
||||
CheckBoxCell cell = (CheckBoxCell) view;
|
||||
if (view instanceof TextCell) {
|
||||
TextCell cell = (TextCell) view;
|
||||
boolean isChecked = cell.isChecked();
|
||||
cell.setChecked(!isChecked, true);
|
||||
cell.setChecked(!isChecked);
|
||||
if (position == 0) {
|
||||
if (isChecked) {
|
||||
currentFilter = new TLRPC.TL_channelAdminLogEventsFilter();
|
||||
|
|
@ -242,7 +242,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
RecyclerView.ViewHolder holder = listView.findContainingViewHolder(child);
|
||||
int pos = holder.getAdapterPosition();
|
||||
if (holder.getItemViewType() == 0 && pos > 0 && pos < allAdminsRow - 1) {
|
||||
((CheckBoxCell) child).setChecked(!isChecked, true);
|
||||
((TextCell) child).setChecked(!isChecked);
|
||||
}
|
||||
}
|
||||
} else if (position == allAdminsRow) {
|
||||
|
|
@ -268,10 +268,6 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
currentFilter.unban = currentFilter.kick = currentFilter.unkick = currentFilter.promote =
|
||||
currentFilter.demote = currentFilter.info = currentFilter.settings = currentFilter.pinned =
|
||||
currentFilter.edit = currentFilter.delete = currentFilter.group_call = currentFilter.invites = true;
|
||||
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(0);
|
||||
if (holder != null) {
|
||||
((CheckBoxCell) holder.itemView).setChecked(false, true);
|
||||
}
|
||||
}
|
||||
if (position == restrictionsRow) {
|
||||
currentFilter.kick = currentFilter.ban = currentFilter.unkick = currentFilter.unban = !currentFilter.kick;
|
||||
|
|
@ -294,6 +290,16 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
} else if (position == invitesRow) {
|
||||
currentFilter.invites = !currentFilter.invites;
|
||||
}
|
||||
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(0);
|
||||
if (holder != null) {
|
||||
boolean isAllChecked = (
|
||||
currentFilter.join && currentFilter.leave && currentFilter.invite && currentFilter.ban &&
|
||||
currentFilter.unban && currentFilter.kick && currentFilter.unkick && currentFilter.promote &&
|
||||
currentFilter.demote && currentFilter.info && currentFilter.settings && currentFilter.pinned &&
|
||||
currentFilter.edit && currentFilter.delete && currentFilter.group_call && currentFilter.invites
|
||||
);
|
||||
((TextCell) holder.itemView).setChecked(isAllChecked);
|
||||
}
|
||||
}
|
||||
if (currentFilter != null &&
|
||||
!currentFilter.join && !currentFilter.leave && !currentFilter.invite && !currentFilter.ban &&
|
||||
|
|
@ -312,7 +318,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
selectedAdmins = new LongSparseArray<>();
|
||||
RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(allAdminsRow);
|
||||
if (holder != null) {
|
||||
((CheckBoxCell) holder.itemView).setChecked(false, true);
|
||||
((TextCell) holder.itemView).setChecked(false);
|
||||
}
|
||||
for (int a = 0; a < currentAdmins.size(); a++) {
|
||||
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessageObject.getPeerId(currentAdmins.get(a).peer));
|
||||
|
|
@ -415,7 +421,7 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
FrameLayout view = null;
|
||||
switch (viewType) {
|
||||
case 0:
|
||||
view = new CheckBoxCell(context, 1, 21, resourcesProvider);
|
||||
view = new TextCell(context, 23, false, true, resourcesProvider);
|
||||
break;
|
||||
case 1:
|
||||
ShadowSectionCell shadowSectionCell = new ShadowSectionCell(context, 18);
|
||||
|
|
@ -435,35 +441,6 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
|
||||
int position = holder.getAdapterPosition();
|
||||
switch (holder.getItemViewType()) {
|
||||
case 0: {
|
||||
CheckBoxCell cell = (CheckBoxCell) holder.itemView;
|
||||
if (position == 0) {
|
||||
cell.setChecked(currentFilter == null, false);
|
||||
} else if (position == restrictionsRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.kick && currentFilter.ban && currentFilter.unkick && currentFilter.unban, false);
|
||||
} else if (position == adminsRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.promote && currentFilter.demote, false);
|
||||
} else if (position == membersRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.invite && currentFilter.join, false);
|
||||
} else if (position == infoRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.info, false);
|
||||
} else if (position == deleteRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.delete, false);
|
||||
} else if (position == editRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.edit, false);
|
||||
} else if (position == pinnedRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.pinned, false);
|
||||
} else if (position == leavingRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.leave, false);
|
||||
} else if (position == callsRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.group_call, false);
|
||||
} else if (position == invitesRow) {
|
||||
cell.setChecked(currentFilter == null || currentFilter.invites, false);
|
||||
} else if (position == allAdminsRow) {
|
||||
cell.setChecked(selectedAdmins == null, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
CheckBoxUserCell userCell = (CheckBoxUserCell) holder.itemView;
|
||||
long userId = MessageObject.getPeerId(currentAdmins.get(position - allAdminsRow - 1).peer);
|
||||
|
|
@ -477,35 +454,35 @@ public class AdminLogFilterAlert extends BottomSheet {
|
|||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
switch (holder.getItemViewType()) {
|
||||
case 0: {
|
||||
CheckBoxCell cell = (CheckBoxCell) holder.itemView;
|
||||
TextCell cell = (TextCell) holder.itemView;
|
||||
if (position == 0) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterAll", R.string.EventLogFilterAll), "", currentFilter == null, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterAll", R.string.EventLogFilterAll), currentFilter == null, true);
|
||||
} else if (position == restrictionsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterNewRestrictions", R.string.EventLogFilterNewRestrictions), "", currentFilter == null || currentFilter.kick && currentFilter.ban && currentFilter.unkick && currentFilter.unban, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterNewRestrictions", R.string.EventLogFilterNewRestrictions), currentFilter == null || currentFilter.kick && currentFilter.ban && currentFilter.unkick && currentFilter.unban, true);
|
||||
} else if (position == adminsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterNewAdmins", R.string.EventLogFilterNewAdmins), "", currentFilter == null || currentFilter.promote && currentFilter.demote, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterNewAdmins", R.string.EventLogFilterNewAdmins), currentFilter == null || currentFilter.promote && currentFilter.demote, true);
|
||||
} else if (position == membersRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterNewMembers", R.string.EventLogFilterNewMembers), "", currentFilter == null || currentFilter.invite && currentFilter.join, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterNewMembers", R.string.EventLogFilterNewMembers), currentFilter == null || currentFilter.invite && currentFilter.join, true);
|
||||
} else if (position == infoRow) {
|
||||
if (isMegagroup) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterGroupInfo", R.string.EventLogFilterGroupInfo), "", currentFilter == null || currentFilter.info, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterGroupInfo", R.string.EventLogFilterGroupInfo), currentFilter == null || currentFilter.info, true);
|
||||
} else {
|
||||
cell.setText(LocaleController.getString("EventLogFilterChannelInfo", R.string.EventLogFilterChannelInfo), "", currentFilter == null || currentFilter.info, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterChannelInfo", R.string.EventLogFilterChannelInfo), currentFilter == null || currentFilter.info, true);
|
||||
}
|
||||
} else if (position == deleteRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterDeletedMessages", R.string.EventLogFilterDeletedMessages), "", currentFilter == null || currentFilter.delete, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterDeletedMessages", R.string.EventLogFilterDeletedMessages), currentFilter == null || currentFilter.delete, true);
|
||||
} else if (position == editRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterEditedMessages", R.string.EventLogFilterEditedMessages), "", currentFilter == null || currentFilter.edit, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterEditedMessages", R.string.EventLogFilterEditedMessages), currentFilter == null || currentFilter.edit, true);
|
||||
} else if (position == pinnedRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterPinnedMessages", R.string.EventLogFilterPinnedMessages), "", currentFilter == null || currentFilter.pinned, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterPinnedMessages", R.string.EventLogFilterPinnedMessages), currentFilter == null || currentFilter.pinned, true);
|
||||
} else if (position == leavingRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterLeavingMembers", R.string.EventLogFilterLeavingMembers), "", currentFilter == null || currentFilter.leave, callsRow != -1);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterLeavingMembers", R.string.EventLogFilterLeavingMembers), currentFilter == null || currentFilter.leave, callsRow != -1);
|
||||
} else if (position == callsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterCalls", R.string.EventLogFilterCalls), "", currentFilter == null || currentFilter.group_call, false);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterCalls", R.string.EventLogFilterCalls), currentFilter == null || currentFilter.group_call, false);
|
||||
} else if (position == invitesRow) {
|
||||
cell.setText(LocaleController.getString("EventLogFilterInvites", R.string.EventLogFilterInvites), "", currentFilter == null || currentFilter.invites, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogFilterInvites", R.string.EventLogFilterInvites), currentFilter == null || currentFilter.invites, true);
|
||||
} else if (position == allAdminsRow) {
|
||||
cell.setText(LocaleController.getString("EventLogAllAdmins", R.string.EventLogAllAdmins), "", selectedAdmins == null, true);
|
||||
cell.setTextAndCheck(LocaleController.getString("EventLogAllAdmins", R.string.EventLogAllAdmins), selectedAdmins == null, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import android.view.HapticFeedbackConstants;
|
|||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
|
@ -1033,6 +1032,7 @@ public class AlertsCreator {
|
|||
cell.setTag(a);
|
||||
cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
|
||||
cell.setTextAndValue(arrayList.get(a), SharedConfig.mapPreviewType == types.get(a));
|
||||
cell.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), Theme.RIPPLE_MASK_ALL));
|
||||
linearLayout.addView(cell);
|
||||
cell.setOnClickListener(v -> {
|
||||
Integer which = (Integer) v.getTag();
|
||||
|
|
@ -1065,26 +1065,19 @@ public class AlertsCreator {
|
|||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
|
||||
int year, month;
|
||||
|
||||
int currentYear = calendar.get(Calendar.YEAR);
|
||||
int currentMonth = calendar.get(Calendar.MONTH);
|
||||
int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
if (currentYear > yearPicker.getValue()) {
|
||||
yearPicker.setValue(currentYear);
|
||||
//yearPicker.finishScroll();
|
||||
}
|
||||
if (yearPicker.getValue() == currentYear) {
|
||||
if (currentMonth > monthPicker.getValue()) {
|
||||
monthPicker.setValue(currentMonth);
|
||||
//monthPicker.finishScroll();
|
||||
}
|
||||
if (currentMonth == monthPicker.getValue()) {
|
||||
if (currentDay > dayPicker.getValue()) {
|
||||
dayPicker.setValue(currentDay);
|
||||
//dayPicker.finishScroll();
|
||||
}
|
||||
}
|
||||
}
|
||||
yearPicker.setMinValue(currentYear);
|
||||
year = yearPicker.getValue();
|
||||
|
||||
monthPicker.setMinValue(year == currentYear ? currentMonth : 0);
|
||||
month = monthPicker.getValue();
|
||||
|
||||
dayPicker.setMinValue(year == currentYear && month == currentMonth ? currentDay : 1);
|
||||
}
|
||||
|
||||
public static void showOpenUrlAlert(BaseFragment fragment, String url, boolean punycode, boolean ask) {
|
||||
|
|
@ -1136,7 +1129,7 @@ public class AlertsCreator {
|
|||
if (fragment == null || fragment.getParentActivity() == null) {
|
||||
return null;
|
||||
}
|
||||
final TextView message = new TextView(fragment.getParentActivity());
|
||||
final LinkSpanDrawable.LinksTextView message = new LinkSpanDrawable.LinksTextView(fragment.getParentActivity(), fragment.getResourceProvider());
|
||||
Spannable spanned = new SpannableString(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo).replace("\n", "<br>")));
|
||||
URLSpan[] spans = spanned.getSpans(0, spanned.length(), URLSpan.class);
|
||||
for (int i = 0; i < spans.length; i++) {
|
||||
|
|
@ -1284,15 +1277,15 @@ public class AlertsCreator {
|
|||
|
||||
if (user != null) {
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
imageView.setImage(null, null, avatarDrawable, user);
|
||||
} else if (user.id == selfUserId) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
imageView.setImage(null, null, avatarDrawable, user);
|
||||
} else {
|
||||
avatarDrawable.setSmallSize(false);
|
||||
avatarDrawable.setScaleSize(1f);
|
||||
avatarDrawable.setInfo(user);
|
||||
imageView.setForUserOrChat(user, avatarDrawable);
|
||||
}
|
||||
|
|
@ -1462,15 +1455,15 @@ public class AlertsCreator {
|
|||
|
||||
if (user != null) {
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
imageView.setImage(null, null, avatarDrawable, user);
|
||||
} else if (user.id == selfUserId) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
imageView.setImage(null, null, avatarDrawable, user);
|
||||
} else {
|
||||
avatarDrawable.setSmallSize(false);
|
||||
avatarDrawable.setScaleSize(1f);
|
||||
avatarDrawable.setInfo(user);
|
||||
imageView.setForUserOrChat(user, avatarDrawable);
|
||||
}
|
||||
|
|
@ -1745,7 +1738,7 @@ public class AlertsCreator {
|
|||
|
||||
AvatarDrawable avatarDrawable = new AvatarDrawable();
|
||||
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
|
||||
avatarDrawable.setSmallSize(false);
|
||||
avatarDrawable.setScaleSize(1f);
|
||||
avatarDrawable.setInfo(user);
|
||||
|
||||
BackupImageView imageView = new BackupImageView(context);
|
||||
|
|
@ -2276,34 +2269,50 @@ public class AlertsCreator {
|
|||
calendar.setTimeInMillis(systemTime);
|
||||
int currentYear = calendar.get(Calendar.YEAR);
|
||||
int currentDay = calendar.get(Calendar.DAY_OF_YEAR);
|
||||
|
||||
int maxDay = 0, maxHour = 0, maxMinute = 0;
|
||||
if (maxDate > 0) {
|
||||
maxDate *= 1000;
|
||||
calendar.setTimeInMillis(systemTime + maxDate);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 23);
|
||||
calendar.set(Calendar.MINUTE, 59);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, maxHour = 23);
|
||||
calendar.set(Calendar.MINUTE, maxMinute = 59);
|
||||
calendar.set(Calendar.SECOND, 59);
|
||||
maxDay = 7; // ???
|
||||
maxDate = calendar.getTimeInMillis();
|
||||
}
|
||||
|
||||
calendar.setTimeInMillis(systemTime + 60000L);
|
||||
int minDay = 1;
|
||||
int minHour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minMinute = calendar.get(Calendar.MINUTE);
|
||||
|
||||
calendar.setTimeInMillis(System.currentTimeMillis() + (long) day * 24 * 3600 * 1000);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hour);
|
||||
calendar.set(Calendar.MINUTE, minute);
|
||||
long currentTime = calendar.getTimeInMillis();
|
||||
calendar.setTimeInMillis(currentTime);
|
||||
|
||||
dayPicker.setMinValue(0);
|
||||
if (maxDate > 0) {
|
||||
dayPicker.setMaxValue(maxDay);
|
||||
}
|
||||
day = dayPicker.getValue();
|
||||
|
||||
hourPicker.setMinValue(day == 0 ? minHour : 0);
|
||||
if (maxDate > 0) {
|
||||
hourPicker.setMaxValue(day == maxDay ? maxHour : 23);
|
||||
}
|
||||
hour = hourPicker.getValue();
|
||||
|
||||
minutePicker.setMinValue(day == 0 && hour == minHour ? minMinute : 0);
|
||||
if (maxDate > 0) {
|
||||
minutePicker.setMaxValue(day == maxDay && hour == maxHour ? maxMinute : 59);
|
||||
}
|
||||
minute = minutePicker.getValue();
|
||||
if (currentTime <= systemTime + 60000L) {
|
||||
calendar.setTimeInMillis(systemTime + 60000L);
|
||||
|
||||
if (currentDay != calendar.get(Calendar.DAY_OF_YEAR)) {
|
||||
dayPicker.setValue(day = 1);
|
||||
}
|
||||
hourPicker.setValue(hour = calendar.get(Calendar.HOUR_OF_DAY));
|
||||
minutePicker.setValue(minute = calendar.get(Calendar.MINUTE));
|
||||
} else if (maxDate > 0 && currentTime > maxDate) {
|
||||
calendar.setTimeInMillis(maxDate);
|
||||
|
||||
dayPicker.setValue(day = 7);
|
||||
hourPicker.setValue(hour = calendar.get(Calendar.HOUR_OF_DAY));
|
||||
minutePicker.setValue(minute = calendar.get(Calendar.MINUTE));
|
||||
}
|
||||
int selectedYear = calendar.get(Calendar.YEAR);
|
||||
|
||||
|
|
@ -3019,7 +3028,7 @@ public class AlertsCreator {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static BottomSheet.Builder createAutoDeleteDatePickerDialog(Context context, Theme.ResourcesProvider resourcesProvider, final ScheduleDatePickerDelegate datePickerDelegate) {
|
||||
public static BottomSheet.Builder createAutoDeleteDatePickerDialog(Context context, int type, Theme.ResourcesProvider resourcesProvider, final ScheduleDatePickerDelegate datePickerDelegate) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -3128,7 +3137,7 @@ public class AlertsCreator {
|
|||
linearLayout.setWeightSum(1.0f);
|
||||
container.addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 1f, 0, 0, 12, 0, 12));
|
||||
|
||||
TextView buttonTextView = new TextView(context) {
|
||||
AnimatedTextView buttonTextView = new AnimatedTextView(context, true, true, false) {
|
||||
@Override
|
||||
public CharSequence getAccessibilityClassName() {
|
||||
return Button.class.getName();
|
||||
|
|
@ -3137,17 +3146,22 @@ public class AlertsCreator {
|
|||
|
||||
linearLayout.addView(numberPicker, LayoutHelper.createLinear(0, 54 * 5, 1f));
|
||||
|
||||
buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
|
||||
buttonTextView.setPadding(0, 0, 0, 0);
|
||||
buttonTextView.setGravity(Gravity.CENTER);
|
||||
buttonTextView.setTextColor(datePickerColors.buttonTextColor);
|
||||
buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
buttonTextView.setTextSize(AndroidUtilities.dp(14));
|
||||
buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
buttonTextView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), datePickerColors.buttonBackgroundColor, datePickerColors.buttonBackgroundPressedColor));
|
||||
buttonTextView.setText(LocaleController.getString("AutoDeleteConfirm", R.string.AutoDeleteConfirm));
|
||||
container.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM, 16, 15, 16, 16));
|
||||
buttonTextView.setText(LocaleController.getString("DisableAutoDeleteTimer", R.string.DisableAutoDeleteTimer));
|
||||
|
||||
final NumberPicker.OnValueChangeListener onValueChangeListener = (picker, oldVal, newVal) -> {
|
||||
try {
|
||||
if (newVal == 0) {
|
||||
buttonTextView.setText(LocaleController.getString("DisableAutoDeleteTimer", R.string.DisableAutoDeleteTimer));
|
||||
} else {
|
||||
buttonTextView.setText(LocaleController.getString("SetAutoDeleteTimer", R.string.SetAutoDeleteTimer));
|
||||
}
|
||||
container.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||
} catch (Exception ignore) {
|
||||
|
||||
|
|
@ -3503,9 +3517,7 @@ public class AlertsCreator {
|
|||
}
|
||||
|
||||
private static void checkCalendarDate(long minDate, NumberPicker dayPicker, NumberPicker monthPicker, NumberPicker yearPicker) {
|
||||
int day = dayPicker.getValue();
|
||||
int month = monthPicker.getValue();
|
||||
int year = yearPicker.getValue();
|
||||
int month, year;
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(minDate);
|
||||
|
|
@ -3517,43 +3529,20 @@ public class AlertsCreator {
|
|||
int maxMonth = calendar.get(Calendar.MONTH);
|
||||
int maxDay = calendar.get(Calendar.DAY_OF_MONTH);
|
||||
|
||||
if (year > maxYear) {
|
||||
yearPicker.setValue(year = maxYear);
|
||||
}
|
||||
if (year == maxYear) {
|
||||
if (month > maxMonth) {
|
||||
monthPicker.setValue(month = maxMonth);
|
||||
}
|
||||
if (month == maxMonth) {
|
||||
if (day > maxDay) {
|
||||
dayPicker.setValue(day = maxDay);
|
||||
}
|
||||
}
|
||||
}
|
||||
yearPicker.setMaxValue(maxYear);
|
||||
yearPicker.setMinValue(minYear);
|
||||
year = yearPicker.getValue();
|
||||
|
||||
if (year < minYear) {
|
||||
yearPicker.setValue(year = minYear);
|
||||
}
|
||||
if (year == minYear) {
|
||||
if (month < minMonth) {
|
||||
monthPicker.setValue(month = minMonth);
|
||||
}
|
||||
if (month == minMonth) {
|
||||
if (day < minDay) {
|
||||
dayPicker.setValue(day = minDay);
|
||||
}
|
||||
}
|
||||
}
|
||||
monthPicker.setMaxValue(year == maxYear ? maxMonth : 11);
|
||||
monthPicker.setMinValue(year == minYear ? minMonth : 0);
|
||||
month = monthPicker.getValue();
|
||||
|
||||
calendar.set(Calendar.YEAR, year);
|
||||
calendar.set(Calendar.MONTH, month);
|
||||
|
||||
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
dayPicker.setMaxValue(daysInMonth);
|
||||
if (day > daysInMonth) {
|
||||
day = daysInMonth;
|
||||
dayPicker.setValue(day);
|
||||
}
|
||||
dayPicker.setMaxValue(year == maxYear && month == maxMonth ? Math.min(maxDay, daysInMonth) : daysInMonth);
|
||||
dayPicker.setMinValue(year == minYear && month == minMonth ? minDay : 1);
|
||||
}
|
||||
|
||||
public static BottomSheet.Builder createCalendarPickerDialog(Context context, long minDate, final MessagesStorage.IntCallback callback, Theme.ResourcesProvider resourcesProvider) {
|
||||
|
|
@ -3653,39 +3642,17 @@ public class AlertsCreator {
|
|||
linearLayout.addView(monthPicker, LayoutHelper.createLinear(0, 54 * 5, 0.5f));
|
||||
monthPicker.setFormatter(value -> {
|
||||
switch (value) {
|
||||
case 0: {
|
||||
return LocaleController.getString("January", R.string.January);
|
||||
}
|
||||
case 1: {
|
||||
return LocaleController.getString("February", R.string.February);
|
||||
}
|
||||
case 2: {
|
||||
return LocaleController.getString("March", R.string.March);
|
||||
}
|
||||
case 3: {
|
||||
return LocaleController.getString("April", R.string.April);
|
||||
}
|
||||
case 4: {
|
||||
return LocaleController.getString("May", R.string.May);
|
||||
}
|
||||
case 5: {
|
||||
return LocaleController.getString("June", R.string.June);
|
||||
}
|
||||
case 6: {
|
||||
return LocaleController.getString("July", R.string.July);
|
||||
}
|
||||
case 7: {
|
||||
return LocaleController.getString("August", R.string.August);
|
||||
}
|
||||
case 8: {
|
||||
return LocaleController.getString("September", R.string.September);
|
||||
}
|
||||
case 9: {
|
||||
return LocaleController.getString("October", R.string.October);
|
||||
}
|
||||
case 10: {
|
||||
return LocaleController.getString("November", R.string.November);
|
||||
}
|
||||
case 0: return LocaleController.getString("January", R.string.January);
|
||||
case 1: return LocaleController.getString("February", R.string.February);
|
||||
case 2: return LocaleController.getString("March", R.string.March);
|
||||
case 3: return LocaleController.getString("April", R.string.April);
|
||||
case 4: return LocaleController.getString("May", R.string.May);
|
||||
case 5: return LocaleController.getString("June", R.string.June);
|
||||
case 6: return LocaleController.getString("July", R.string.July);
|
||||
case 7: return LocaleController.getString("August", R.string.August);
|
||||
case 8: return LocaleController.getString("September", R.string.September);
|
||||
case 9: return LocaleController.getString("October", R.string.October);
|
||||
case 10: return LocaleController.getString("November", R.string.November);
|
||||
case 11:
|
||||
default: {
|
||||
return LocaleController.getString("December", R.string.December);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.view.Gravity;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class AnimatedAvatarContainer extends FrameLayout {
|
||||
|
||||
boolean occupyStatusBar = true;
|
||||
private int leftPadding = AndroidUtilities.dp(8);
|
||||
AnimatedTextView titleTextView;
|
||||
AnimatedTextView subtitleTextView;
|
||||
public AnimatedAvatarContainer(@NonNull Context context) {
|
||||
super(context);
|
||||
titleTextView = new AnimatedTextView(context, true, true, true);
|
||||
titleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
|
||||
titleTextView.setTextSize(AndroidUtilities.dp(18));
|
||||
titleTextView.setGravity(Gravity.LEFT);
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
titleTextView.setPadding(0, AndroidUtilities.dp(6), 0, AndroidUtilities.dp(12));
|
||||
addView(titleTextView);
|
||||
|
||||
subtitleTextView = new AnimatedTextView(context, true, true, true);
|
||||
subtitleTextView.setTag(Theme.key_actionBarDefaultSubtitle);
|
||||
subtitleTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
|
||||
subtitleTextView.setTextSize(AndroidUtilities.dp(14));
|
||||
subtitleTextView.setGravity(Gravity.LEFT);
|
||||
subtitleTextView.setPadding(0, 0, AndroidUtilities.dp(10), 0);
|
||||
addView(subtitleTextView);
|
||||
|
||||
titleTextView.getDrawable().setAllowCancel(true);
|
||||
subtitleTextView.getDrawable().setAllowCancel(true);
|
||||
titleTextView.setAnimationProperties(1f, 0, 150, CubicBezierInterpolator.DEFAULT);
|
||||
subtitleTextView.setAnimationProperties(1f, 0, 150, CubicBezierInterpolator.DEFAULT);
|
||||
|
||||
setClipChildren(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec) + titleTextView.getPaddingRight();
|
||||
int availableWidth = width - AndroidUtilities.dp( 16);
|
||||
titleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(24 + 8) + titleTextView.getPaddingRight(), MeasureSpec.AT_MOST));
|
||||
subtitleTextView.measure(MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(20), MeasureSpec.AT_MOST));
|
||||
setMeasuredDimension(width, MeasureSpec.getSize(heightMeasureSpec));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
int actionBarHeight = ActionBar.getCurrentActionBarHeight();
|
||||
int viewTop = (actionBarHeight - AndroidUtilities.dp(42)) / 2 + (Build.VERSION.SDK_INT >= 21 && occupyStatusBar ? AndroidUtilities.statusBarHeight : 0);
|
||||
int l = leftPadding;
|
||||
if (subtitleTextView.getVisibility() != GONE) {
|
||||
titleTextView.layout(l, viewTop + AndroidUtilities.dp(1f) - titleTextView.getPaddingTop(), l + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(1.3f) - titleTextView.getPaddingTop() + titleTextView.getPaddingBottom());
|
||||
} else {
|
||||
titleTextView.layout(l, viewTop + AndroidUtilities.dp(11) - titleTextView.getPaddingTop(), l + titleTextView.getMeasuredWidth(), viewTop + titleTextView.getTextHeight() + AndroidUtilities.dp(11) - titleTextView.getPaddingTop() + titleTextView.getPaddingBottom());
|
||||
}
|
||||
subtitleTextView.layout(l, viewTop + AndroidUtilities.dp(20), l + subtitleTextView.getMeasuredWidth(), viewTop + subtitleTextView.getTextHeight() + AndroidUtilities.dp(24));
|
||||
}
|
||||
|
||||
public AnimatedTextView getTitle() {
|
||||
return titleTextView;
|
||||
}
|
||||
|
||||
public AnimatedTextView getSubtitleTextView() {
|
||||
return subtitleTextView;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
|
|
@ -12,6 +13,7 @@ import android.text.style.CharacterStyle;
|
|||
import android.text.style.ReplacementSpan;
|
||||
import android.util.LongSparseArray;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
|
|
@ -831,6 +833,43 @@ public class AnimatedEmojiSpan extends ReplacementSpan {
|
|||
return newText;
|
||||
}
|
||||
|
||||
public static class TextViewEmojis extends TextView {
|
||||
public TextViewEmojis(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
AnimatedEmojiSpan.EmojiGroupedSpans stack;
|
||||
@Override
|
||||
public void setText(CharSequence text, TextView.BufferType type) {
|
||||
super.setText(text, type);
|
||||
stack = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, stack, getLayout());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
stack = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, stack, getLayout());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
stack = AnimatedEmojiSpan.update(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, this, stack, getLayout());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
AnimatedEmojiSpan.release(this, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
AnimatedEmojiSpan.drawAnimatedEmojis(canvas, getLayout(), stack, 0, null, 0, 0, 0, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public interface InvalidateHolder {
|
||||
void invalidate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import android.text.Layout;
|
|||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
|
@ -26,7 +25,6 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -72,6 +70,7 @@ public class AnimatedTextView extends View {
|
|||
private boolean startFromEnd;
|
||||
|
||||
private Runnable onAnimationFinishListener;
|
||||
private boolean allowCancel;
|
||||
|
||||
public AnimatedTextDrawable() {
|
||||
this(false, false, false);
|
||||
|
|
@ -83,6 +82,10 @@ public class AnimatedTextView extends View {
|
|||
this.startFromEnd = startFromEnd;
|
||||
}
|
||||
|
||||
public void setAllowCancel(boolean allowCancel) {
|
||||
this.allowCancel = allowCancel;
|
||||
}
|
||||
|
||||
public void setOnAnimationFinishListener(Runnable listener) {
|
||||
onAnimationFinishListener = listener;
|
||||
}
|
||||
|
|
@ -93,7 +96,7 @@ public class AnimatedTextView extends View {
|
|||
canvas.translate(bounds.left, bounds.top);
|
||||
int fullWidth = bounds.width();
|
||||
int fullHeight = bounds.height();
|
||||
if (currentLayout != null && oldLayout != null) {
|
||||
if (currentLayout != null && oldLayout != null && t != 1) {
|
||||
int width = AndroidUtilities.lerp(oldWidth, currentWidth, t);
|
||||
int height = AndroidUtilities.lerp(oldHeight, currentHeight, t);
|
||||
canvas.translate(0, (fullHeight - height) / 2f);
|
||||
|
|
@ -122,7 +125,7 @@ public class AnimatedTextView extends View {
|
|||
x += fullWidth - lwidth;
|
||||
}
|
||||
}
|
||||
canvas.translate(x, y);
|
||||
canvas.translate(Math.round(x), Math.round(y));
|
||||
currentLayout[i].draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
@ -147,7 +150,7 @@ public class AnimatedTextView extends View {
|
|||
x += fullWidth - oldWidth;
|
||||
}
|
||||
}
|
||||
canvas.translate(x, y);
|
||||
canvas.translate(Math.round(x), Math.round(y));
|
||||
oldLayout[i].draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
@ -170,7 +173,7 @@ public class AnimatedTextView extends View {
|
|||
x += fullWidth - currentWidth;
|
||||
}
|
||||
}
|
||||
canvas.translate(x, 0);
|
||||
canvas.translate(Math.round(x), 0);
|
||||
currentLayout[i].draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
|
@ -205,7 +208,12 @@ public class AnimatedTextView extends View {
|
|||
text = "";
|
||||
}
|
||||
if (animated) {
|
||||
if (isAnimating()) {
|
||||
if (allowCancel) {
|
||||
if (animator != null) {
|
||||
animator.cancel();
|
||||
animator = null;
|
||||
}
|
||||
} else if (isAnimating()) {
|
||||
toSetText = text;
|
||||
toSetTextMoveDown = moveDown;
|
||||
return;
|
||||
|
|
@ -635,6 +643,10 @@ public class AnimatedTextView extends View {
|
|||
textPaint.setTextSize(textSizePx);
|
||||
}
|
||||
|
||||
public float getTextSize() {
|
||||
return textPaint.getTextSize();
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
textPaint.setColor(color);
|
||||
}
|
||||
|
|
@ -761,10 +773,17 @@ public class AnimatedTextView extends View {
|
|||
public void setText(CharSequence text, boolean animated, boolean moveDown) {
|
||||
animated = !first && animated;
|
||||
first = false;
|
||||
if (animated && drawable.isAnimating()) {
|
||||
toSetText = text;
|
||||
toSetMoveDown = moveDown;
|
||||
return;
|
||||
if (animated) {
|
||||
if (drawable.allowCancel) {
|
||||
if (drawable.animator != null) {
|
||||
drawable.animator.cancel();
|
||||
drawable.animator = null;
|
||||
}
|
||||
} else if (drawable.isAnimating()) {
|
||||
toSetText = text;
|
||||
toSetMoveDown = moveDown;
|
||||
return;
|
||||
}
|
||||
}
|
||||
int wasWidth = drawable.getWidth();
|
||||
drawable.setBounds(getPaddingLeft(), getPaddingTop(), lastMaxWidth - getPaddingRight(), getMeasuredHeight() - getPaddingBottom());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
|
@ -16,13 +18,17 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
|
||||
public class AutoDeletePopupWrapper {
|
||||
|
||||
public static final int TYPE_GROUP_CREATE = 1;
|
||||
|
||||
private int type;
|
||||
View backItem;
|
||||
public ActionBarPopupWindow.ActionBarPopupWindowLayout windowLayout;
|
||||
private final ActionBarMenuSubItem disableItem;
|
||||
Callback callback;
|
||||
long lastDismissTime;
|
||||
TextView textView;
|
||||
|
||||
public AutoDeletePopupWrapper(Context context, PopupSwipeBackLayout swipeBackLayout, Callback callback, boolean createBackground, Theme.ResourcesProvider resourcesProvider) {
|
||||
public AutoDeletePopupWrapper(Context context, PopupSwipeBackLayout swipeBackLayout, Callback callback, boolean createBackground, int type, Theme.ResourcesProvider resourcesProvider) {
|
||||
windowLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(context, createBackground ? R.drawable.popup_fixed_alert : 0, resourcesProvider);
|
||||
windowLayout.setFitItems(true);
|
||||
this.callback = callback;
|
||||
|
|
@ -49,10 +55,14 @@ public class AutoDeletePopupWrapper {
|
|||
dismiss();
|
||||
callback.setAutoDeleteHistory(31 * 24 * 60 * 60, UndoView.ACTION_AUTO_DELETE_ON);
|
||||
});
|
||||
item = ActionBarMenuItem.addItem(windowLayout, R.drawable.msg_customize, LocaleController.getString("AutoDeleteCustom", R.string.AutoDeleteCustom), false, resourcesProvider);
|
||||
String customTitle = LocaleController.getString("AutoDeleteCustom", R.string.AutoDeleteCustom);
|
||||
if (type == TYPE_GROUP_CREATE) {
|
||||
customTitle = LocaleController.getString("AutoDeleteCustom2", R.string.AutoDeleteCustom2);
|
||||
}
|
||||
item = ActionBarMenuItem.addItem(windowLayout, R.drawable.msg_customize, customTitle, false, resourcesProvider);
|
||||
item.setOnClickListener(view -> {
|
||||
dismiss();
|
||||
AlertsCreator.createAutoDeleteDatePickerDialog(context, resourcesProvider, (notify, timeInMinutes) -> {
|
||||
AlertsCreator.createAutoDeleteDatePickerDialog(context, type, resourcesProvider, (notify, timeInMinutes) -> {
|
||||
callback.setAutoDeleteHistory(timeInMinutes * 60, timeInMinutes == 0 ? UndoView.ACTION_AUTO_DELETE_OFF : UndoView.ACTION_AUTO_DELETE_ON);
|
||||
});
|
||||
});
|
||||
|
|
@ -61,20 +71,29 @@ public class AutoDeletePopupWrapper {
|
|||
dismiss();
|
||||
callback.setAutoDeleteHistory(0, UndoView.ACTION_AUTO_DELETE_OFF);
|
||||
});
|
||||
disableItem.setColors(Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogTextRed2));
|
||||
if (type != TYPE_GROUP_CREATE) {
|
||||
disableItem.setColors(Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogTextRed2));
|
||||
}
|
||||
|
||||
View gap = new FrameLayout(context);
|
||||
gap.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuSeparator, resourcesProvider));
|
||||
gap.setTag(R.id.fit_width_tag, 1);
|
||||
windowLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
|
||||
if (type != TYPE_GROUP_CREATE) {
|
||||
FrameLayout gap = new FrameLayout(context);
|
||||
gap.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuSeparator, resourcesProvider));
|
||||
View gapShadow = new View(context);
|
||||
gapShadow.setBackground(Theme.getThemedDrawable(context, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow, resourcesProvider));
|
||||
gap.addView(gapShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
gap.setTag(R.id.fit_width_tag, 1);
|
||||
windowLayout.addView(gap, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8));
|
||||
|
||||
TextView textView = new TextView(context);
|
||||
textView.setTag(R.id.fit_width_tag, 1);
|
||||
textView.setPadding(AndroidUtilities.dp(13), AndroidUtilities.dp(8), AndroidUtilities.dp(13), AndroidUtilities.dp(8));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
|
||||
textView.setText(LocaleController.getString("AutoDeletePopupDescription", R.string.AutoDeletePopupDescription));
|
||||
windowLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
textView = new LinkSpanDrawable.LinksTextView(context);
|
||||
textView.setTag(R.id.fit_width_tag, 1);
|
||||
textView.setPadding(AndroidUtilities.dp(13), 0, AndroidUtilities.dp(13), AndroidUtilities.dp(8));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
||||
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
textView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText));
|
||||
textView.setText(LocaleController.getString("AutoDeletePopupDescription", R.string.AutoDeletePopupDescription));
|
||||
windowLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 8, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private void dismiss() {
|
||||
|
|
@ -96,9 +115,28 @@ public class AutoDeletePopupWrapper {
|
|||
}
|
||||
}
|
||||
|
||||
public void allowExtenededHint() {
|
||||
if (textView == null) {
|
||||
return;
|
||||
}
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
|
||||
spannableStringBuilder.append(LocaleController.getString("AutoDeletePopupDescription", R.string.AutoDeletePopupDescription));
|
||||
spannableStringBuilder.append("\n\n");
|
||||
spannableStringBuilder.append(AndroidUtilities.replaceSingleTag(LocaleController.getString("AutoDeletePopupDescription2", R.string.AutoDeletePopupDescription2), () -> {
|
||||
callback.showGlobalAutoDeleteScreen();
|
||||
}));
|
||||
textView.setText(spannableStringBuilder);
|
||||
}
|
||||
|
||||
void setType(int i) {
|
||||
type = i;
|
||||
}
|
||||
|
||||
public interface Callback {
|
||||
void dismiss();
|
||||
void setAutoDeleteHistory(int time, int action);
|
||||
default void showGlobalAutoDeleteScreen() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ import org.telegram.tgnet.TLObject;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AvatarDrawable extends Drawable {
|
||||
|
||||
private TextPaint namePaint;
|
||||
|
|
@ -45,7 +47,7 @@ public class AvatarDrawable extends Drawable {
|
|||
private boolean drawDeleted;
|
||||
private int avatarType;
|
||||
private float archivedAvatarProgress;
|
||||
private boolean smallSize;
|
||||
private float scaleSize = 1f;
|
||||
private StringBuilder stringBuilder = new StringBuilder(5);
|
||||
private int roundRadius = -1;
|
||||
|
||||
|
|
@ -72,6 +74,7 @@ public class AvatarDrawable extends Drawable {
|
|||
public static final int AVATAR_TYPE_FILTER_READ = 10;
|
||||
public static final int AVATAR_TYPE_FILTER_ARCHIVED = 11;
|
||||
public static final int AVATAR_TYPE_REGISTER = 13;
|
||||
public static final int AVATAR_TYPE_OTHER_CHATS = 14;
|
||||
|
||||
private int alpha = 255;
|
||||
private Theme.ResourcesProvider resourcesProvider;
|
||||
|
|
@ -169,8 +172,8 @@ public class AvatarDrawable extends Drawable {
|
|||
}
|
||||
}
|
||||
|
||||
public void setSmallSize(boolean value) {
|
||||
smallSize = value;
|
||||
public void setScaleSize(float value) {
|
||||
scaleSize = value;
|
||||
}
|
||||
|
||||
public void setAvatarType(int value) {
|
||||
|
|
@ -181,11 +184,7 @@ public class AvatarDrawable extends Drawable {
|
|||
} else if (avatarType == AVATAR_TYPE_ARCHIVED) {
|
||||
hasGradient = false;
|
||||
color = color2 = getThemedColor(Theme.key_avatar_backgroundArchivedHidden);
|
||||
} else if (avatarType == AVATAR_TYPE_REPLIES) {
|
||||
hasGradient = true;
|
||||
color = getThemedColor(Theme.key_avatar_backgroundSaved);
|
||||
color2 = getThemedColor(Theme.key_avatar_background2Saved);
|
||||
} else if (avatarType == AVATAR_TYPE_SAVED) {
|
||||
} else if (avatarType == AVATAR_TYPE_REPLIES || avatarType == AVATAR_TYPE_SAVED || avatarType == AVATAR_TYPE_OTHER_CHATS) {
|
||||
hasGradient = true;
|
||||
color = getThemedColor(Theme.key_avatar_backgroundSaved);
|
||||
color2 = getThemedColor(Theme.key_avatar_background2Saved);
|
||||
|
|
@ -226,7 +225,7 @@ public class AvatarDrawable extends Drawable {
|
|||
color = getThemedColor(Theme.keys_avatar_background[getColorIndex(4)]);
|
||||
color2 = getThemedColor(Theme.keys_avatar_background2[getColorIndex(4)]);
|
||||
}
|
||||
needApplyColorAccent = avatarType != AVATAR_TYPE_ARCHIVED && avatarType != AVATAR_TYPE_SAVED && avatarType != AVATAR_TYPE_REPLIES;
|
||||
needApplyColorAccent = avatarType != AVATAR_TYPE_ARCHIVED && avatarType != AVATAR_TYPE_SAVED && avatarType != AVATAR_TYPE_REPLIES && avatarType != AVATAR_TYPE_OTHER_CHATS;
|
||||
}
|
||||
|
||||
public void setArchivedAvatarHiddenProgress(float progress) {
|
||||
|
|
@ -278,31 +277,11 @@ public class AvatarDrawable extends Drawable {
|
|||
}
|
||||
|
||||
private String takeFirstCharacter(String text) {
|
||||
StringBuilder sequence = new StringBuilder(16);
|
||||
boolean isInJoin = false;
|
||||
int codePoint;
|
||||
for (int i = 0; i < text.length(); i = text.offsetByCodePoints(i, 1)) {
|
||||
codePoint = text.codePointAt(i);
|
||||
if (codePoint == 0x200D || codePoint == 0x1f1ea) {
|
||||
isInJoin = true;
|
||||
if (sequence.length() == 0)
|
||||
continue;
|
||||
} else {
|
||||
if ((sequence.length() > 0) && (!isInJoin))
|
||||
break;
|
||||
isInJoin = false;
|
||||
}
|
||||
sequence.appendCodePoint(codePoint);
|
||||
ArrayList<Emoji.EmojiSpanRange> ranges = Emoji.parseEmojis(text);
|
||||
if (ranges != null && !ranges.isEmpty() && ranges.get(0).start == 0) {
|
||||
return text.substring(0, ranges.get(0).end);
|
||||
}
|
||||
if (isInJoin) {
|
||||
for (int i = sequence.length()-1; i >= 0; --i) {
|
||||
if (sequence.charAt(i) == 0x200D)
|
||||
sequence.deleteCharAt(i);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sequence.toString();
|
||||
return text.substring(0, text.offsetByCodePoints(0, Math.min(text.codePointCount(0, text.length()), 1)));
|
||||
}
|
||||
|
||||
public void setInfo(long id, String firstName, String lastName, String custom) {
|
||||
|
|
@ -429,12 +408,8 @@ public class AvatarDrawable extends Drawable {
|
|||
} else if (avatarType != 0) {
|
||||
Drawable drawable;
|
||||
|
||||
if (avatarType == AVATAR_TYPE_REPLIES) {
|
||||
drawable = Theme.avatarDrawables[11];
|
||||
} else if (avatarType == AVATAR_TYPE_SAVED) {
|
||||
if (avatarType == AVATAR_TYPE_SAVED) {
|
||||
drawable = Theme.avatarDrawables[0];
|
||||
} else if (avatarType == AVATAR_TYPE_SHARES) {
|
||||
drawable = Theme.avatarDrawables[10];
|
||||
} else if (avatarType == AVATAR_TYPE_FILTER_CONTACTS) {
|
||||
drawable = Theme.avatarDrawables[2];
|
||||
} else if (avatarType == AVATAR_TYPE_FILTER_NON_CONTACTS) {
|
||||
|
|
@ -449,16 +424,18 @@ public class AvatarDrawable extends Drawable {
|
|||
drawable = Theme.avatarDrawables[7];
|
||||
} else if (avatarType == AVATAR_TYPE_FILTER_READ) {
|
||||
drawable = Theme.avatarDrawables[8];
|
||||
} else if (avatarType == AVATAR_TYPE_SHARES) {
|
||||
drawable = Theme.avatarDrawables[10];
|
||||
} else if (avatarType == AVATAR_TYPE_REPLIES) {
|
||||
drawable = Theme.avatarDrawables[11];
|
||||
} else if (avatarType == AVATAR_TYPE_OTHER_CHATS) {
|
||||
drawable = Theme.avatarDrawables[12];
|
||||
} else {
|
||||
drawable = Theme.avatarDrawables[9];
|
||||
}
|
||||
if (drawable != null) {
|
||||
int w = drawable.getIntrinsicWidth();
|
||||
int h = drawable.getIntrinsicHeight();
|
||||
if (smallSize) {
|
||||
w *= 0.8f;
|
||||
h *= 0.8f;
|
||||
}
|
||||
int w = (int) (drawable.getIntrinsicWidth() * scaleSize);
|
||||
int h = (int) (drawable.getIntrinsicHeight() * scaleSize);
|
||||
int x = (size - w) / 2;
|
||||
int y = (size - h) / 2;
|
||||
drawable.setBounds(x, y, x + w, y + h);
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class BackButtonMenu {
|
|||
cell.addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 59, 0, 12, 0));
|
||||
|
||||
AvatarDrawable avatarDrawable = new AvatarDrawable();
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
Drawable thumb = avatarDrawable;
|
||||
boolean addDivider = false;
|
||||
if (chat != null) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public class BackupImageView extends View {
|
|||
protected int width = -1;
|
||||
protected int height = -1;
|
||||
public AnimatedEmojiDrawable animatedEmojiDrawable;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
boolean attached;
|
||||
|
||||
public BackupImageView(Context context) {
|
||||
|
|
@ -171,6 +172,13 @@ public class BackupImageView extends View {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public AvatarDrawable getAvatarDrawable() {
|
||||
if (avatarDrawable == null) {
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
return avatarDrawable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.telegram.messenger.SharedConfig;
|
|||
public class BlurredRecyclerView extends RecyclerListView {
|
||||
|
||||
public int blurTopPadding;
|
||||
int topPadding;
|
||||
public int topPadding;
|
||||
boolean globalIgnoreLayout;
|
||||
public int additionalClipBottom;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.animation.ValueAnimator;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
|
@ -69,7 +70,11 @@ import org.telegram.ui.ActionBar.AlertDialog;
|
|||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.voip.CellFlickerDrawable;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -526,6 +531,21 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
|
|||
if (isPageLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
InputStream in = getResources().getAssets().open("bot_clipboard_wrapper.js");
|
||||
BufferedReader r = new BufferedReader(new InputStreamReader(in));
|
||||
StringBuilder script = new StringBuilder();
|
||||
String line;
|
||||
while ((line = r.readLine()) != null) {
|
||||
script.append(line).append("\n");
|
||||
}
|
||||
in.close();
|
||||
evaluateJs(script.toString());
|
||||
} catch (IOException e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
||||
AnimatorSet set = new AnimatorSet();
|
||||
set.playTogether(
|
||||
ObjectAnimator.ofFloat(webView, View.ALPHA, 1f),
|
||||
|
|
@ -1336,6 +1356,13 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
|
|||
public void postEvent(String eventType, String eventData) {
|
||||
AndroidUtilities.runOnUIThread(() -> onEventReceived(eventType, eventData));
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String getClipboardText() {
|
||||
ClipboardManager clipboardManager = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
CharSequence text = clipboardManager.getText();
|
||||
return text != null ? text.toString() : null;
|
||||
}
|
||||
}
|
||||
|
||||
public interface WebViewScrollListener {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
|
@ -49,8 +50,10 @@ import androidx.dynamicanimation.animation.SpringAnimation;
|
|||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
|
|
@ -131,7 +134,9 @@ public class Bulletin {
|
|||
|
||||
private boolean showing;
|
||||
private boolean canHide;
|
||||
private boolean loaded = true;
|
||||
public int currentBottomOffset;
|
||||
public int lastBottomOffset;
|
||||
private Delegate currentDelegate;
|
||||
private Layout.Transition layoutTransition;
|
||||
|
||||
|
|
@ -144,6 +149,7 @@ public class Bulletin {
|
|||
|
||||
private Bulletin(BaseFragment fragment, @NonNull FrameLayout containerLayout, @NonNull Layout layout, int duration) {
|
||||
this.layout = layout;
|
||||
this.loaded = !(this.layout instanceof LoadingLayout);
|
||||
this.parentLayout = new ParentLayout(layout) {
|
||||
@Override
|
||||
protected void onPressedStateChanged(boolean pressed) {
|
||||
|
|
@ -204,15 +210,15 @@ public class Bulletin {
|
|||
containerLayout.addOnLayoutChangeListener(containerLayoutListener = (v, left, top1, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
|
||||
if (!top) {
|
||||
int newOffset = currentDelegate != null ? currentDelegate.getBottomOffset(tag) : 0;
|
||||
if (currentBottomOffset != newOffset) {
|
||||
if (lastBottomOffset != newOffset) {
|
||||
if (bottomOffsetSpring == null || !bottomOffsetSpring.isRunning()) {
|
||||
bottomOffsetSpring = new SpringAnimation(new FloatValueHolder(currentBottomOffset))
|
||||
bottomOffsetSpring = new SpringAnimation(new FloatValueHolder(lastBottomOffset))
|
||||
.setSpring(new SpringForce()
|
||||
.setFinalPosition(newOffset)
|
||||
.setStiffness(900f)
|
||||
.setDampingRatio(SpringForce.DAMPING_RATIO_NO_BOUNCY));
|
||||
bottomOffsetSpring.addUpdateListener((animation, value, velocity) -> {
|
||||
currentBottomOffset = (int) value;
|
||||
lastBottomOffset = (int) value;
|
||||
updatePosition();
|
||||
});
|
||||
bottomOffsetSpring.addEndListener((animation, canceled, value, velocity) -> {
|
||||
|
|
@ -236,7 +242,7 @@ public class Bulletin {
|
|||
layout.onShow();
|
||||
currentDelegate = findDelegate(containerFragment, containerLayout);
|
||||
if (bottomOffsetSpring == null || !bottomOffsetSpring.isRunning()) {
|
||||
currentBottomOffset = currentDelegate != null ? currentDelegate.getBottomOffset(tag) : 0;
|
||||
lastBottomOffset = currentDelegate != null ? currentDelegate.getBottomOffset(tag) : 0;
|
||||
}
|
||||
if (currentDelegate != null) {
|
||||
currentDelegate.onShow(Bulletin.this);
|
||||
|
|
@ -285,7 +291,8 @@ public class Bulletin {
|
|||
return this;
|
||||
}
|
||||
|
||||
private void setCanHide(boolean canHide) {
|
||||
public void setCanHide(boolean canHide) {
|
||||
canHide = canHide && loaded;
|
||||
if (this.canHide != canHide && layout != null) {
|
||||
this.canHide = canHide;
|
||||
if (canHide) {
|
||||
|
|
@ -783,7 +790,7 @@ public class Bulletin {
|
|||
|
||||
public float getBottomOffset() {
|
||||
if (bulletin != null && bulletin.bottomOffsetSpring != null && bulletin.bottomOffsetSpring.isRunning()) {
|
||||
return bulletin.currentBottomOffset;
|
||||
return bulletin.lastBottomOffset;
|
||||
}
|
||||
return delegate.getBottomOffset(bulletin != null ? bulletin.tag : 0);
|
||||
}
|
||||
|
|
@ -1132,8 +1139,8 @@ public class Bulletin {
|
|||
public static class TwoLineLottieLayout extends ButtonLayout {
|
||||
|
||||
public final RLottieImageView imageView;
|
||||
public final TextView titleTextView;
|
||||
public final TextView subtitleTextView;
|
||||
public final LinkSpanDrawable.LinksTextView titleTextView;
|
||||
public final LinkSpanDrawable.LinksTextView subtitleTextView;
|
||||
|
||||
private final int textColor;
|
||||
|
||||
|
|
@ -1147,20 +1154,22 @@ public class Bulletin {
|
|||
addView(imageView, LayoutHelper.createFrameRelatively(56, 48, Gravity.START | Gravity.CENTER_VERTICAL));
|
||||
|
||||
final int undoInfoColor = getThemedColor(Theme.key_undo_infoColor);
|
||||
final int undoLinkColor = getThemedColor(Theme.key_voipgroup_overlayBlue1);
|
||||
final int undoLinkColor = getThemedColor(Theme.key_undo_cancelColor);
|
||||
|
||||
final LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
addView(linearLayout, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 56, 8, 12, 8));
|
||||
addView(linearLayout, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 52, 8, 8, 8));
|
||||
|
||||
titleTextView = new TextView(context);
|
||||
titleTextView = new LinkSpanDrawable.LinksTextView(context);
|
||||
titleTextView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
titleTextView.setSingleLine();
|
||||
titleTextView.setTextColor(undoInfoColor);
|
||||
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
linearLayout.addView(titleTextView);
|
||||
|
||||
subtitleTextView = new TextView(context);
|
||||
subtitleTextView = new LinkSpanDrawable.LinksTextView(context);
|
||||
subtitleTextView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
subtitleTextView.setTextColor(undoInfoColor);
|
||||
subtitleTextView.setLinkTextColor(undoLinkColor);
|
||||
subtitleTextView.setTypeface(Typeface.SANS_SERIF);
|
||||
|
|
@ -1204,7 +1213,14 @@ public class Bulletin {
|
|||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
addView(imageView, LayoutHelper.createFrameRelatively(56, 48, Gravity.START | Gravity.CENTER_VERTICAL));
|
||||
|
||||
textView = new LinkSpanDrawable.LinksTextView(context);
|
||||
textView = new LinkSpanDrawable.LinksTextView(context) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(13), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(textView);
|
||||
textView.setDisablePaddingsOffset(true);
|
||||
textView.setSingleLine();
|
||||
textView.setTypeface(Typeface.SANS_SERIF);
|
||||
|
|
@ -1262,6 +1278,51 @@ public class Bulletin {
|
|||
}
|
||||
}
|
||||
|
||||
public static interface LoadingLayout {
|
||||
void onTextLoaded(CharSequence text);
|
||||
}
|
||||
|
||||
public static class LoadingLottieLayout extends LottieLayout implements LoadingLayout {
|
||||
|
||||
public LinkSpanDrawable.LinksTextView textLoadingView;
|
||||
|
||||
public LoadingLottieLayout(@NonNull Context context, Theme.ResourcesProvider resourcesProvider) {
|
||||
super(context, resourcesProvider);
|
||||
|
||||
textLoadingView = new LinkSpanDrawable.LinksTextView(context);
|
||||
textLoadingView.setDisablePaddingsOffset(true);
|
||||
textLoadingView.setSingleLine();
|
||||
textLoadingView.setTypeface(Typeface.SANS_SERIF);
|
||||
textLoadingView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textLoadingView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
textLoadingView.setPadding(0, AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8));
|
||||
textView.setVisibility(View.GONE);
|
||||
addView(textLoadingView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 56, 0, 8, 0));
|
||||
|
||||
setTextColor(getThemedColor(Theme.key_undo_infoColor));
|
||||
}
|
||||
|
||||
public LoadingLottieLayout(@NonNull Context context, Theme.ResourcesProvider resourcesProvider, int backgroundColor, int textColor) {
|
||||
this(context, resourcesProvider);
|
||||
setBackground(backgroundColor);
|
||||
setTextColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextColor(int textColor) {
|
||||
super.setTextColor(textColor);
|
||||
if (textLoadingView != null) {
|
||||
textLoadingView.setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
|
||||
public void onTextLoaded(CharSequence text) {
|
||||
textView.setText(text);
|
||||
AndroidUtilities.updateViewShow(textLoadingView, false, false, true);
|
||||
AndroidUtilities.updateViewShow(textView, true, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class UsersLayout extends ButtonLayout {
|
||||
|
||||
public AvatarsImageView avatarsImageView;
|
||||
|
|
@ -1275,7 +1336,14 @@ public class Bulletin {
|
|||
avatarsImageView.setAvatarsTextSize(AndroidUtilities.dp(18));
|
||||
addView(avatarsImageView, LayoutHelper.createFrameRelatively(24 + 12 + 12 + 8, 48, Gravity.START | Gravity.CENTER_VERTICAL, 12, 0, 0, 0));
|
||||
|
||||
textView = new LinkSpanDrawable.LinksTextView(context);
|
||||
textView = new LinkSpanDrawable.LinksTextView(context) {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
text = Emoji.replaceEmoji(text, getPaint().getFontMetricsInt(), AndroidUtilities.dp(13), false);
|
||||
super.setText(text, type);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(textView);
|
||||
textView.setTypeface(Typeface.SANS_SERIF);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
textView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
|
|
@ -1439,6 +1507,16 @@ public class Bulletin {
|
|||
return color != null ? color : Theme.getColor(key);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: possibility of loading icon as well
|
||||
public void onLoaded(CharSequence text) {
|
||||
loaded = true;
|
||||
if (layout instanceof LoadingLayout) {
|
||||
((LoadingLayout) layout).onTextLoaded(text);
|
||||
}
|
||||
setCanHide(true);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
public static class EmptyBulletin extends Bulletin {
|
||||
|
|
@ -1577,6 +1655,23 @@ public class Bulletin {
|
|||
},
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
);
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
container.setFitsSystemWindows(true);
|
||||
container.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
applyInsets(insets);
|
||||
v.requestLayout();
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
return WindowInsets.CONSUMED;
|
||||
} else {
|
||||
return insets.consumeSystemWindowInsets();
|
||||
}
|
||||
});
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
container.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||
} else {
|
||||
container.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
|
||||
addDelegate(container, new Delegate() {
|
||||
@Override
|
||||
|
|
@ -1601,7 +1696,7 @@ public class Bulletin {
|
|||
params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND;
|
||||
params.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
params.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
|
||||
params.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
|
||||
}
|
||||
params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
|
|
@ -1615,7 +1710,19 @@ public class Bulletin {
|
|||
params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
}
|
||||
window.setAttributes(params);
|
||||
AndroidUtilities.setLightNavigationBar(window, AndroidUtilities.computePerceivedBrightness(Theme.getColor(Theme.key_windowBackgroundGray)) > 0.721f);
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
private void applyInsets(WindowInsets insets) {
|
||||
if (container != null) {
|
||||
container.setPadding(
|
||||
insets.getSystemWindowInsetLeft(),
|
||||
insets.getSystemWindowInsetTop(),
|
||||
insets.getSystemWindowInsetRight(),
|
||||
insets.getSystemWindowInsetBottom()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.TypedValue;
|
||||
|
|
@ -14,17 +15,20 @@ import android.widget.FrameLayout;
|
|||
|
||||
import androidx.annotation.CheckResult;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaDataController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationsController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
|
@ -151,7 +155,7 @@ public final class BulletinFactory {
|
|||
layout.setAnimation(iconRawId, 36, 36);
|
||||
layout.titleTextView.setText(text);
|
||||
layout.subtitleTextView.setText(subtext);
|
||||
return create(layout, text.length() < 20 ? Bulletin.DURATION_SHORT : Bulletin.DURATION_LONG);
|
||||
return create(layout, (text.length() + subtext.length()) < 20 ? Bulletin.DURATION_SHORT : Bulletin.DURATION_LONG);
|
||||
}
|
||||
|
||||
public Bulletin createSimpleBulletin(int iconRawId, CharSequence text, CharSequence button, Runnable onButtonClick) {
|
||||
|
|
@ -262,6 +266,76 @@ public final class BulletinFactory {
|
|||
return create(layout, Bulletin.DURATION_LONG);
|
||||
}
|
||||
|
||||
public Bulletin createEmojiLoadingBulletin(TLRPC.Document document, CharSequence text, CharSequence button, Runnable onButtonClick) {
|
||||
final Bulletin.LoadingLottieLayout layout = new Bulletin.LoadingLottieLayout(getContext(), resourcesProvider);
|
||||
layout.setAnimation(document, 36, 36);
|
||||
layout.textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
layout.textView.setSingleLine(false);
|
||||
layout.textView.setMaxLines(3);
|
||||
layout.textLoadingView.setText(text);
|
||||
layout.textLoadingView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
layout.textLoadingView.setSingleLine(false);
|
||||
layout.textLoadingView.setMaxLines(3);
|
||||
layout.setButton(new Bulletin.UndoButton(getContext(), true, resourcesProvider).setText(button).setUndoAction(onButtonClick));
|
||||
return create(layout, Bulletin.DURATION_LONG);
|
||||
}
|
||||
|
||||
public Bulletin createContainsEmojiBulletin(TLRPC.Document document, boolean inTopic, Utilities.Callback<TLRPC.InputStickerSet> openSet) {
|
||||
TLRPC.InputStickerSet inputStickerSet = MessageObject.getInputStickerSet(document);
|
||||
if (inputStickerSet == null) {
|
||||
return null;
|
||||
}
|
||||
TLRPC.TL_messages_stickerSet cachedSet = MediaDataController.getInstance(UserConfig.selectedAccount).getStickerSet(inputStickerSet, true);
|
||||
if (cachedSet == null || cachedSet.set == null) {
|
||||
final String loadingPlaceholder = "<{LOADING}>";
|
||||
SpannableStringBuilder stringBuilder;
|
||||
if (inTopic) {
|
||||
stringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatString("TopicContainsEmojiPackSingle", R.string.TopicContainsEmojiPackSingle, loadingPlaceholder)));
|
||||
} else {
|
||||
stringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatString("MessageContainsEmojiPackSingle", R.string.MessageContainsEmojiPackSingle, loadingPlaceholder)));
|
||||
}
|
||||
LoadingSpan loadingSpan = null;
|
||||
int index;
|
||||
if ((index = stringBuilder.toString().indexOf(loadingPlaceholder)) >= 0) {
|
||||
stringBuilder.setSpan(loadingSpan = new LoadingSpan(null, AndroidUtilities.dp(100)), index, index + loadingPlaceholder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
loadingSpan.setColors(
|
||||
ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_undo_infoColor, resourcesProvider), 0x20),
|
||||
ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_undo_infoColor, resourcesProvider), 0x48)
|
||||
);
|
||||
}
|
||||
final long startTime = System.currentTimeMillis();
|
||||
final long minDuration = 750;
|
||||
Bulletin bulletin = createEmojiLoadingBulletin(document, stringBuilder, LocaleController.getString("ViewAction", R.string.ViewAction), () -> openSet.run(inputStickerSet)).show();
|
||||
if (loadingSpan != null && bulletin.getLayout() instanceof Bulletin.LoadingLottieLayout) {
|
||||
loadingSpan.setView(((Bulletin.LoadingLottieLayout) bulletin.getLayout()).textLoadingView);
|
||||
}
|
||||
MediaDataController.getInstance(UserConfig.selectedAccount).getStickerSet(inputStickerSet, false, set -> {
|
||||
CharSequence message;
|
||||
if (set != null && set.set != null) {
|
||||
if (inTopic) {
|
||||
message = AndroidUtilities.replaceTags(LocaleController.formatString("TopicContainsEmojiPackSingle", R.string.TopicContainsEmojiPackSingle, set.set.title));
|
||||
} else {
|
||||
message = AndroidUtilities.replaceTags(LocaleController.formatString("MessageContainsEmojiPackSingle", R.string.MessageContainsEmojiPackSingle, set.set.title));
|
||||
}
|
||||
} else {
|
||||
message = LocaleController.getString("AddEmojiNotFound", R.string.AddEmojiNotFound);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
bulletin.onLoaded(message);
|
||||
}, Math.max(1, minDuration - (System.currentTimeMillis() - startTime)));
|
||||
});
|
||||
return bulletin;
|
||||
} else {
|
||||
CharSequence message;
|
||||
if (inTopic) {
|
||||
message = AndroidUtilities.replaceTags(LocaleController.formatString("TopicContainsEmojiPackSingle", R.string.TopicContainsEmojiPackSingle, cachedSet.set.title));
|
||||
} else {
|
||||
message = AndroidUtilities.replaceTags(LocaleController.formatString("MessageContainsEmojiPackSingle", R.string.MessageContainsEmojiPackSingle, cachedSet.set.title));
|
||||
}
|
||||
return createEmojiBulletin(document, message, LocaleController.getString("ViewAction", R.string.ViewAction), () -> openSet.run(inputStickerSet));
|
||||
}
|
||||
}
|
||||
|
||||
@CheckResult
|
||||
public Bulletin createDownloadBulletin(FileType fileType) {
|
||||
return createDownloadBulletin(fileType, resourcesProvider);
|
||||
|
|
@ -633,9 +707,9 @@ public final class BulletinFactory {
|
|||
}
|
||||
} else {
|
||||
if (messagesCount <= 1) {
|
||||
text = AndroidUtilities.replaceTags(LocaleController.formatString("FwdMessageToChats", R.string.FwdMessageToChats, LocaleController.formatPluralString("Chats", dialogsCount)));
|
||||
text = AndroidUtilities.replaceTags(LocaleController.formatPluralString("FwdMessageToManyChats", dialogsCount));
|
||||
} else {
|
||||
text = AndroidUtilities.replaceTags(LocaleController.formatString("FwdMessagesToChats", R.string.FwdMessagesToChats, LocaleController.formatPluralString("Chats", dialogsCount)));
|
||||
text = AndroidUtilities.replaceTags(LocaleController.formatPluralString("FwdMessagesToManyChats", dialogsCount));
|
||||
}
|
||||
layout.setAnimation(R.raw.forward, 30, 30);
|
||||
hapticDelay = 300;
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.VideoEditedInfo;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.messenger.camera.CameraController;
|
||||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
|
|
@ -2026,13 +2027,13 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
public boolean onTextContextMenuItem(int id) {
|
||||
if (id == android.R.id.paste) {
|
||||
isPaste = true;
|
||||
}
|
||||
|
||||
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = clipboard.getPrimaryClip();
|
||||
if (clipData != null) {
|
||||
if (clipData.getItemCount() == 1 && clipData.getDescription().hasMimeType("image/*")) {
|
||||
editPhoto(clipData.getItemAt(0).getUri(), clipData.getDescription().getMimeType(0));
|
||||
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clipData = clipboard.getPrimaryClip();
|
||||
if (clipData != null) {
|
||||
if (clipData.getItemCount() == 1 && clipData.getDescription().hasMimeType("image/*")) {
|
||||
editPhoto(clipData.getItemAt(0).getUri(), clipData.getDescription().getMimeType(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.onTextContextMenuItem(id);
|
||||
|
|
@ -4344,7 +4345,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
}
|
||||
|
||||
int visibility = getVisibility();
|
||||
if (showKeyboardOnResume && parentFragment.isLastFragment()) {
|
||||
if (showKeyboardOnResume && parentFragment != null && parentFragment.isLastFragment()) {
|
||||
showKeyboardOnResume = false;
|
||||
if (searchingType == 0) {
|
||||
messageEditText.requestFocus();
|
||||
|
|
@ -7150,7 +7151,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
|||
if (button instanceof TLRPC.TL_keyboardButton) {
|
||||
SendMessagesHelper.getInstance(currentAccount).sendMessage(button.text, dialog_id, replyMessageObject, getThreadMessage(), null, false, null, null, null, true, 0, null, false);
|
||||
} else if (button instanceof TLRPC.TL_keyboardButtonUrl) {
|
||||
AlertsCreator.showOpenUrlAlert(parentFragment, button.url, false, true, resourcesProvider);
|
||||
if (Browser.urlMustNotHaveConfirmation(button.url)) {
|
||||
Browser.openUrl(parentActivity, button.url);
|
||||
} else {
|
||||
AlertsCreator.showOpenUrlAlert(parentFragment, button.url, false, true, resourcesProvider);
|
||||
}
|
||||
} else if (button instanceof TLRPC.TL_keyboardButtonRequestPhone) {
|
||||
parentFragment.shareMyContact(2, messageObject);
|
||||
} else if (button instanceof TLRPC.TL_keyboardButtonRequestPoll) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.telegram.ui.Components;
|
|||
import org.telegram.messenger.ChatObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public interface ChatActivityInterface {
|
||||
|
||||
|
|
@ -49,4 +50,6 @@ public interface ChatActivityInterface {
|
|||
SizeNotifierFrameLayout getContentView();
|
||||
|
||||
ActionBar getActionBar();
|
||||
|
||||
Theme.ResourcesProvider getResourceProvider();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
|
|
@ -99,7 +100,14 @@ public class ChatAttachAlertContactsLayout extends ChatAttachAlert.AttachAlertLa
|
|||
avatarImageView.setRoundRadius(AndroidUtilities.dp(23));
|
||||
addView(avatarImageView, LayoutHelper.createFrame(46, 46, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 14, 9, LocaleController.isRTL ? 14 : 0, 0));
|
||||
|
||||
nameTextView = new SimpleTextView(context);
|
||||
nameTextView = new SimpleTextView(context) {
|
||||
@Override
|
||||
public boolean setText(CharSequence value, boolean force) {
|
||||
value = Emoji.replaceEmoji(value, getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
return super.setText(value, force);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(nameTextView);
|
||||
nameTextView.setTextColor(getThemedColor(Theme.key_dialogTextBlack));
|
||||
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
nameTextView.setTextSize(16);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
titleTextView.setLeftDrawableTopPadding(-AndroidUtilities.dp(1.3f));
|
||||
titleTextView.setCanHideRightDrawable(false);
|
||||
titleTextView.setRightDrawableOutside(true);
|
||||
titleTextView.setEllipsizeByGradient(true);
|
||||
titleTextView.setPadding(0, AndroidUtilities.dp(6), 0, AndroidUtilities.dp(12));
|
||||
addView(titleTextView);
|
||||
|
||||
|
|
@ -179,11 +178,6 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
}
|
||||
super.setTranslationY(translationY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
}
|
||||
};
|
||||
subtitleTextView.setEllipsizeByGradient(true);
|
||||
subtitleTextView.setTextColor(getThemedColor(Theme.key_actionBarDefaultSubtitle));
|
||||
|
|
@ -294,7 +288,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
}
|
||||
|
||||
}
|
||||
}, true, resourcesProvider);
|
||||
}, true, 0, resourcesProvider);
|
||||
autoDeletePopupWrapper.updateItems(ttl);
|
||||
|
||||
scrimPopupWindow[0] = new ActionBarPopupWindow(autoDeletePopupWrapper.windowLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
|
||||
|
|
@ -320,7 +314,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
return true;
|
||||
}
|
||||
|
||||
private void openProfile(boolean byAvatar) {
|
||||
public void openProfile(boolean byAvatar) {
|
||||
if (byAvatar && (AndroidUtilities.isTablet() || AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y || !avatarImageView.getImageReceiver().hasNotThumb())) {
|
||||
byAvatar = false;
|
||||
}
|
||||
|
|
@ -723,9 +717,16 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
}
|
||||
setTypingAnimation(false);
|
||||
if (parentFragment.isTopic && chat != null) {
|
||||
int count = parentFragment.getThreadMessage().getRepliesCount();
|
||||
// newSubtitle = LocaleController.formatPluralString("messages", count, count);
|
||||
newSubtitle = LocaleController.formatString("TopicProfileStatus", R.string.TopicProfileStatus, chat.title);
|
||||
TLRPC.TL_forumTopic topic = MessagesController.getInstance(currentAccount).getTopicsController().findTopic(chat.id, parentFragment.getTopicId());
|
||||
int count = 0;
|
||||
if (topic != null) {
|
||||
count = topic.totalMessagesCount - 1;
|
||||
}
|
||||
if (count > 0) {
|
||||
newSubtitle = LocaleController.formatPluralString("messages", count, count);
|
||||
} else {
|
||||
newSubtitle = LocaleController.formatString("TopicProfileStatus", R.string.TopicProfileStatus, chat.title);
|
||||
}
|
||||
} else if (chat != null) {
|
||||
TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
|
||||
if (ChatObject.isChannel(chat)) {
|
||||
|
|
@ -878,18 +879,18 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
avatarDrawable.setInfo(user);
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(null, null, avatarDrawable, user);
|
||||
}
|
||||
} else if (UserObject.isUserSelf(user) && !showSelf) {
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(null, null, avatarDrawable, user);
|
||||
}
|
||||
} else {
|
||||
avatarDrawable.setSmallSize(false);
|
||||
avatarDrawable.setScaleSize(1f);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setForUserOrChat(user, avatarDrawable);
|
||||
}
|
||||
|
|
@ -905,19 +906,19 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent
|
|||
if (user != null) {
|
||||
avatarDrawable.setInfo(user);
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(null, null, avatarDrawable, user);
|
||||
}
|
||||
} else if (UserObject.isUserSelf(user)) {
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(null, null, avatarDrawable, user);
|
||||
}
|
||||
} else {
|
||||
avatarDrawable.setSmallSize(false);
|
||||
avatarDrawable.setScaleSize(1f);
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.imageReceiver.setForUserOrChat(user, avatarDrawable, null, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,13 +26,29 @@ public class ColoredImageSpan extends ReplacementSpan {
|
|||
|
||||
private int size;
|
||||
|
||||
public static final int ALIGN_DEFAULT = 0;
|
||||
public static final int ALIGN_BASELINE = 1;
|
||||
public static final int ALIGN_CENTER = 2;
|
||||
private final int verticalAlignment;
|
||||
|
||||
public ColoredImageSpan(int imageRes) {
|
||||
this(ContextCompat.getDrawable(ApplicationLoader.applicationContext, imageRes));
|
||||
this(imageRes, ALIGN_DEFAULT);
|
||||
}
|
||||
|
||||
public ColoredImageSpan(Drawable drawable) {
|
||||
this(drawable, ALIGN_DEFAULT);
|
||||
}
|
||||
|
||||
public ColoredImageSpan(int imageRes, int verticalAlignment) {
|
||||
this(ContextCompat.getDrawable(ApplicationLoader.applicationContext, imageRes), verticalAlignment);
|
||||
}
|
||||
|
||||
public ColoredImageSpan(Drawable drawable, int verticalAlignment) {
|
||||
this.drawable = drawable;
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
if (drawable != null) {
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
}
|
||||
this.verticalAlignment = verticalAlignment;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
|
|
@ -57,13 +73,23 @@ public class ColoredImageSpan extends ReplacementSpan {
|
|||
drawableColor = color;
|
||||
drawable.setColorFilter(new PorterDuffColorFilter(drawableColor, PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
int lineHeight = bottom - top;
|
||||
int drawableHeight = size != 0 ? size : drawable.getIntrinsicHeight();
|
||||
int padding = (lineHeight - drawableHeight) / 2;
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(x, top + padding + AndroidUtilities.dp(topOffset));
|
||||
drawable.draw(canvas);
|
||||
int transY = bottom - (drawable != null ? drawable.getBounds().bottom : bottom);
|
||||
if (verticalAlignment == ALIGN_BASELINE) {
|
||||
transY -= paint.getFontMetricsInt().descent;
|
||||
} else if (verticalAlignment == ALIGN_CENTER) {
|
||||
transY = top + (bottom - top) / 2 - (drawable != null ? drawable.getBounds().height() / 2 : 0);
|
||||
} else if (verticalAlignment == ALIGN_DEFAULT) {
|
||||
int lineHeight = bottom - top;
|
||||
int drawableHeight = size != 0 ? size : drawable.getIntrinsicHeight();
|
||||
int padding = (lineHeight - drawableHeight) / 2;
|
||||
transY = top + padding + AndroidUtilities.dp(topOffset);
|
||||
}
|
||||
canvas.translate(x, transY);
|
||||
if (drawable != null) {
|
||||
drawable.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@
|
|||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public class CombinedDrawable extends Drawable implements Drawable.Callback {
|
||||
|
|
@ -26,6 +28,7 @@ public class CombinedDrawable extends Drawable implements Drawable.Callback {
|
|||
private int offsetX;
|
||||
private int offsetY;
|
||||
private boolean fullSize;
|
||||
private boolean both;
|
||||
|
||||
public CombinedDrawable(Drawable backgroundDrawable, Drawable iconDrawable, int leftOffset, int topOffset) {
|
||||
background = backgroundDrawable;
|
||||
|
|
@ -42,6 +45,15 @@ public class CombinedDrawable extends Drawable implements Drawable.Callback {
|
|||
iconHeight = height;
|
||||
}
|
||||
|
||||
public CombinedDrawable(Context context, int backgroundDrawableResId, int iconDrawableResId) {
|
||||
background = context.getResources().getDrawable(backgroundDrawableResId);
|
||||
icon = context.getResources().getDrawable(iconDrawableResId);
|
||||
if (icon != null) {
|
||||
icon.setCallback(this);
|
||||
}
|
||||
both = true;
|
||||
}
|
||||
|
||||
public CombinedDrawable(Drawable backgroundDrawable, Drawable iconDrawable) {
|
||||
background = backgroundDrawable;
|
||||
icon = iconDrawable;
|
||||
|
|
@ -75,6 +87,9 @@ public class CombinedDrawable extends Drawable implements Drawable.Callback {
|
|||
@Override
|
||||
public void setColorFilter(ColorFilter colorFilter) {
|
||||
icon.setColorFilter(colorFilter);
|
||||
if (both) {
|
||||
background.setColorFilter(colorFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ public class DialogsItemAnimator extends SimpleItemAnimator {
|
|||
return (!mPendingAdditions.isEmpty()
|
||||
|| !mPendingChanges.isEmpty()
|
||||
|| !mPendingMoves.isEmpty()
|
||||
|| !mPendingRemovals.isEmpty()
|
||||
|| !mPendingChanges.isEmpty()
|
||||
|| !mMoveAnimations.isEmpty()
|
||||
|| !mRemoveAnimations.isEmpty()
|
||||
|| !mAddAnimations.isEmpty()
|
||||
|
|
|
|||
|
|
@ -849,9 +849,9 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
|
|||
addButtonView.setVisibility(View.VISIBLE);
|
||||
removeButtonView.setVisibility(View.GONE);
|
||||
if (canInstallPacks.size() == 1) {
|
||||
addButtonView.setText(LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("EmojiCountButton", canInstallPacks.get(0).documents.size())));
|
||||
addButtonView.setText(LocaleController.formatPluralString("AddManyEmojiCount", canInstallPacks.get(0).documents.size()));
|
||||
} else {
|
||||
addButtonView.setText(LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("EmojiPackCount", canInstallPacks.size())));
|
||||
addButtonView.setText(LocaleController.formatPluralString("AddManyEmojiCount", canInstallPacks.size()));
|
||||
}
|
||||
addButtonView.setOnClickListener(ev -> {
|
||||
final int count = canInstallPacks.size();
|
||||
|
|
@ -881,9 +881,9 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
|
|||
addButtonView.setVisibility(View.GONE);
|
||||
removeButtonView.setVisibility(View.VISIBLE);
|
||||
if (installedPacks.size() == 1) {
|
||||
removeButtonView.setText(LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("EmojiCountButton", installedPacks.get(0).documents.size())));
|
||||
removeButtonView.setText(LocaleController.formatPluralString("RemoveManyEmojiCount", installedPacks.get(0).documents.size()));
|
||||
} else {
|
||||
removeButtonView.setText(LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("EmojiPackCount", installedPacks.size())));
|
||||
removeButtonView.setText(LocaleController.formatPluralString("RemoveManyEmojiPacksCount", installedPacks.size()));
|
||||
}
|
||||
|
||||
removeButtonView.setOnClickListener(ev -> {
|
||||
|
|
@ -1500,8 +1500,8 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
|
|||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.groupStickersDidLoad);
|
||||
final boolean[] failed = new boolean[1];
|
||||
for (int i = 0; i < data.length; ++i) {
|
||||
TLRPC.TL_messages_stickerSet stickerSet = MediaDataController.getInstance(currentAccount).getStickerSet(inputStickerSets.get(i), false, () -> {
|
||||
if (!failed[0]) {
|
||||
TLRPC.TL_messages_stickerSet stickerSet = MediaDataController.getInstance(currentAccount).getStickerSet(inputStickerSets.get(i), false, (set) -> {
|
||||
if (set == null && !failed[0]) {
|
||||
failed[0] = true;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
dismiss();
|
||||
|
|
|
|||
|
|
@ -188,12 +188,14 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
|
|||
protected void dispatchDraw(Canvas canvas) {
|
||||
for (Map.Entry<View, Rect> entry : removingViews.entrySet()) {
|
||||
View view = entry.getKey();
|
||||
Rect bounds = entry.getValue();
|
||||
canvas.save();
|
||||
canvas.translate(bounds.left, bounds.top);
|
||||
canvas.scale(view.getScaleX(), view.getScaleY(), bounds.width() / 2f, bounds.height() / 2f);
|
||||
view.draw(canvas);
|
||||
canvas.restore();
|
||||
if (view != null) {
|
||||
Rect bounds = entry.getValue();
|
||||
canvas.save();
|
||||
canvas.translate(bounds.left, bounds.top);
|
||||
canvas.scale(view.getScaleX(), view.getScaleY(), bounds.width() / 2f, bounds.height() / 2f);
|
||||
view.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
int selectFrom = (int) Math.floor(selectT), selectTo = (int) Math.ceil(selectT);
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ import org.telegram.tgnet.TLRPC;
|
|||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.BottomSheet;
|
||||
import org.telegram.ui.ActionBar.SimpleTextView;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Cells.ContextLinkCell;
|
||||
import org.telegram.ui.Cells.EmptyCell;
|
||||
|
|
@ -1091,11 +1092,10 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (isPressed() && pressedProgress != 1f) {
|
||||
pressedProgress += 16f / 100f;
|
||||
pressedProgress += (float) Math.min(40, 1000f / AndroidUtilities.screenRefreshRate) / 100f;
|
||||
pressedProgress = Utilities.clamp(pressedProgress, 1f, 0);
|
||||
invalidate();
|
||||
}
|
||||
|
|
@ -3271,7 +3271,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
installFadeAway = ValueAnimator.ofFloat(addButtonView.getAlpha(), installed ? .6f : 1f);
|
||||
addButtonView.setAlpha(addButtonView.getAlpha());
|
||||
installFadeAway.addUpdateListener(anm -> {
|
||||
addButtonView.setAlpha((float) anm.getAnimatedValue());
|
||||
if (addButtonView != null) {
|
||||
addButtonView.setAlpha((float) anm.getAnimatedValue());
|
||||
}
|
||||
});
|
||||
installFadeAway.setDuration(450);
|
||||
installFadeAway.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
|
|
@ -3300,8 +3302,12 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
lockAnimator = ValueAnimator.ofFloat(lockT, show ? 1f : 0f);
|
||||
lockAnimator.addUpdateListener(anm -> {
|
||||
lockT = (float) anm.getAnimatedValue();
|
||||
addButtonView.setAlpha(1f - lockT);
|
||||
premiumButtonView.setAlpha(lockT);
|
||||
if (addButtonView != null) {
|
||||
addButtonView.setAlpha(1f - lockT);
|
||||
}
|
||||
if (premiumButtonView != null) {
|
||||
premiumButtonView.setAlpha(lockT);
|
||||
}
|
||||
});
|
||||
lockAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
|
@ -3328,7 +3334,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
private class EmojiPackHeader extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
RLottieImageView lockView;
|
||||
TextView headerView;
|
||||
SimpleTextView headerView;
|
||||
|
||||
FrameLayout buttonsView;
|
||||
TextView addButtonView;
|
||||
|
|
@ -3348,8 +3354,8 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
lockView.setColorFilter(getThemedColor(Theme.key_chat_emojiPanelStickerSetName));
|
||||
addView(lockView, LayoutHelper.createFrameRelatively(20, 20, Gravity.START, 10, 15, 0, 0));
|
||||
|
||||
headerView = new TextView(context);
|
||||
headerView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
||||
headerView = new SimpleTextView(context);
|
||||
headerView.setTextSize(15);
|
||||
headerView.setTextColor(getThemedColor(Theme.key_chat_emojiPanelStickerSetName));
|
||||
headerView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
headerView.setOnClickListener(e -> {
|
||||
|
|
@ -3357,7 +3363,8 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
openEmojiPackAlert(this.pack.set);
|
||||
}
|
||||
});
|
||||
addView(headerView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.START, 15, 15, 52, 0));
|
||||
headerView.setEllipsizeByGradient(true);
|
||||
addView(headerView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.START, 15, 15, 0, 0));
|
||||
|
||||
buttonsView = new FrameLayout(context);
|
||||
buttonsView.setPadding(AndroidUtilities.dp(11), AndroidUtilities.dp(11), AndroidUtilities.dp(11), 0);
|
||||
|
|
@ -3493,6 +3500,12 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
headerView.setRightPadding(buttonsView.getWidth() + AndroidUtilities.dp(11));
|
||||
}
|
||||
|
||||
public void setStickerSet(EmojiPack pack, boolean divider) {
|
||||
if (pack == null) {
|
||||
return;
|
||||
|
|
@ -6381,7 +6394,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
|
|||
coloredCode = null;
|
||||
for (int a = 0; a < EmojiData.dataColored.length; a++) {
|
||||
int size = EmojiData.dataColored[a].length + 1;
|
||||
if (position < count + size) {
|
||||
if (position - count - 1 >= 0 && position < count + size) {
|
||||
coloredCode = code = EmojiData.dataColored[a][position - count - 1];
|
||||
String color = Emoji.emojiColor.get(code);
|
||||
if (color != null) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ public class FlickerLoadingView extends View {
|
|||
public final static int LIMIT_REACHED_LINKS = 22;
|
||||
public final static int REACTED_TYPE_WITH_EMOJI_HINT = 23;
|
||||
public static final int TOPIC_CELL_TYPE = 24;
|
||||
public static final int DIALOG_CACHE_CONTROL = 25;
|
||||
|
||||
private int gradientWidth;
|
||||
private LinearGradient gradient;
|
||||
|
|
@ -63,8 +64,8 @@ public class FlickerLoadingView extends View {
|
|||
private int paddingTop;
|
||||
private int paddingLeft;
|
||||
|
||||
private String colorKey1 = Theme.key_windowBackgroundWhite;
|
||||
private String colorKey2 = Theme.key_windowBackgroundGray;
|
||||
private String colorKey1 = Theme.key_actionBarDefaultSubmenuBackground;
|
||||
private String colorKey2 = Theme.key_listSelector;
|
||||
private String colorKey3;
|
||||
private int itemsCount = 1;
|
||||
private final Theme.ResourcesProvider resourcesProvider;
|
||||
|
|
@ -553,8 +554,8 @@ public class FlickerLoadingView extends View {
|
|||
|
||||
if (backgroundPaint == null) {
|
||||
backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
backgroundPaint.setColor(Theme.getColor(Theme.key_dialogBackground));
|
||||
}
|
||||
backgroundPaint.setColor(Theme.getColor(Theme.key_dialogBackground, resourcesProvider));
|
||||
|
||||
AndroidUtilities.rectTmp.set(x + AndroidUtilities.dp(4), AndroidUtilities.dp(4), x + itemWidth - AndroidUtilities.dp(4), getMeasuredHeight() - AndroidUtilities.dp(4));
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(6), AndroidUtilities.dp(6), paint);
|
||||
|
|
@ -651,7 +652,7 @@ public class FlickerLoadingView extends View {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} else if (viewType == LIMIT_REACHED_LINKS) {
|
||||
} else if (viewType == LIMIT_REACHED_LINKS) {
|
||||
int k = 0;
|
||||
while (h <= getMeasuredHeight()) {
|
||||
int r = AndroidUtilities.dp(48) >> 1;
|
||||
|
|
@ -665,6 +666,22 @@ public class FlickerLoadingView extends View {
|
|||
checkRtl(rectF);
|
||||
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
|
||||
|
||||
h += getCellHeight(getMeasuredWidth());
|
||||
k++;
|
||||
if (isSingleCell && k >= itemsCount) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (viewType == DIALOG_CACHE_CONTROL) {
|
||||
int k = 0;
|
||||
while (h <= getMeasuredHeight()) {
|
||||
int r = AndroidUtilities.dp(38) >> 1;
|
||||
canvas.drawCircle(AndroidUtilities.dp(17) + r, h + AndroidUtilities.dp(6) + r, r, paint);
|
||||
|
||||
rectF.set(AndroidUtilities.dp(76), h + AndroidUtilities.dp(21), AndroidUtilities.dp(220), h + AndroidUtilities.dp(29));
|
||||
// checkRtl(rectF);
|
||||
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
|
||||
|
||||
h += getCellHeight(getMeasuredWidth());
|
||||
k++;
|
||||
if (isSingleCell && k >= itemsCount) {
|
||||
|
|
@ -788,6 +805,8 @@ public class FlickerLoadingView extends View {
|
|||
return AndroidUtilities.dp(58);
|
||||
case LIMIT_REACHED_LINKS:
|
||||
return AndroidUtilities.dp(60);
|
||||
case DIALOG_CACHE_CONTROL:
|
||||
return AndroidUtilities.dp(51);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,26 @@
|
|||
package org.telegram.ui.Components.Forum;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
|
|
@ -20,6 +32,7 @@ import org.telegram.messenger.UserConfig;
|
|||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ActionBar.INavigationLayout;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AnimatedEmojiDrawable;
|
||||
import org.telegram.ui.Components.AnimatedEmojiSpan;
|
||||
|
|
@ -35,13 +48,16 @@ public class ForumUtilities {
|
|||
|
||||
|
||||
public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic) {
|
||||
setTopicIcon(backupImageView, forumTopic, false);
|
||||
setTopicIcon(backupImageView, forumTopic, false, null);
|
||||
}
|
||||
public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic, boolean largeIcon) {
|
||||
public static void setTopicIcon(BackupImageView backupImageView, TLRPC.TL_forumTopic forumTopic, boolean largeIcon, Theme.ResourcesProvider resourcesProvider) {
|
||||
if (forumTopic == null || backupImageView == null) {
|
||||
return;
|
||||
}
|
||||
if (forumTopic.icon_emoji_id != 0) {
|
||||
if (forumTopic.id == 1) {
|
||||
backupImageView.setAnimatedEmojiDrawable(null);
|
||||
backupImageView.setImageDrawable(createGeneralTopicDrawable(backupImageView.getContext(), 0.75f, Theme.getColor(Theme.key_actionBarDefaultIcon, resourcesProvider)));
|
||||
} else if (forumTopic.icon_emoji_id != 0) {
|
||||
backupImageView.setImageDrawable(null);
|
||||
if (backupImageView.animatedEmojiDrawable == null || forumTopic.icon_emoji_id != backupImageView.animatedEmojiDrawable.getDocumentId()) {
|
||||
backupImageView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(largeIcon ? AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC_LARGE : AnimatedEmojiDrawable.CACHE_TYPE_FORUM_TOPIC, UserConfig.selectedAccount, forumTopic.icon_emoji_id));
|
||||
|
|
@ -52,6 +68,75 @@ public class ForumUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
public static Drawable createGeneralTopicDrawable(Context context, float scale, Theme.ResourcesProvider resourcesProvider) {
|
||||
return createGeneralTopicDrawable(context, scale, Theme.getColor(Theme.key_chat_inMenu, resourcesProvider));
|
||||
}
|
||||
|
||||
public static GeneralTopicDrawable createGeneralTopicDrawable(Context context, float scale, int color) {
|
||||
if (context == null) {
|
||||
return null;
|
||||
}
|
||||
return new GeneralTopicDrawable(context, scale, color);
|
||||
}
|
||||
|
||||
public static class GeneralTopicDrawable extends Drawable {
|
||||
|
||||
Drawable icon;
|
||||
float scale;
|
||||
int color;
|
||||
|
||||
public GeneralTopicDrawable(Context context) {
|
||||
this(context, 1f);
|
||||
}
|
||||
|
||||
public GeneralTopicDrawable(Context context, float scale) {
|
||||
this.icon = context.getResources().getDrawable(R.drawable.msg_filled_general).mutate();
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
public GeneralTopicDrawable(Context context, float scale, int color) {
|
||||
this.icon = context.getResources().getDrawable(R.drawable.msg_filled_general).mutate();
|
||||
this.scale = scale;
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
Rect bounds = getBounds();
|
||||
if (scale == 1) {
|
||||
icon.setBounds(bounds);
|
||||
} else {
|
||||
icon.setBounds(
|
||||
(int) (bounds.centerX() - bounds.width() / 2f * scale),
|
||||
(int) (bounds.centerY() - bounds.height() / 2f * scale),
|
||||
(int) (bounds.centerX() + bounds.width() / 2f * scale),
|
||||
(int) (bounds.centerY() + bounds.height() / 2f * scale)
|
||||
);
|
||||
}
|
||||
icon.draw(canvas);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
if (this.color != color) {
|
||||
setColorFilter(new PorterDuffColorFilter(this.color = color, PorterDuff.Mode.MULTIPLY));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int i) {
|
||||
icon.setAlpha(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
icon.setColorFilter(colorFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSPARENT;
|
||||
}
|
||||
}
|
||||
|
||||
public static Drawable createTopicDrawable(TLRPC.TL_forumTopic topic) {
|
||||
return topic == null ? null : createTopicDrawable(topic.title, topic.icon_color);
|
||||
|
|
@ -62,7 +147,7 @@ public class ForumUtilities {
|
|||
}
|
||||
|
||||
public static Drawable createTopicDrawable(String text, int color) {
|
||||
ForumBubbleDrawable forumBubbleDrawable = new ForumBubbleDrawable(color);
|
||||
Drawable forumBubbleDrawable = new ForumBubbleDrawable(color);
|
||||
LetterDrawable letterDrawable = new LetterDrawable(null, LetterDrawable.STYLE_TOPIC_DRAWABLE);
|
||||
String title = text.trim().toUpperCase();
|
||||
letterDrawable.setTitle(title.length() >= 1 ? title.substring(0, 1) : "");
|
||||
|
|
@ -122,11 +207,21 @@ public class ForumUtilities {
|
|||
return getTopicSpannedName(topic, paint, null);
|
||||
}
|
||||
|
||||
public static CharSequence getTopicSpannedName(TLRPC.ForumTopic topic, Paint paint, ForumBubbleDrawable[] drawableToSet) {
|
||||
public static CharSequence getTopicSpannedName(TLRPC.ForumTopic topic, Paint paint, Drawable[] drawableToSet) {
|
||||
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
if (topic instanceof TLRPC.TL_forumTopic) {
|
||||
TLRPC.TL_forumTopic forumTopic = (TLRPC.TL_forumTopic) topic;
|
||||
if (forumTopic.icon_emoji_id != 0) {
|
||||
if (forumTopic.id == 1) {
|
||||
try {
|
||||
Drawable drawable = createGeneralTopicDrawable(ApplicationLoader.applicationContext, 1f, paint == null ? Theme.getColor(Theme.key_chat_inMenu) : paint.getColor());
|
||||
drawable.setBounds(0, 0, paint == null ? AndroidUtilities.dp(14) : (int) (paint.getTextSize()), paint == null ? AndroidUtilities.dp(14) : (int) (paint.getTextSize()));
|
||||
sb.append(" ");
|
||||
if (drawableToSet != null) {
|
||||
drawableToSet[0] = drawable;
|
||||
}
|
||||
sb.setSpan(new ImageSpan(drawable, DynamicDrawableSpan.ALIGN_CENTER), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} catch (Exception e) {}
|
||||
} else if (forumTopic.icon_emoji_id != 0) {
|
||||
sb.append(" ");
|
||||
AnimatedEmojiSpan span;
|
||||
sb.setSpan(span = new AnimatedEmojiSpan(forumTopic.icon_emoji_id, .95f, paint == null ? null : paint.getFontMetricsInt()), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
|
|
@ -136,7 +231,7 @@ public class ForumUtilities {
|
|||
sb.append(" ");
|
||||
Drawable drawable = ForumUtilities.createTopicDrawable(forumTopic);
|
||||
if (drawableToSet != null) {
|
||||
drawableToSet[0] = (ForumBubbleDrawable) ((CombinedDrawable) drawable).getBackgroundDrawable();
|
||||
drawableToSet[0] = ((CombinedDrawable) drawable).getBackgroundDrawable();
|
||||
}
|
||||
drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * 0.65f), (int) (drawable.getIntrinsicHeight() * 0.65f));
|
||||
if (drawable instanceof CombinedDrawable && ((CombinedDrawable) drawable).getIcon() instanceof LetterDrawable) {
|
||||
|
|
@ -230,9 +325,9 @@ public class ForumUtilities {
|
|||
if (messageObject.getDialogId() > 0) {
|
||||
return;
|
||||
}
|
||||
TLRPC.TL_forumTopic topic = MessagesController.getInstance(messageObject.currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), MessageObject.getTopicId(messageObject.messageOwner));
|
||||
if (topic != null && messageObject.topicIconDrawable[0] != null) {
|
||||
messageObject.topicIconDrawable[0].setColor(topic.icon_color);
|
||||
TLRPC.TL_forumTopic topic = MessagesController.getInstance(messageObject.currentAccount).getTopicsController().findTopic(-messageObject.getDialogId(), MessageObject.getTopicId(messageObject.messageOwner, true));
|
||||
if (topic != null && messageObject.topicIconDrawable[0] instanceof ForumBubbleDrawable) {
|
||||
((ForumBubbleDrawable) messageObject.topicIconDrawable[0]).setColor(topic.icon_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ public class MessageTopicButton {
|
|||
private int topicWidth;
|
||||
private int topicHeight;
|
||||
private Paint topicPaint;
|
||||
private boolean isGeneralTopic;
|
||||
private Path topicPath;
|
||||
private boolean topicArrowDrawableVisible;
|
||||
private Drawable topicArrowDrawable;
|
||||
private Drawable topicSelectorDrawable;
|
||||
private Drawable topicIconDrawable;
|
||||
|
|
@ -53,6 +55,7 @@ public class MessageTopicButton {
|
|||
private AnimatedColor topicBackgroundColorAnimated, topicNameColorAnimated;
|
||||
private boolean topicIconWaiting;
|
||||
private StaticLayout topicNameLayout;
|
||||
private float topicNameLeft;
|
||||
private RectF topicHitRect;
|
||||
private boolean topicPressed;
|
||||
private MessageObject lastMessageObject;
|
||||
|
|
@ -72,12 +75,13 @@ public class MessageTopicButton {
|
|||
|
||||
public int set(ChatMessageCell cell, MessageObject messageObject, TLRPC.TL_forumTopic topic, int maxWidth) {
|
||||
lastMessageObject = messageObject;
|
||||
isGeneralTopic = topic == null || topic.id == 1;
|
||||
if (cell == null || messageObject == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iconsz = AndroidUtilities.dp(7) + (int) Theme.chat_topicTextPaint.getTextSize();
|
||||
float padleft = AndroidUtilities.dp(10) + iconsz;
|
||||
float padleft = AndroidUtilities.dp(isGeneralTopic ? 6 : 10) + iconsz;
|
||||
float padright1 = Theme.chat_topicTextPaint.getTextSize() - AndroidUtilities.dp(8);
|
||||
float padright = AndroidUtilities.dp(5) + Theme.chat_topicTextPaint.getTextSize();
|
||||
maxWidth -= padleft + padright;
|
||||
|
|
@ -96,7 +100,10 @@ public class MessageTopicButton {
|
|||
topicPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
int iconColor;
|
||||
if (topic.icon_emoji_id != 0) {
|
||||
if (topic.id == 1) {
|
||||
iconColor = getThemedColor(messageObject != null && messageObject.isOutOwner() ? Theme.key_chat_outReactionButtonText : Theme.key_chat_inReactionButtonText);
|
||||
topicIconDrawable = ForumUtilities.createGeneralTopicDrawable(context, .65f, iconColor);
|
||||
} else if (topic.icon_emoji_id != 0) {
|
||||
if (!(topicIconDrawable instanceof AnimatedEmojiDrawable) || topic.icon_emoji_id != ((AnimatedEmojiDrawable) topicIconDrawable).getDocumentId()) {
|
||||
if (topicIconDrawable instanceof AnimatedEmojiDrawable) {
|
||||
((AnimatedEmojiDrawable) topicIconDrawable).removeView(cell::invalidateOutbounds);
|
||||
|
|
@ -133,14 +140,16 @@ public class MessageTopicButton {
|
|||
int arrowsz = Math.max(1, (int) Theme.chat_topicTextPaint.getTextSize() + AndroidUtilities.dp(0));
|
||||
if (lineCount == 2) {
|
||||
topicHeight = AndroidUtilities.dp(15) + 2 * ((int) Theme.chat_topicTextPaint.getTextSize());
|
||||
float l1w = topicNameLayout.getLineWidth(0) - topicNameLayout.getLineLeft(0);
|
||||
float l2w = topicNameLayout.getLineWidth(1) - topicNameLayout.getLineLeft(1);
|
||||
float l1w = Math.abs(topicNameLayout.getLineRight(0) - topicNameLayout.getLineLeft(0));
|
||||
float l2w = Math.abs(topicNameLayout.getLineRight(1) - topicNameLayout.getLineLeft(1));
|
||||
topicNameLeft = Math.min(topicNameLayout.getLineLeft(0), topicNameLayout.getLineLeft(1));
|
||||
boolean isRTL = topicNameLeft != 0;
|
||||
textWidth = Math.max(l1w, l2w);
|
||||
float r = (AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize()) / 1.5f;
|
||||
boolean same = false;
|
||||
AndroidUtilities.rectTmp.set(0, 0, R, R);
|
||||
topicPath.arcTo(AndroidUtilities.rectTmp, 180, 90);
|
||||
if (Math.abs(l1w - l2w) <= (padright - padright1)) {
|
||||
if (Math.abs(l1w - l2w) <= (padright - padright1) || isRTL) {
|
||||
l1w = Math.max(l1w, l2w + (padright - padright1));
|
||||
l2w = Math.max(l2w, l1w - (padright - padright1));
|
||||
same = true;
|
||||
|
|
@ -163,6 +172,7 @@ public class MessageTopicButton {
|
|||
topicPath.arcTo(AndroidUtilities.rectTmp, 270, 90);
|
||||
}
|
||||
}
|
||||
topicArrowDrawableVisible = !isRTL;
|
||||
topicArrowDrawable.setBounds(
|
||||
(int) (padleft + padright + AndroidUtilities.dp(-4) + l2w - arrowsz),
|
||||
(int) ((topicHeight - AndroidUtilities.dp(11) - Theme.chat_topicTextPaint.getTextSize() + topicHeight) / 2f - arrowsz / 2),
|
||||
|
|
@ -176,8 +186,10 @@ public class MessageTopicButton {
|
|||
topicPath.close();
|
||||
} else if (lineCount == 1) {
|
||||
topicHeight = AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize();
|
||||
textWidth = topicNameLayout.getLineWidth(0) - topicNameLayout.getLineLeft(0);
|
||||
textWidth = Math.abs(topicNameLayout.getLineRight(0) - topicNameLayout.getLineLeft(0));
|
||||
topicNameLeft = topicNameLayout.getLineLeft(0);
|
||||
AndroidUtilities.rectTmp.set(0, 0, padleft + padright + textWidth, topicHeight);
|
||||
topicArrowDrawableVisible = true;
|
||||
topicArrowDrawable.setBounds(
|
||||
(int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz),
|
||||
(int) (topicHeight / 2f - arrowsz / 2),
|
||||
|
|
@ -185,12 +197,27 @@ public class MessageTopicButton {
|
|||
(int) (topicHeight / 2f + arrowsz / 2)
|
||||
);
|
||||
topicPath.addRoundRect(AndroidUtilities.rectTmp, R, R, Path.Direction.CW);
|
||||
} else if (lineCount == 0) {
|
||||
topicHeight = AndroidUtilities.dp(11) + (int) Theme.chat_topicTextPaint.getTextSize();
|
||||
textWidth = 0;
|
||||
topicNameLeft = 0;
|
||||
topicArrowDrawableVisible = true;
|
||||
topicArrowDrawable.setBounds(
|
||||
(int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth - arrowsz),
|
||||
(int) (topicHeight / 2f - arrowsz / 2),
|
||||
(int) (padleft + padright + AndroidUtilities.dp(-4) + textWidth),
|
||||
(int) (topicHeight / 2f + arrowsz / 2)
|
||||
);
|
||||
AndroidUtilities.rectTmp.set(0, 0, padleft + padright + textWidth, topicHeight);
|
||||
topicPath.addRoundRect(AndroidUtilities.rectTmp, R, R, Path.Direction.CW);
|
||||
}
|
||||
topicWidth = (int) (padleft + padright -AndroidUtilities.dp(1) + textWidth);
|
||||
int occupingHeight = 0;
|
||||
if (!messageObject.isAnyKindOfSticker() && messageObject.type != MessageObject.TYPE_ROUND_VIDEO) {
|
||||
if (!messageObject.isAnyKindOfSticker() && messageObject.type != MessageObject.TYPE_ROUND_VIDEO || messageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
occupingHeight += AndroidUtilities.dp(6) + topicHeight;
|
||||
if (messageObject.type != MessageObject.TYPE_TEXT) {
|
||||
if (messageObject.type == MessageObject.TYPE_EMOJIS) {
|
||||
occupingHeight += AndroidUtilities.dp(16);
|
||||
} else if (messageObject.type != MessageObject.TYPE_TEXT) {
|
||||
occupingHeight += AndroidUtilities.dp(9);
|
||||
}
|
||||
}
|
||||
|
|
@ -380,7 +407,7 @@ public class MessageTopicButton {
|
|||
int nameColor = topicNameColor;
|
||||
if (topicNameLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(17) + Theme.chat_topicTextPaint.getTextSize(), AndroidUtilities.dp(4.5f));
|
||||
canvas.translate(AndroidUtilities.dp(isGeneralTopic ? 13 : 17) + Theme.chat_topicTextPaint.getTextSize() - topicNameLeft, AndroidUtilities.dp(4.5f));
|
||||
if (topicNameColorAnimated != null) {
|
||||
Theme.chat_topicTextPaint.setColor(nameColor = topicNameColorAnimated.set(topicNameColor));
|
||||
} else {
|
||||
|
|
@ -390,7 +417,7 @@ public class MessageTopicButton {
|
|||
topicNameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
if (topicArrowDrawable != null) {
|
||||
if (topicArrowDrawable != null && topicArrowDrawableVisible) {
|
||||
int arrowColor = ColorUtils.setAlphaComponent(nameColor, 140);
|
||||
if (topicArrowColor != arrowColor) {
|
||||
topicArrowDrawable.setColorFilter(new PorterDuffColorFilter(topicArrowColor = arrowColor, PorterDuff.Mode.MULTIPLY));
|
||||
|
|
|
|||
|
|
@ -24,18 +24,20 @@ import android.text.TextUtils;
|
|||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.ImageReceiver;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
public class GroupCreateSpan extends View {
|
||||
|
||||
private long uid;
|
||||
|
|
@ -76,12 +78,12 @@ public class GroupCreateSpan extends View {
|
|||
Object imageParent;
|
||||
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
|
||||
avatarDrawable.setTextSize(AndroidUtilities.dp(20));
|
||||
if (object instanceof String) {
|
||||
imageLocation = null;
|
||||
imageParent = null;
|
||||
String str = (String) object;
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
switch (str) {
|
||||
case "contacts":
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_FILTER_CONTACTS);
|
||||
|
|
@ -130,13 +132,13 @@ public class GroupCreateSpan extends View {
|
|||
uid = user.id;
|
||||
if (UserObject.isReplyUser(user)) {
|
||||
firstName = LocaleController.getString("RepliesTitle", R.string.RepliesTitle);
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_REPLIES);
|
||||
imageLocation = null;
|
||||
imageParent = null;
|
||||
} else if (UserObject.isUserSelf(user)) {
|
||||
firstName = LocaleController.getString("SavedMessages", R.string.SavedMessages);
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
imageLocation = null;
|
||||
imageParent = null;
|
||||
|
|
@ -178,7 +180,10 @@ public class GroupCreateSpan extends View {
|
|||
maxNameWidth = (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(32 + 18 + 57 * 2)) / 2;
|
||||
}
|
||||
|
||||
CharSequence name = TextUtils.ellipsize(firstName.replace('\n', ' '), textPaint, maxNameWidth, TextUtils.TruncateAt.END);
|
||||
firstName = firstName.replace('\n', ' ');
|
||||
CharSequence name = firstName;
|
||||
name = Emoji.replaceEmoji(name, textPaint.getFontMetricsInt(), AndroidUtilities.dp(12), false);
|
||||
name = TextUtils.ellipsize(name, textPaint, maxNameWidth, TextUtils.TruncateAt.END);
|
||||
nameLayout = new StaticLayout(name, textPaint, 1000, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
textWidth = (int) Math.ceil(nameLayout.getLineWidth(0));
|
||||
|
|
@ -186,6 +191,8 @@ public class GroupCreateSpan extends View {
|
|||
}
|
||||
imageReceiver.setImage(imageLocation, "50_50", avatarDrawable, 0, null, imageParent, 1);
|
||||
updateColors();
|
||||
|
||||
NotificationCenter.listenEmojiLoading(this);
|
||||
}
|
||||
|
||||
public void updateColors() {
|
||||
|
|
|
|||
|
|
@ -298,11 +298,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase implements Notifica
|
|||
dismiss();
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
if (selectedContacts.size() == 1) {
|
||||
builder.setTitle(LocaleController.getString("AddOneMemberAlertTitle", R.string.AddOneMemberAlertTitle));
|
||||
} else {
|
||||
builder.setTitle(LocaleController.formatString("AddMembersAlertTitle", R.string.AddMembersAlertTitle, LocaleController.formatPluralString("Members", selectedContacts.size())));
|
||||
}
|
||||
builder.setTitle(LocaleController.formatPluralString("AddManyMembersAlertTitle", selectedContacts.size()));
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int a = 0; a < selectedContacts.size(); a++) {
|
||||
long uid = selectedContacts.keyAt(a);
|
||||
|
|
@ -317,7 +313,7 @@ public class InviteMembersBottomSheet extends UsersAlertBase implements Notifica
|
|||
}
|
||||
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chatId);
|
||||
if (selectedContacts.size() > 5) {
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatString("AddMembersAlertNamesText", R.string.AddMembersAlertNamesText, LocaleController.formatPluralString("Members", selectedContacts.size()), chat.title)));
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(AndroidUtilities.replaceTags(LocaleController.formatPluralString("AddManyMembersAlertNamesText", selectedContacts.size(), chat.title)));
|
||||
String countString = String.format("%d", selectedContacts.size());
|
||||
int index = TextUtils.indexOf(spannableStringBuilder, countString);
|
||||
if (index >= 0) {
|
||||
|
|
|
|||
|
|
@ -10,20 +10,17 @@ package org.telegram.ui.Components;
|
|||
|
||||
import android.graphics.CornerPathEffect;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.text.Layout;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class LinkPath extends Path {
|
||||
|
||||
private Layout currentLayout;
|
||||
private int currentLine;
|
||||
private float lastTop = -1;
|
||||
private float heightOffset;
|
||||
private float xOffset, yOffset;
|
||||
private boolean useRoundRect;
|
||||
private boolean allowReset = true;
|
||||
private int baselineShift;
|
||||
|
|
@ -52,10 +49,23 @@ public class LinkPath extends Path {
|
|||
}
|
||||
|
||||
public void setCurrentLayout(Layout layout, int start, float yOffset) {
|
||||
setCurrentLayout(layout, start, 0, yOffset);
|
||||
}
|
||||
|
||||
public void setCurrentLayout(Layout layout, int start, float xOffset, float yOffset) {
|
||||
if (layout == null) {
|
||||
currentLayout = null;
|
||||
currentLine = 0;
|
||||
lastTop = -1;
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
return;
|
||||
}
|
||||
currentLayout = layout;
|
||||
currentLine = layout.getLineForOffset(start);
|
||||
lastTop = -1;
|
||||
heightOffset = yOffset;
|
||||
this.xOffset = xOffset;
|
||||
this.yOffset = yOffset;
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
int lineCount = layout.getLineCount();
|
||||
if (lineCount > 0) {
|
||||
|
|
@ -82,48 +92,58 @@ public class LinkPath extends Path {
|
|||
|
||||
@Override
|
||||
public void addRect(float left, float top, float right, float bottom, Direction dir) {
|
||||
top += heightOffset;
|
||||
bottom += heightOffset;
|
||||
if (lastTop == -1) {
|
||||
lastTop = top;
|
||||
} else if (lastTop != top) {
|
||||
lastTop = top;
|
||||
currentLine++;
|
||||
}
|
||||
float lineRight = currentLayout.getLineRight(currentLine);
|
||||
float lineLeft = currentLayout.getLineLeft(currentLine);
|
||||
if (left >= lineRight || left <= lineLeft && right <= lineLeft) {
|
||||
if (currentLayout == null) {
|
||||
super.addRect(left, top, right, bottom, dir);
|
||||
return;
|
||||
}
|
||||
if (right > lineRight) {
|
||||
right = lineRight;
|
||||
}
|
||||
if (left < lineLeft) {
|
||||
left = lineLeft;
|
||||
}
|
||||
float y = top;
|
||||
float y2;
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
y2 = bottom;
|
||||
if (bottom - top > lineHeight) {
|
||||
y2 = heightOffset + (bottom != currentLayout.getHeight() ? (currentLayout.getLineBottom(currentLine) - currentLayout.getSpacingAdd()) : 0);
|
||||
try {
|
||||
top += yOffset;
|
||||
bottom += yOffset;
|
||||
if (lastTop == -1) {
|
||||
lastTop = top;
|
||||
} else if (lastTop != top) {
|
||||
lastTop = top;
|
||||
currentLine++;
|
||||
}
|
||||
} else {
|
||||
y2 = bottom - (bottom != currentLayout.getHeight() ? currentLayout.getSpacingAdd() : 0);
|
||||
}
|
||||
if (baselineShift < 0) {
|
||||
y2 += baselineShift;
|
||||
} else if (baselineShift > 0) {
|
||||
y += baselineShift;
|
||||
}
|
||||
if (useRoundRect) {
|
||||
float lineRight = currentLayout.getLineRight(currentLine);
|
||||
float lineLeft = currentLayout.getLineLeft(currentLine);
|
||||
if (left >= lineRight || left <= lineLeft && right <= lineLeft) {
|
||||
return;
|
||||
}
|
||||
if (right > lineRight) {
|
||||
right = lineRight;
|
||||
}
|
||||
if (left < lineLeft) {
|
||||
left = lineLeft;
|
||||
}
|
||||
left += xOffset;
|
||||
right += xOffset;
|
||||
float y = top;
|
||||
float y2;
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
y2 = bottom;
|
||||
if (bottom - top > lineHeight) {
|
||||
y2 = yOffset + (bottom != currentLayout.getHeight() ? (currentLayout.getLineBottom(currentLine) - currentLayout.getSpacingAdd()) : 0);
|
||||
}
|
||||
} else {
|
||||
y2 = bottom - (bottom != currentLayout.getHeight() ? currentLayout.getSpacingAdd() : 0);
|
||||
}
|
||||
if (baselineShift < 0) {
|
||||
y2 += baselineShift;
|
||||
} else if (baselineShift > 0) {
|
||||
y += baselineShift;
|
||||
}
|
||||
if (useRoundRect) {
|
||||
// final CharSequence text = currentLayout.getText();
|
||||
// int startOffset = currentLayout.getOffsetForHorizontal(currentLine, left), endOffset = currentLayout.getOffsetForHorizontal(currentLine, right) + 1;
|
||||
boolean startsWithWhitespace = false; // startOffset >= 0 && startOffset < text.length() && text.charAt(startOffset) == ' ';
|
||||
boolean endsWithWhitespace = false; // endOffset >= 0 && endOffset < text.length() && text.charAt(endOffset) == ' ';
|
||||
super.addRect(left - (startsWithWhitespace ? 0 : getRadius() / 2f), y, right + (endsWithWhitespace ? 0 : getRadius() / 2f), y2, dir);
|
||||
} else {
|
||||
super.addRect(left, y, right, y2, dir);
|
||||
boolean startsWithWhitespace = false; // startOffset >= 0 && startOffset < text.length() && text.charAt(startOffset) == ' ';
|
||||
boolean endsWithWhitespace = false; // endOffset >= 0 && endOffset < text.length() && text.charAt(endOffset) == ' ';
|
||||
super.addRect(left - (startsWithWhitespace ? 0 : getRadius() / 2f), y, right + (endsWithWhitespace ? 0 : getRadius() / 2f), y2, dir);
|
||||
} else {
|
||||
super.addRect(left, y, right, y2, dir);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.telegram.ui.Components;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.CornerPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
|
|
@ -18,7 +19,10 @@ import android.view.View;
|
|||
import android.view.ViewConfiguration;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.graphics.ColorUtils;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.ui.ActionBar.SimpleTextView;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ArticleViewer;
|
||||
|
||||
|
|
@ -26,6 +30,8 @@ import java.util.ArrayList;
|
|||
|
||||
public class LinkSpanDrawable<S extends CharacterStyle> {
|
||||
|
||||
private static final int CORNER_RADIUS_DP = 4;
|
||||
|
||||
private int cornerRadius;
|
||||
private int color;
|
||||
private Paint mSelectionPaint, mRipplePaint;
|
||||
|
|
@ -74,11 +80,11 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
this.color = color;
|
||||
if (mSelectionPaint != null) {
|
||||
mSelectionPaint.setColor(color);
|
||||
mSelectionAlpha = mSelectionPaint.getAlpha();
|
||||
mSelectionAlpha = Color.alpha(color);
|
||||
}
|
||||
if (mRipplePaint != null) {
|
||||
mRipplePaint.setColor(color);
|
||||
mRippleAlpha = mRipplePaint.getAlpha();
|
||||
mRippleAlpha = Color.alpha(color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -113,20 +119,23 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
}
|
||||
|
||||
public boolean draw(Canvas canvas) {
|
||||
boolean cornerRadiusUpdate = cornerRadius != AndroidUtilities.dp(4);
|
||||
if (mSelectionPaint == null || cornerRadiusUpdate) {
|
||||
boolean cornerRadiusUpdate = cornerRadius != AndroidUtilities.dp(CORNER_RADIUS_DP);
|
||||
if (mSelectionPaint == null) {
|
||||
mSelectionPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mSelectionPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mSelectionPaint.setColor(color);
|
||||
mSelectionAlpha = mSelectionPaint.getAlpha();
|
||||
mSelectionPaint.setPathEffect(new CornerPathEffect(cornerRadius = AndroidUtilities.dp(4)));
|
||||
mSelectionAlpha = Color.alpha(color);
|
||||
}
|
||||
if (mRipplePaint == null || cornerRadiusUpdate) {
|
||||
if (mRipplePaint == null) {
|
||||
mRipplePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mRipplePaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mRipplePaint.setColor(color);
|
||||
mRippleAlpha = mRipplePaint.getAlpha();
|
||||
mRipplePaint.setPathEffect(new CornerPathEffect(cornerRadius = AndroidUtilities.dp(4)));
|
||||
mRippleAlpha = Color.alpha(color);
|
||||
}
|
||||
if (cornerRadiusUpdate) {
|
||||
cornerRadius = AndroidUtilities.dp(CORNER_RADIUS_DP);
|
||||
mSelectionPaint.setPathEffect(new CornerPathEffect(cornerRadius));
|
||||
mRipplePaint.setPathEffect(new CornerPathEffect(cornerRadius));
|
||||
}
|
||||
if (mBounds == null && mPathesCount > 0) {
|
||||
mPathes.get(0).computeBounds(AndroidUtilities.rectTmp, false);
|
||||
|
|
@ -376,6 +385,8 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
private OnLinkPress onLongPressListener;
|
||||
|
||||
private boolean disablePaddingsOffset;
|
||||
private boolean disablePaddingsOffsetX;
|
||||
private boolean disablePaddingsOffsetY;
|
||||
|
||||
public LinksTextView(Context context) {
|
||||
this(context, null);
|
||||
|
|
@ -399,6 +410,14 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
this.disablePaddingsOffset = disablePaddingsOffset;
|
||||
}
|
||||
|
||||
public void setDisablePaddingsOffsetX(boolean disablePaddingsOffsetX) {
|
||||
this.disablePaddingsOffsetX = disablePaddingsOffsetX;
|
||||
}
|
||||
|
||||
public void setDisablePaddingsOffsetY(boolean disablePaddingsOffsetY) {
|
||||
this.disablePaddingsOffsetY = disablePaddingsOffsetY;
|
||||
}
|
||||
|
||||
public void setOnLinkPressListener(OnLinkPress listener) {
|
||||
onPressListener = listener;
|
||||
}
|
||||
|
|
@ -417,7 +436,6 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
final int line = textLayout.getLineForVertical(y);
|
||||
final int off = textLayout.getOffsetForHorizontal(line, x);
|
||||
final float left = getLayout().getLineLeft(line);
|
||||
ClickableSpan span = null;
|
||||
if (left <= x && left + textLayout.getLineWidth(line) >= x && y >= 0 && y <= textLayout.getHeight()) {
|
||||
Spannable buffer = new SpannableString(textLayout.getText());
|
||||
ClickableSpan[] spans = buffer.getSpans(off, off, ClickableSpan.class);
|
||||
|
|
@ -480,7 +498,7 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
if (!isCustomLinkCollector) {
|
||||
canvas.save();
|
||||
if (!disablePaddingsOffset) {
|
||||
canvas.translate(getPaddingLeft(), getPaddingTop());
|
||||
canvas.translate(disablePaddingsOffsetX ? 0 : getPaddingLeft(), disablePaddingsOffsetY ? 0 : getPaddingTop());
|
||||
}
|
||||
if (links.draw(canvas)) {
|
||||
invalidate();
|
||||
|
|
@ -490,4 +508,80 @@ public class LinkSpanDrawable<S extends CharacterStyle> {
|
|||
super.onDraw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClickableSmallTextView extends SimpleTextView {
|
||||
private Theme.ResourcesProvider resourcesProvider;
|
||||
public ClickableSmallTextView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ClickableSmallTextView(Context context, Theme.ResourcesProvider resourcesProvider) {
|
||||
super(context);
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
}
|
||||
|
||||
private int getLinkColor() {
|
||||
return ColorUtils.setAlphaComponent(getTextColor(), (int) (Color.alpha(getTextColor()) * .1175f));
|
||||
}
|
||||
|
||||
private LinkCollector links = new LinkCollector(this);
|
||||
private Paint linkBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (isClickable()) {
|
||||
AndroidUtilities.rectTmp.set(0, 0, getPaddingLeft() + getTextWidth() + getPaddingRight(), getHeight());
|
||||
linkBackgroundPaint.setColor(getLinkColor());
|
||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(CORNER_RADIUS_DP), AndroidUtilities.dp(CORNER_RADIUS_DP), linkBackgroundPaint);
|
||||
}
|
||||
|
||||
super.onDraw(canvas);
|
||||
|
||||
if (isClickable() && links.draw(canvas)) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private LinkSpanDrawable pressedLink;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (!isClickable()) {
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
if (links != null) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
final LinkSpanDrawable link = new LinkSpanDrawable<ClickableSpan>(null, resourcesProvider, event.getX(), event.getY());
|
||||
link.setColor(getLinkColor());
|
||||
pressedLink = link;
|
||||
links.addLink(pressedLink);
|
||||
LinkPath path = pressedLink.obtainNewPath();
|
||||
path.setCurrentLayout(null, 0, 0, 0);
|
||||
path.addRect(0, 0, getPaddingLeft() + getTextWidth() + getPaddingRight(), getHeight(), Path.Direction.CW);
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (pressedLink == link) {
|
||||
performLongClick();
|
||||
pressedLink = null;
|
||||
links.clear();
|
||||
}
|
||||
}, ViewConfiguration.getLongPressTimeout());
|
||||
return true;
|
||||
}
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
links.clear();
|
||||
if (pressedLink != null) {
|
||||
performClick();
|
||||
}
|
||||
pressedLink = null;
|
||||
return true;
|
||||
}
|
||||
if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
links.clear();
|
||||
pressedLink = null;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return pressedLink != null || super.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,23 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
|
||||
public class LoadingDrawable extends Drawable {
|
||||
|
||||
private Theme.ResourcesProvider resourcesProvider;
|
||||
public Theme.ResourcesProvider resourcesProvider;
|
||||
public LoadingDrawable(Theme.ResourcesProvider resourcesProvider) {
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
}
|
||||
|
||||
public LoadingDrawable(String colorKey1, String colorKey2, Theme.ResourcesProvider resourcesProvider) {
|
||||
this.colorKey1 = colorKey1;
|
||||
this.colorKey2 = colorKey2;
|
||||
this.resourcesProvider = resourcesProvider;
|
||||
}
|
||||
|
||||
private long start = -1;
|
||||
private LinearGradient gradient;
|
||||
private int gradientColor1, gradientColor2;
|
||||
public String colorKey1 = Theme.key_dialogBackground;
|
||||
public String colorKey2 = Theme.key_dialogBackgroundGray;
|
||||
public Integer color1, color2;
|
||||
private int gradientWidth;
|
||||
|
||||
public Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
|
@ -48,8 +55,8 @@ public class LoadingDrawable extends Drawable {
|
|||
return;
|
||||
}
|
||||
int gwidth = Math.min(AndroidUtilities.dp(400), bounds.width());
|
||||
int color1 = Theme.getColor(colorKey1, resourcesProvider);
|
||||
int color2 = Theme.getColor(colorKey2, resourcesProvider);
|
||||
int color1 = this.color1 != null ? this.color1 : Theme.getColor(colorKey1, resourcesProvider);
|
||||
int color2 = this.color2 != null ? this.color2 : Theme.getColor(colorKey2, resourcesProvider);
|
||||
if (gradient == null || gwidth != gradientWidth || color1 != gradientColor1 || color2 != gradientColor2) {
|
||||
gradientWidth = gwidth;
|
||||
gradientColor1 = color1;
|
||||
|
|
@ -62,7 +69,7 @@ public class LoadingDrawable extends Drawable {
|
|||
if (start < 0) {
|
||||
start = now;
|
||||
}
|
||||
float offset = gradientWidth - (((now - start) / 1000f * gradientWidth) % gradientWidth);
|
||||
float offset = gradientWidth - (((now - start) / 4000f * AndroidUtilities.dp(2) * gradientWidth) % gradientWidth);
|
||||
|
||||
canvas.save();
|
||||
canvas.clipRect(bounds);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
||||
public class LoadingSpan extends ReplacementSpan {
|
||||
|
||||
|
|
@ -24,6 +25,26 @@ public class LoadingSpan extends ReplacementSpan {
|
|||
this.drawable.paint.setPathEffect(new CornerPathEffect(AndroidUtilities.dp(4)));
|
||||
}
|
||||
|
||||
public void setColorKeys(String colorKey1, String colorKey2) {
|
||||
this.drawable.colorKey1 = colorKey1;
|
||||
this.drawable.colorKey2 = colorKey2;
|
||||
}
|
||||
|
||||
public void setColorKeys(String colorKey1, String colorKey2, Theme.ResourcesProvider resourcesProvider) {
|
||||
this.drawable.resourcesProvider = resourcesProvider;
|
||||
this.drawable.colorKey1 = colorKey1;
|
||||
this.drawable.colorKey2 = colorKey2;
|
||||
}
|
||||
|
||||
public void setColors(int color1, int color2) {
|
||||
this.drawable.color1 = color1;
|
||||
this.drawable.color2 = color2;
|
||||
}
|
||||
|
||||
public void setView(View view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i1, @Nullable Paint.FontMetricsInt fontMetricsInt) {
|
||||
return size;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
|
@ -78,6 +79,7 @@ public class MediaActivity extends BaseFragment implements SharedMediaLayout.Sha
|
|||
}
|
||||
}
|
||||
});
|
||||
actionBar.setColorFilterMode(PorterDuff.Mode.SRC_IN);
|
||||
FrameLayout avatarContainer = new FrameLayout(context);
|
||||
SizeNotifierFrameLayout fragmentView = new SizeNotifierFrameLayout(context) {
|
||||
|
||||
|
|
@ -256,7 +258,7 @@ public class MediaActivity extends BaseFragment implements SharedMediaLayout.Sha
|
|||
if (user.self) {
|
||||
nameTextView.setText(LocaleController.getString("SavedMessages", R.string.SavedMessages));
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_SAVED);
|
||||
avatarDrawable.setSmallSize(true);
|
||||
avatarDrawable.setScaleSize(.8f);
|
||||
} else {
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
avatarDrawable.setInfo(user);
|
||||
|
|
|
|||
|
|
@ -73,8 +73,11 @@ public class NumberPicker extends LinearLayout {
|
|||
private int mSelectorTextGapHeight;
|
||||
private String[] mDisplayedValues;
|
||||
private int mMinValue;
|
||||
private boolean mMinValueSet;
|
||||
private int mMaxValue;
|
||||
private boolean mMaxValueSet;
|
||||
private int mValue;
|
||||
private int mFantomValue;
|
||||
private OnValueChangeListener mOnValueChangeListener;
|
||||
private OnScrollListener mOnScrollListener;
|
||||
private Formatter mFormatter;
|
||||
|
|
@ -96,7 +99,7 @@ public class NumberPicker extends LinearLayout {
|
|||
private int mTouchSlop;
|
||||
private int mMinimumFlingVelocity;
|
||||
private int mMaximumFlingVelocity;
|
||||
private boolean mWrapSelectorWheel;
|
||||
private boolean mWrapSelectorWheel, mWrapSelectorWheelSetting;
|
||||
private int mSolidColor;
|
||||
private Paint mSelectionDivider;
|
||||
private int mSelectionDividerHeight;
|
||||
|
|
@ -140,6 +143,10 @@ public class NumberPicker extends LinearLayout {
|
|||
initializeSelectorWheelIndices();
|
||||
}
|
||||
|
||||
public int getItemsCount() {
|
||||
return SELECTOR_WHEEL_ITEM_COUNT;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
mSolidColor = 0;
|
||||
mSelectionDivider = new Paint();
|
||||
|
|
@ -625,10 +632,8 @@ public class NumberPicker extends LinearLayout {
|
|||
}
|
||||
|
||||
public void setWrapSelectorWheel(boolean wrapSelectorWheel) {
|
||||
final boolean wrappingAllowed = (mMaxValue - mMinValue) >= mSelectorIndices.length;
|
||||
if ((!wrapSelectorWheel || wrappingAllowed) && wrapSelectorWheel != mWrapSelectorWheel) {
|
||||
mWrapSelectorWheel = wrapSelectorWheel;
|
||||
}
|
||||
final boolean wrappingAllowed = !(mMaxValueSet && mMinValueSet) || (mMaxValue - mMinValue) >= mSelectorIndices.length;
|
||||
mWrapSelectorWheel = wrappingAllowed && (mWrapSelectorWheelSetting = wrapSelectorWheel);
|
||||
}
|
||||
|
||||
public void setOnLongPressUpdateInterval(long intervalMillis) {
|
||||
|
|
@ -651,11 +656,17 @@ public class NumberPicker extends LinearLayout {
|
|||
throw new IllegalArgumentException("minValue must be >= 0");
|
||||
}
|
||||
mMinValue = minValue;
|
||||
mMinValueSet = true;
|
||||
if (mMinValue > mValue) {
|
||||
mValue = mMinValue;
|
||||
if (mMinValue <= mFantomValue) {
|
||||
mValue = mFantomValue;
|
||||
} else {
|
||||
mValue = mMinValue;
|
||||
}
|
||||
}
|
||||
if (mWrapSelectorWheelSetting && mMaxValueSet) {
|
||||
mWrapSelectorWheel = mMaxValue - mMinValue > mSelectorIndices.length;
|
||||
}
|
||||
boolean wrapSelectorWheel = mMaxValue - mMinValue > mSelectorIndices.length;
|
||||
setWrapSelectorWheel(wrapSelectorWheel);
|
||||
initializeSelectorWheelIndices();
|
||||
updateInputTextView();
|
||||
tryComputeMaxWidth();
|
||||
|
|
@ -674,11 +685,17 @@ public class NumberPicker extends LinearLayout {
|
|||
throw new IllegalArgumentException("maxValue must be >= 0");
|
||||
}
|
||||
mMaxValue = maxValue;
|
||||
mMaxValueSet = true;
|
||||
if (mMaxValue < mValue) {
|
||||
mValue = mMaxValue;
|
||||
if (mMaxValue >= mFantomValue) {
|
||||
mValue = mFantomValue;
|
||||
} else {
|
||||
mValue = mMaxValue;
|
||||
}
|
||||
}
|
||||
if (mWrapSelectorWheelSetting && mMinValueSet) {
|
||||
mWrapSelectorWheel = mMaxValue - mMinValue > mSelectorIndices.length;
|
||||
}
|
||||
boolean wrapSelectorWheel = mMaxValue - mMinValue > mSelectorIndices.length;
|
||||
setWrapSelectorWheel(wrapSelectorWheel);
|
||||
initializeSelectorWheelIndices();
|
||||
updateInputTextView();
|
||||
tryComputeMaxWidth();
|
||||
|
|
@ -856,7 +873,7 @@ public class NumberPicker extends LinearLayout {
|
|||
current = Math.min(current, mMaxValue);
|
||||
}
|
||||
int previous = mValue;
|
||||
mValue = current;
|
||||
mValue = mFantomValue = current;
|
||||
updateInputTextView();
|
||||
if (Math.abs(previous - current) > 0.9f && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ public class OutlineTextContainerView extends FrameLayout {
|
|||
}
|
||||
|
||||
public void updateColor() {
|
||||
int textSelectionColor = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteHintText), Theme.getColor(Theme.key_windowBackgroundWhiteValueText), selectionProgress);
|
||||
int textSelectionColor = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteHintText), Theme.getColor(Theme.key_windowBackgroundWhiteValueText), forceUseCenter ? 0f : selectionProgress);
|
||||
textPaint.setColor(ColorUtils.blendARGB(textSelectionColor, Theme.getColor(Theme.key_dialogTextRed), errorProgress));
|
||||
int selectionColor = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteInputField), Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), selectionProgress);
|
||||
int selectionColor = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteInputField), Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), forceUseCenter ? 0f : selectionProgress);
|
||||
setColor(ColorUtils.blendARGB(selectionColor, Theme.getColor(Theme.key_dialogTextRed), errorProgress));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package org.telegram.ui.Components;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
|
@ -9,6 +14,7 @@ import android.graphics.Color;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
|
@ -21,6 +27,8 @@ import android.webkit.WebSettings;
|
|||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
|
@ -32,11 +40,14 @@ import org.telegram.messenger.AndroidUtilities;
|
|||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BringAppForegroundService;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.browser.Browser;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
|
@ -56,11 +67,19 @@ public class PhotoViewerWebView extends FrameLayout {
|
|||
YT_PLAYING = 1,
|
||||
YT_PAUSED = 2,
|
||||
YT_BUFFERING = 3;
|
||||
private final static int YT_ERR_INVALID = 2,
|
||||
YT_ERR_HTML = 5,
|
||||
YT_ERR_NOT_FOUND = 100,
|
||||
YT_ERR_NOT_AVAILABLE_IN_APP = 101,
|
||||
YT_ERR_NOT_AVAILABLE_IN_APP_ALT = 150;
|
||||
|
||||
private int currentAccount = UserConfig.selectedAccount;
|
||||
|
||||
private PhotoViewer photoViewer;
|
||||
|
||||
private LinearLayout errorLayout;
|
||||
private TextView errorMessage;
|
||||
private TextView errorButton;
|
||||
private WebView webView;
|
||||
private View progressBarBlackBackground;
|
||||
private RadialProgressView progressBar;
|
||||
|
|
@ -75,6 +94,7 @@ public class PhotoViewerWebView extends FrameLayout {
|
|||
private float playbackSpeed;
|
||||
private boolean setPlaybackSpeed;
|
||||
|
||||
private boolean hasError;
|
||||
private boolean isPlaying;
|
||||
private int videoDuration;
|
||||
private int currentPosition;
|
||||
|
|
@ -110,6 +130,59 @@ public class PhotoViewerWebView extends FrameLayout {
|
|||
});
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void onPlayerError(String error) {
|
||||
int errorInt = Integer.parseInt(error);
|
||||
AndroidUtilities.runOnUIThread(()->{
|
||||
errorButton.setVisibility(GONE);
|
||||
webView.setVisibility(GONE);
|
||||
|
||||
if (errorLayout.getVisibility() == View.GONE) {
|
||||
errorLayout.setVisibility(VISIBLE);
|
||||
errorLayout.animate().cancel();
|
||||
errorLayout.animate().alpha(1f).setDuration(150).start();
|
||||
}
|
||||
|
||||
if (progressBar.getAlpha() == 1f) {
|
||||
progressBar.animate().cancel();
|
||||
progressBar.animate().alpha(0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
progressBar.setVisibility(GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (progressBarBlackBackground.getAlpha() == 1f) {
|
||||
progressBarBlackBackground.animate().cancel();
|
||||
progressBarBlackBackground.animate().alpha(0f).setDuration(150).setListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
progressBarBlackBackground.setVisibility(GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
switch (errorInt) {
|
||||
case YT_ERR_INVALID:
|
||||
errorMessage.setText(LocaleController.getString(R.string.YouTubeVideoErrorInvalid));
|
||||
break;
|
||||
case YT_ERR_HTML:
|
||||
errorMessage.setText(LocaleController.getString(R.string.YouTubeVideoErrorHTML));
|
||||
break;
|
||||
case YT_ERR_NOT_FOUND:
|
||||
errorMessage.setText(LocaleController.getString(R.string.YouTubeVideoErrorNotFound));
|
||||
break;
|
||||
case YT_ERR_NOT_AVAILABLE_IN_APP:
|
||||
case YT_ERR_NOT_AVAILABLE_IN_APP_ALT:
|
||||
errorMessage.setText(LocaleController.getString(R.string.YouTubeVideoErrorNotAvailableInApp));
|
||||
errorButton.setText(LocaleController.getString(R.string.YouTubeVideoErrorOpenExternal));
|
||||
errorButton.setVisibility(VISIBLE);
|
||||
errorButton.setOnClickListener(v -> v.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(currentWebpage.url))));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void onPlayerStateChange(String state) {
|
||||
int stateInt = Integer.parseInt(state);
|
||||
|
|
@ -295,6 +368,26 @@ public class PhotoViewerWebView extends FrameLayout {
|
|||
|
||||
addView(webView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
|
||||
|
||||
errorLayout = new LinearLayout(context);
|
||||
errorLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
errorLayout.setGravity(Gravity.CENTER);
|
||||
errorLayout.setVisibility(GONE);
|
||||
addView(errorLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
|
||||
errorMessage = new TextView(context);
|
||||
errorMessage.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
errorMessage.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
||||
errorMessage.setGravity(Gravity.CENTER);
|
||||
errorLayout.addView(errorMessage, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
|
||||
|
||||
errorButton = new TextView(context);
|
||||
errorButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
errorButton.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
|
||||
errorButton.setPadding(AndroidUtilities.dp(12), AndroidUtilities.dp(8), AndroidUtilities.dp(12), AndroidUtilities.dp(8));
|
||||
errorButton.setBackground(Theme.AdaptiveRipple.rect(Theme.key_windowBackgroundWhiteBlueText, 12));
|
||||
errorButton.setVisibility(GONE);
|
||||
errorLayout.addView(errorButton, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 0, 8, 0, 0));
|
||||
|
||||
progressBarBlackBackground = new View(context) {
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
|
@ -311,6 +404,10 @@ public class PhotoViewerWebView extends FrameLayout {
|
|||
addView(progressBar, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
return hasError;
|
||||
}
|
||||
|
||||
public boolean hasYoutubeStoryboards() {
|
||||
return !youtubeStoryboards.isEmpty();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ import android.animation.ValueAnimator;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
|
|
@ -25,7 +25,9 @@ import androidx.core.graphics.ColorUtils;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.TopicsFragment;
|
||||
|
||||
public class PullForegroundDrawable {
|
||||
|
||||
|
|
@ -46,8 +48,10 @@ public class PullForegroundDrawable {
|
|||
private final Paint paintBackgroundAccent = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final Paint backgroundPaint = new Paint();
|
||||
private final RectF rectF = new RectF();
|
||||
private final Paint tooltipTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final TextPaint tooltipTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
private final ArrowDrawable arrowDrawable = new ArrowDrawable();
|
||||
private int generalTopicDrawableColor;
|
||||
private Drawable generalTopicDrawable;
|
||||
private final Path circleClipPath = new Path();
|
||||
|
||||
private float textSwappingProgress = 1f;
|
||||
|
|
@ -84,8 +88,10 @@ public class PullForegroundDrawable {
|
|||
public float outImageSize;
|
||||
public float outOverScroll;
|
||||
|
||||
private String pullTooltip;
|
||||
private String releaseTooltip;
|
||||
private StaticLayout pullTooltipLayout;
|
||||
private float pullTooltipLayoutWidth;
|
||||
private StaticLayout releaseTooltipLayout;
|
||||
private float releaseTooltipLayoutWidth;
|
||||
private boolean willDraw;
|
||||
|
||||
private boolean isOut;
|
||||
|
|
@ -106,16 +112,22 @@ public class PullForegroundDrawable {
|
|||
}
|
||||
};
|
||||
|
||||
public PullForegroundDrawable(String pullText, String releaseText) {
|
||||
public PullForegroundDrawable(CharSequence pullText, CharSequence releaseText) {
|
||||
tooltipTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
tooltipTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||
// tooltipTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||
tooltipTextPaint.setTextSize(AndroidUtilities.dp(16));
|
||||
|
||||
final ViewConfiguration vc = ViewConfiguration.get(ApplicationLoader.applicationContext);
|
||||
touchSlop = vc.getScaledTouchSlop();
|
||||
|
||||
pullTooltip = pullText;
|
||||
releaseTooltip = releaseText;
|
||||
pullTooltipLayout = new StaticLayout(pullText, 0, pullText.length(), tooltipTextPaint, AndroidUtilities.displaySize.x, Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
|
||||
pullTooltipLayoutWidth = pullTooltipLayout.getLineWidth(0);
|
||||
releaseTooltipLayout = new StaticLayout(releaseText, 0, releaseText.length(), tooltipTextPaint, AndroidUtilities.displaySize.x, Layout.Alignment.ALIGN_NORMAL, 1, 0, false);
|
||||
releaseTooltipLayoutWidth = releaseTooltipLayout.getLineWidth(0);
|
||||
|
||||
try {
|
||||
generalTopicDrawable = ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.msg_filled_general).mutate();
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
public static int getMaxOverscroll() {
|
||||
|
|
@ -166,7 +178,8 @@ public class PullForegroundDrawable {
|
|||
if (!willDraw || isOut || cell == null || listView == null) {
|
||||
return;
|
||||
}
|
||||
int startPadding = AndroidUtilities.dp(28);
|
||||
boolean isTopic = cell instanceof TopicsFragment.TopicDialogCell;
|
||||
int startPadding = AndroidUtilities.dp(isTopic ? 15 : 28);
|
||||
int smallMargin = AndroidUtilities.dp(8);
|
||||
int radius = AndroidUtilities.dp(9);
|
||||
int diameter = AndroidUtilities.dp(18);
|
||||
|
|
@ -207,11 +220,12 @@ public class PullForegroundDrawable {
|
|||
canvas.drawPaint(backgroundPaint);
|
||||
}
|
||||
} else {
|
||||
float outBackgroundRadius = outRadius + (cell.getWidth() - outRadius) * (1f - outProgress) + (outRadius * bounceP);
|
||||
float outBackgroundRadius = outRadius + (outRadius * bounceP) + (cell.getWidth() - outRadius) * (1f - outProgress);
|
||||
|
||||
if (!(accentRevalProgress == 1f || accentRevalProgressOut == 1)) {
|
||||
canvas.drawCircle(cX, cY, outBackgroundRadius, backgroundPaint);
|
||||
}
|
||||
|
||||
circleClipPath.reset();
|
||||
rectF.set(cX - outBackgroundRadius, cY - outBackgroundRadius, cX + outBackgroundRadius, cY + outBackgroundRadius);
|
||||
circleClipPath.addOval(rectF, Path.Direction.CW);
|
||||
|
|
@ -261,8 +275,11 @@ public class PullForegroundDrawable {
|
|||
return;
|
||||
}
|
||||
|
||||
if (outProgress == 0f) {
|
||||
paintWhite.setAlpha((int) (startPullProgress * 255));
|
||||
if (isTopic) {
|
||||
smallCircleY -= (cell.getMeasuredHeight() - AndroidUtilities.dp(41)) * outProgress;
|
||||
}
|
||||
if (outProgress == 0f || isTopic) {
|
||||
paintWhite.setAlpha((int) (startPullProgress * 255 * (1f - outProgress)));
|
||||
canvas.drawCircle(smallCircleX, smallCircleY, radius, paintWhite);
|
||||
|
||||
int ih = arrowDrawable.getIntrinsicHeight();
|
||||
|
|
@ -279,19 +296,16 @@ public class PullForegroundDrawable {
|
|||
canvas.rotate(180 * rotateProgress, smallCircleX, smallCircleY);
|
||||
canvas.translate(0, AndroidUtilities.dpf2(1f) * 1f - rotateProgress);
|
||||
arrowDrawable.setColor(animateToColorize ? paintBackgroundAccent.getColor() : Theme.getColor(backgroundColorKey));
|
||||
arrowDrawable.setAlpha((int) (255 * (1f - outProgress)));
|
||||
arrowDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
|
||||
if (pullProgress > 0f) {
|
||||
textIn();
|
||||
}
|
||||
|
||||
float textY = cell.getHeight() - ((diameter + smallMargin * 2) / 2f) + AndroidUtilities.dp(6);
|
||||
|
||||
tooltipTextPaint.setAlpha((int) (255 * textSwappingProgress * startPullProgress * textInProgress));
|
||||
|
||||
float textCx = cell.getWidth() / 2f - AndroidUtilities.dp(2);
|
||||
|
||||
if (textSwappingProgress > 0 && textSwappingProgress < 1f) {
|
||||
|
|
@ -299,7 +313,10 @@ public class PullForegroundDrawable {
|
|||
float scale = 0.8f + 0.2f * textSwappingProgress;
|
||||
canvas.scale(scale, scale, textCx, textY + AndroidUtilities.dp(16) * (1f - textSwappingProgress));
|
||||
}
|
||||
canvas.drawText(pullTooltip, textCx, textY + AndroidUtilities.dp(8) * (1f - textSwappingProgress), tooltipTextPaint);
|
||||
canvas.saveLayerAlpha(0, 0, cell.getMeasuredWidth(), cell.getMeasuredHeight(), (int) (255 * textSwappingProgress * startPullProgress * textInProgress), Canvas.ALL_SAVE_FLAG);
|
||||
canvas.translate(textCx - pullTooltipLayoutWidth / 2f, textY + AndroidUtilities.dp(8) * (1f - textSwappingProgress) - tooltipTextPaint.getTextSize());
|
||||
pullTooltipLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
if (textSwappingProgress > 0 && textSwappingProgress < 1f) {
|
||||
canvas.restore();
|
||||
|
|
@ -310,15 +327,17 @@ public class PullForegroundDrawable {
|
|||
float scale = 0.9f + 0.1f * (1f - textSwappingProgress);
|
||||
canvas.scale(scale, scale, textCx, textY - AndroidUtilities.dp(8) * (textSwappingProgress));
|
||||
}
|
||||
tooltipTextPaint.setAlpha((int) (255 * (1f - textSwappingProgress) * startPullProgress * textInProgress));
|
||||
canvas.drawText(releaseTooltip, textCx, textY - AndroidUtilities.dp(8) * (textSwappingProgress), tooltipTextPaint);
|
||||
canvas.saveLayerAlpha(0, 0, cell.getMeasuredWidth(), cell.getMeasuredHeight(), (int) (255 * (1f - textSwappingProgress) * startPullProgress * textInProgress), Canvas.ALL_SAVE_FLAG);
|
||||
canvas.translate(textCx - releaseTooltipLayoutWidth / 2f, textY + AndroidUtilities.dp(8) * (textSwappingProgress) - tooltipTextPaint.getTextSize());
|
||||
releaseTooltipLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
|
||||
if (textSwappingProgress > 0 && textSwappingProgress < 1f) {
|
||||
canvas.restore();
|
||||
}
|
||||
canvas.restore();
|
||||
|
||||
if (changeAvatarColor && outProgress > 0) {
|
||||
if (!isTopic && changeAvatarColor && outProgress > 0) {
|
||||
canvas.save();
|
||||
int iw = Theme.dialogs_archiveAvatarDrawable.getIntrinsicWidth();
|
||||
|
||||
|
|
@ -347,6 +366,19 @@ public class PullForegroundDrawable {
|
|||
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
// if (isTopic) {
|
||||
// int color = arrowDrawable.paint.getColor();
|
||||
// if (generalTopicDrawableColor != color) {
|
||||
// generalTopicDrawable.setColorFilter(new PorterDuffColorFilter(generalTopicDrawableColor = color, PorterDuff.Mode.MULTIPLY));
|
||||
// }
|
||||
//
|
||||
// int ih = AndroidUtilities.lerp(AndroidUtilities.dp(14), AndroidUtilities.dp(28), outProgress);
|
||||
// int iw = AndroidUtilities.lerp(AndroidUtilities.dp(14), AndroidUtilities.dp(28), outProgress);
|
||||
// generalTopicDrawable.setBounds(smallCircleX - (iw >> 1), smallCircleY - (ih >> 1), smallCircleX + (iw >> 1), smallCircleY + (ih >> 1));
|
||||
// generalTopicDrawable.setAlpha((int) (255 * outProgress));
|
||||
// generalTopicDrawable.draw(canvas);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -541,6 +573,7 @@ public class PullForegroundDrawable {
|
|||
Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow1.**", color);
|
||||
Theme.dialogs_archiveAvatarDrawable.setLayerColor("Arrow2.**", color);
|
||||
Theme.dialogs_archiveAvatarDrawable.commitApplyLayerColors();
|
||||
Theme.dialogs_archiveAvatarDrawableRecolored = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1094,7 +1094,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
|
|||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
drawInternal(canvas, false, 0, 0);
|
||||
drawInternal(canvas, null, false, 0, 0);
|
||||
}
|
||||
|
||||
public void drawInBackground(Canvas canvas, float x, float y, float w, float h, int alpha, ColorFilter colorFilter, int threadIndex) {
|
||||
|
|
@ -1106,10 +1106,14 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
|
|||
backgroundPaint[threadIndex].setAlpha(alpha);
|
||||
backgroundPaint[threadIndex].setColorFilter(colorFilter);
|
||||
dstRectBackground[threadIndex].set(x, y, x + w, y + h);
|
||||
drawInternal(canvas, true, 0, threadIndex);
|
||||
drawInternal(canvas, null,true, 0, threadIndex);
|
||||
}
|
||||
|
||||
public void drawInternal(Canvas canvas, boolean drawInBackground, long time, int threadIndex) {
|
||||
public void draw(Canvas canvas, Paint paint) {
|
||||
drawInternal(canvas, paint, false, 0, 0);
|
||||
}
|
||||
|
||||
public void drawInternal(Canvas canvas, Paint overridePaint, boolean drawInBackground, long time, int threadIndex) {
|
||||
if (!canLoadFrames() || destroyWhenDone) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -1118,7 +1122,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
|
|||
}
|
||||
|
||||
RectF rect = drawInBackground ? dstRectBackground[threadIndex] : dstRect;
|
||||
Paint paint = drawInBackground ? backgroundPaint[threadIndex] : getPaint();
|
||||
Paint paint = overridePaint != null ? overridePaint : (drawInBackground ? backgroundPaint[threadIndex] : getPaint());
|
||||
|
||||
if (paint.getAlpha() == 0) {
|
||||
return;
|
||||
|
|
@ -1298,7 +1302,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
void setMasterParent(View parent) {
|
||||
public void setMasterParent(View parent) {
|
||||
masterParent = parent;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.DocumentObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.ImageLocation;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaDataController;
|
||||
|
|
@ -381,7 +382,14 @@ public class ReactedUsersListView extends FrameLayout {
|
|||
avatarView.setRoundRadius(AndroidUtilities.dp(32));
|
||||
addView(avatarView, LayoutHelper.createFrameRelatively(36, 36, Gravity.START | Gravity.CENTER_VERTICAL, 8, 0, 0, 0));
|
||||
|
||||
titleView = new SimpleTextView(context);
|
||||
titleView = new SimpleTextView(context) {
|
||||
@Override
|
||||
public boolean setText(CharSequence value) {
|
||||
value = Emoji.replaceEmoji(value, getPaint().getFontMetricsInt(), AndroidUtilities.dp(14), false);
|
||||
return super.setText(value);
|
||||
}
|
||||
};
|
||||
NotificationCenter.listenEmojiLoading(titleView);
|
||||
titleView.setTextSize(16);
|
||||
titleView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
|
||||
titleView.setEllipsizeByGradient(true);
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ public class AnimatedEmojiEffect {
|
|||
toY2 = toY1 + bounds.height();
|
||||
duration = 1800;
|
||||
}
|
||||
duration /= 1.75f;
|
||||
mirror = Utilities.fastRandom.nextBoolean();
|
||||
randomRotation = 20 * ((Utilities.fastRandom.nextInt() % 100) / 100f);
|
||||
}
|
||||
|
|
@ -243,7 +244,7 @@ public class AnimatedEmojiEffect {
|
|||
}
|
||||
|
||||
public void draw(Canvas canvas) {
|
||||
progress += 16f / duration;
|
||||
progress += (float) Math.min(40, 1000f / AndroidUtilities.screenRefreshRate) / duration;
|
||||
progress = Utilities.clamp(progress, 1f, 0f);
|
||||
float progressInternal = CubicBezierInterpolator.EASE_OUT.getInterpolation(progress);
|
||||
float cx = AndroidUtilities.lerp(fromX, toX, progressInternal);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.SharedConfig;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
|
|
@ -97,6 +98,7 @@ public class RecyclerListView extends RecyclerView {
|
|||
private Runnable selectChildRunnable;
|
||||
private FastScroll fastScroll;
|
||||
private SectionsAdapter sectionsAdapter;
|
||||
public boolean useLayoutPositionOnClick;
|
||||
|
||||
private boolean isHidden;
|
||||
|
||||
|
|
@ -117,6 +119,7 @@ public class RecyclerListView extends RecyclerView {
|
|||
private int startSection;
|
||||
private int sectionsCount;
|
||||
private int sectionOffset;
|
||||
private boolean allowStopHeaveOperations;
|
||||
|
||||
@SectionsType
|
||||
private int sectionsType;
|
||||
|
|
@ -1143,7 +1146,11 @@ public class RecyclerListView extends RecyclerView {
|
|||
}
|
||||
currentChildPosition = -1;
|
||||
if (currentChildView != null) {
|
||||
currentChildPosition = view.getChildPosition(currentChildView);
|
||||
if (useLayoutPositionOnClick) {
|
||||
currentChildPosition = view.getChildLayoutPosition(currentChildView);
|
||||
} else {
|
||||
currentChildPosition = view.getChildAdapterPosition(currentChildView);
|
||||
}
|
||||
MotionEvent childEvent = MotionEvent.obtain(0, 0, event.getActionMasked(), event.getX() - currentChildView.getLeft(), event.getY() - currentChildView.getTop(), 0);
|
||||
if (currentChildView.onTouchEvent(childEvent)) {
|
||||
interceptedByChild = true;
|
||||
|
|
@ -1390,6 +1397,7 @@ public class RecyclerListView extends RecyclerView {
|
|||
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
checkStopHeavyOperations(newState);
|
||||
if (newState != SCROLL_STATE_IDLE && currentChildView != null) {
|
||||
if (selectChildRunnable != null) {
|
||||
AndroidUtilities.cancelRunOnUIThread(selectChildRunnable);
|
||||
|
|
@ -1439,6 +1447,48 @@ public class RecyclerListView extends RecyclerView {
|
|||
addOnItemTouchListener(new RecyclerListViewItemClickListener(context));
|
||||
}
|
||||
|
||||
private Paint backgroundPaint;
|
||||
protected void drawSectionBackground(Canvas canvas, int fromAdapterPosition, int toAdapterPosition, int color) {
|
||||
int top = Integer.MAX_VALUE;
|
||||
int bottom = Integer.MIN_VALUE;
|
||||
|
||||
for (int i = 0; i < getChildCount(); ++i) {
|
||||
View child = getChildAt(i);
|
||||
if (child == null) {
|
||||
continue;
|
||||
}
|
||||
int position = getChildAdapterPosition(child);
|
||||
if (position >= fromAdapterPosition && position <= toAdapterPosition) {
|
||||
top = Math.min(child.getTop(), top);
|
||||
bottom = Math.max(child.getBottom(), bottom);
|
||||
}
|
||||
}
|
||||
|
||||
if (top < bottom) {
|
||||
if (backgroundPaint == null) {
|
||||
backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
backgroundPaint.setColor(color);
|
||||
canvas.drawRect(0, top, getWidth(), bottom, backgroundPaint);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean stoppedAllHeavyOperations;
|
||||
|
||||
private void checkStopHeavyOperations(int newState) {
|
||||
if (newState == SCROLL_STATE_IDLE) {
|
||||
if (stoppedAllHeavyOperations) {
|
||||
stoppedAllHeavyOperations = false;
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512);
|
||||
}
|
||||
} else {
|
||||
if (!stoppedAllHeavyOperations && allowStopHeaveOperations) {
|
||||
stoppedAllHeavyOperations = true;
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 512);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) {
|
||||
if (attributes != null) {
|
||||
|
|
@ -1976,7 +2026,7 @@ public class RecyclerListView extends RecyclerView {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean emptyViewIsVisible() {
|
||||
public boolean emptyViewIsVisible() {
|
||||
if (getAdapter() == null || isFastScrollAnimationRunning()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2417,6 +2467,11 @@ public class RecyclerListView extends RecyclerView {
|
|||
if (itemsEnterAnimator != null) {
|
||||
itemsEnterAnimator.onDetached();
|
||||
}
|
||||
|
||||
if (stoppedAllHeavyOperations) {
|
||||
stoppedAllHeavyOperations = false;
|
||||
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 512);
|
||||
}
|
||||
}
|
||||
|
||||
public void addOverlayView(View view, FrameLayout.LayoutParams layoutParams) {
|
||||
|
|
@ -2708,4 +2763,8 @@ public class RecyclerListView extends RecyclerView {
|
|||
public void setAccessibilityEnabled(boolean accessibilityEnabled) {
|
||||
this.accessibilityEnabled = accessibilityEnabled;
|
||||
}
|
||||
|
||||
public void setAllowStopHeaveOperations(boolean allowStopHeaveOperations) {
|
||||
this.allowStopHeaveOperations = allowStopHeaveOperations;
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ import java.util.Set;
|
|||
|
||||
public class SearchViewPager extends ViewPagerFixed implements FilteredSearchView.UiCallback {
|
||||
|
||||
private final ViewPagerAdapter viewPagerAdapter;
|
||||
protected final ViewPagerAdapter viewPagerAdapter;
|
||||
public FrameLayout searchContainer;
|
||||
public RecyclerListView searchListView;
|
||||
public StickerEmptyView emptyView;
|
||||
|
|
@ -107,6 +107,9 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
private int keyboardSize;
|
||||
|
||||
private boolean showOnlyDialogsAdapter;
|
||||
protected boolean includeDownloads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
ChatPreviewDelegate chatPreviewDelegate;
|
||||
SizeNotifierFrameLayout fragmentView;
|
||||
|
|
@ -190,9 +193,13 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
int firstVisibleItem = searchLayoutManager.findFirstVisibleItemPosition();
|
||||
int lastVisibleItem = searchLayoutManager.findLastVisibleItemPosition();
|
||||
int visibleItemCount = Math.abs(searchLayoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
|
||||
int totalItemCount = recyclerView.getAdapter().getItemCount();
|
||||
if (visibleItemCount > 0 && searchLayoutManager.findLastVisibleItemPosition() == totalItemCount - 1 && !dialogsSearchAdapter.isMessagesSearchEndReached()) {
|
||||
if (visibleItemCount > 0 && !dialogsSearchAdapter.isMessagesSearchEndReached() && (
|
||||
lastVisibleItem == totalItemCount - 1 ||
|
||||
dialogsSearchAdapter.delegate != null && dialogsSearchAdapter.delegate.getSearchForumDialogId() != 0 && dialogsSearchAdapter.localMessagesLoadingRow >= 0 && firstVisibleItem <= dialogsSearchAdapter.localMessagesLoadingRow && lastVisibleItem >= dialogsSearchAdapter.localMessagesLoadingRow
|
||||
)) {
|
||||
dialogsSearchAdapter.loadMoreSearchMessages();
|
||||
}
|
||||
fragmentView.invalidateBlur();
|
||||
|
|
@ -262,8 +269,21 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
search(view, getCurrentPosition(), text, reset);
|
||||
}
|
||||
|
||||
protected long getDialogId(String query) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void updateTabs() {
|
||||
viewPagerAdapter.updateItems();
|
||||
fillTabs();
|
||||
if (tabsView != null) {
|
||||
tabsView.finishAddingTabs();
|
||||
}
|
||||
}
|
||||
|
||||
private void search(View view, int position, String query, boolean reset) {
|
||||
long dialogId = 0;
|
||||
long forumDialogId = dialogsSearchAdapter.delegate != null ? dialogsSearchAdapter.delegate.getSearchForumDialogId() : 0;
|
||||
long dialogId = position == 0 ? 0 : forumDialogId;
|
||||
long minDate = 0;
|
||||
long maxDate = 0;
|
||||
boolean includeFolder = false;
|
||||
|
|
@ -284,7 +304,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
}
|
||||
|
||||
if (view == searchContainer) {
|
||||
if (dialogId == 0 && minDate == 0 && maxDate == 0) {
|
||||
if (dialogId == 0 && minDate == 0 && maxDate == 0 || forumDialogId != 0) {
|
||||
lastSearchScrolledToTop = false;
|
||||
dialogsSearchAdapter.searchDialogs(query, includeFolder ? 1 : 0);
|
||||
dialogsSearchAdapter.setFiltersDelegate(filteredSearchViewDelegate, false);
|
||||
|
|
@ -332,6 +352,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
emptyView.setKeyboardHeight(keyboardSize, false);
|
||||
noMediaFiltersSearchView.setKeyboardHeight(keyboardSize, false);
|
||||
} else if (view instanceof FilteredSearchView) {
|
||||
((FilteredSearchView) view).setUseFromUserAsAvatar(forumDialogId != 0);
|
||||
((FilteredSearchView) view).setKeyboardHeight(keyboardSize, false);
|
||||
ViewPagerAdapter.Item item = viewPagerAdapter.items.get(position);
|
||||
((FilteredSearchView) view).search(dialogId, minDate, maxDate, FiltersView.filters[item.filterIndex], includeFolder, query, reset);
|
||||
|
|
@ -391,6 +412,11 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
forwardItem = actionMode.addItemWithWidth(forwardItemId, R.drawable.msg_forward, AndroidUtilities.dp(54), LocaleController.getString("Forward", R.string.Forward));
|
||||
deleteItem = actionMode.addItemWithWidth(deleteItemId, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete));
|
||||
}
|
||||
if (selectedMessagesCountTextView != null) {
|
||||
boolean isForumSearch = dialogsSearchAdapter != null && dialogsSearchAdapter.delegate != null && dialogsSearchAdapter.delegate.getSearchForumDialogId() != 0;
|
||||
((MarginLayoutParams) selectedMessagesCountTextView.getLayoutParams()).leftMargin = AndroidUtilities.dp(72 + (isForumSearch ? 56 : 0));
|
||||
selectedMessagesCountTextView.setLayoutParams(selectedMessagesCountTextView.getLayoutParams());
|
||||
}
|
||||
if (parent.getActionBar().getBackButton().getDrawable() instanceof MenuDrawable) {
|
||||
BackDrawable backDrawable = new BackDrawable(false);
|
||||
parent.getActionBar().setBackButtonDrawable(backDrawable);
|
||||
|
|
@ -878,12 +904,19 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
|
|||
private final static int FILTER_TYPE = 2;
|
||||
|
||||
public ViewPagerAdapter() {
|
||||
updateItems();
|
||||
}
|
||||
|
||||
public void updateItems() {
|
||||
items.clear();
|
||||
items.add(new Item(DIALOGS_TYPE));
|
||||
if (!showOnlyDialogsAdapter) {
|
||||
Item item = new Item(FILTER_TYPE);
|
||||
item.filterIndex = 0;
|
||||
items.add(item);
|
||||
items.add(new Item(DOWNLOADS_TYPE));
|
||||
if (includeDownloads()) {
|
||||
items.add(new Item(DOWNLOADS_TYPE));
|
||||
}
|
||||
item = new Item(FILTER_TYPE);
|
||||
item.filterIndex = 1;
|
||||
items.add(item);
|
||||
|
|
|
|||
|
|
@ -670,7 +670,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
ArrayList<MessageObject> arr = (ArrayList<MessageObject>) args[1];
|
||||
for (int a = 0; a < arr.size(); a++) {
|
||||
MessageObject obj = arr.get(a);
|
||||
if (topicId != 0 && topicId != MessageObject.getTopicId(obj.messageOwner)) {
|
||||
if (topicId != 0 && topicId != MessageObject.getTopicId(obj.messageOwner, true)) {
|
||||
continue;
|
||||
}
|
||||
if (MessageObject.getMedia(obj.messageOwner) == null || obj.needDrawBluredPreview()) {
|
||||
|
|
@ -760,7 +760,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
for (int b = 0; b < sharedMediaData.length; b++) {
|
||||
MessageObject messageObject = sharedMediaData[b].deleteMessage(markAsDeletedMessages.get(a), 0);
|
||||
if (messageObject != null) {
|
||||
if (messageObject.getDialogId() == dialogId && (topicId == 0 || MessageObject.getTopicId(messageObject.messageOwner) == topicId)) {
|
||||
if (messageObject.getDialogId() == dialogId && (topicId == 0 || MessageObject.getTopicId(messageObject.messageOwner, true) == topicId)) {
|
||||
if (mediaCount[b] > 0) {
|
||||
mediaCount[b]--;
|
||||
}
|
||||
|
|
@ -798,7 +798,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
for (int b = 0, N = messageObjects.size(); b < N; b++) {
|
||||
MessageObject messageObject = messageObjects.get(b);
|
||||
int mid = messageObject.getId();
|
||||
int topicId = MessageObject.getTopicId(messageObject.messageOwner);
|
||||
int topicId = MessageObject.getTopicId(messageObject.messageOwner, true);
|
||||
int type = MediaDataController.getMediaType(messageObject.messageOwner);
|
||||
if (this.topicId != 0 && topicId != this.topicId) {
|
||||
continue;
|
||||
|
|
@ -1543,7 +1543,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
actionModeViews.add(selectedMessagesCountTextView);
|
||||
|
||||
if (!DialogObject.isEncryptedDialog(dialog_id)) {
|
||||
gotoItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_windowBackgroundWhiteGrayText2), false);
|
||||
gotoItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_actionBarActionModeDefaultIcon), false);
|
||||
gotoItem.setIcon(R.drawable.msg_message);
|
||||
gotoItem.setContentDescription(LocaleController.getString("AccDescrGoToMessage", R.string.AccDescrGoToMessage));
|
||||
gotoItem.setDuplicateParentStateEnabled(false);
|
||||
|
|
@ -1551,7 +1551,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
actionModeViews.add(gotoItem);
|
||||
gotoItem.setOnClickListener(v -> onActionBarItemClick(v, gotochat));
|
||||
|
||||
forwardItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_windowBackgroundWhiteGrayText2), false);
|
||||
forwardItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_actionBarActionModeDefaultIcon), false);
|
||||
forwardItem.setIcon(R.drawable.msg_forward);
|
||||
forwardItem.setContentDescription(LocaleController.getString("Forward", R.string.Forward));
|
||||
forwardItem.setDuplicateParentStateEnabled(false);
|
||||
|
|
@ -1561,7 +1561,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
|
||||
updateForwardItem();
|
||||
}
|
||||
deleteItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_windowBackgroundWhiteGrayText2), false);
|
||||
deleteItem = new ActionBarMenuItem(context, null, getThemedColor(Theme.key_actionBarActionModeDefaultSelector), getThemedColor(Theme.key_actionBarActionModeDefaultIcon), false);
|
||||
deleteItem.setIcon(R.drawable.msg_delete);
|
||||
deleteItem.setContentDescription(LocaleController.getString("Delete", R.string.Delete));
|
||||
deleteItem.setDuplicateParentStateEnabled(false);
|
||||
|
|
@ -6502,14 +6502,14 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
|
|||
|
||||
arrayList.add(new ThemeDescription(shadowLine, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_divider));
|
||||
|
||||
arrayList.add(new ThemeDescription(deleteItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
|
||||
arrayList.add(new ThemeDescription(deleteItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
|
||||
arrayList.add(new ThemeDescription(deleteItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
|
||||
if (gotoItem != null) {
|
||||
arrayList.add(new ThemeDescription(gotoItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
|
||||
arrayList.add(new ThemeDescription(gotoItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
|
||||
arrayList.add(new ThemeDescription(gotoItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
|
||||
}
|
||||
if (forwardItem != null) {
|
||||
arrayList.add(new ThemeDescription(forwardItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
|
||||
arrayList.add(new ThemeDescription(forwardItem.getIconView(), ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
|
||||
arrayList.add(new ThemeDescription(forwardItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
|
||||
}
|
||||
arrayList.add(new ThemeDescription(closeButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, new Drawable[]{backDrawable}, null, Theme.key_actionBarActionModeDefaultIcon));
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class SlotsDrawable extends RLottieDrawable {
|
|||
if (secondFrameNums[0] == secondFrameCounts[0] - 100) {
|
||||
playWinAnimation = true;
|
||||
if (left == ReelValue.sevenWin) {
|
||||
Runnable runnable = onFinishCallback.get();
|
||||
Runnable runnable = onFinishCallback == null ? null : onFinishCallback.get();
|
||||
if (runnable != null) {
|
||||
AndroidUtilities.runOnUIThread(runnable);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,12 +27,9 @@ import android.os.Build;
|
|||
import android.os.Parcelable;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.transition.Transition;
|
||||
import android.transition.TransitionManager;
|
||||
import android.transition.TransitionValues;
|
||||
|
|
@ -118,28 +115,12 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
boolean onCustomButtonPressed();
|
||||
}
|
||||
|
||||
private static class LinkMovementMethodMy extends LinkMovementMethod {
|
||||
@Override
|
||||
public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
|
||||
try {
|
||||
boolean result = super.onTouchEvent(widget, buffer, event);
|
||||
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
Selection.removeSelection(buffer);
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean wasLightStatusBar;
|
||||
|
||||
private Pattern urlPattern;
|
||||
private RecyclerListView gridView;
|
||||
private GridAdapter adapter;
|
||||
private TextView titleTextView;
|
||||
private LinkSpanDrawable.LinksTextView titleTextView;
|
||||
private TextView descriptionTextView;
|
||||
private ActionBarMenuItem optionsButton;
|
||||
private TextView pickerBottomLayout;
|
||||
|
|
@ -814,14 +795,14 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
gridView.setEmptyView(emptyView);
|
||||
emptyView.setOnTouchListener((v, event) -> true);
|
||||
|
||||
titleTextView = new TextView(context);
|
||||
titleTextView = new LinkSpanDrawable.LinksTextView(context);
|
||||
titleTextView.setLines(1);
|
||||
titleTextView.setSingleLine(true);
|
||||
titleTextView.setTextColor(getThemedColor(Theme.key_dialogTextBlack));
|
||||
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
titleTextView.setLinkTextColor(getThemedColor(Theme.key_dialogTextLink));
|
||||
titleTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
titleTextView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
|
||||
titleTextView.setPadding(AndroidUtilities.dp(18), AndroidUtilities.dp(6), AndroidUtilities.dp(18), AndroidUtilities.dp(6));
|
||||
titleTextView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
containerView.addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 50, Gravity.LEFT | Gravity.TOP, 0, 0, 40, 0));
|
||||
|
|
@ -1054,22 +1035,23 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
}
|
||||
if (stickerSet != null) {
|
||||
SpannableStringBuilder stringBuilder = null;
|
||||
CharSequence title = stickerSet.set.title;
|
||||
title = Emoji.replaceEmoji(title, titleTextView.getPaint().getFontMetricsInt(), AndroidUtilities.dp(18), false);
|
||||
try {
|
||||
if (urlPattern == null) {
|
||||
urlPattern = Pattern.compile("@[a-zA-Z\\d_]{1,32}");
|
||||
}
|
||||
Matcher matcher = urlPattern.matcher(stickerSet.set.title);
|
||||
Matcher matcher = urlPattern.matcher(title);
|
||||
while (matcher.find()) {
|
||||
if (stringBuilder == null) {
|
||||
stringBuilder = new SpannableStringBuilder(stickerSet.set.title);
|
||||
titleTextView.setMovementMethod(new LinkMovementMethodMy());
|
||||
stringBuilder = new SpannableStringBuilder(title);
|
||||
}
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
if (stickerSet.set.title.charAt(start) != '@') {
|
||||
start++;
|
||||
}
|
||||
URLSpanNoUnderline url = new URLSpanNoUnderline(stickerSet.set.title.subSequence(start + 1, end).toString()) {
|
||||
URLSpanNoUnderline url = new URLSpanNoUnderline(title.subSequence(start + 1, end).toString()) {
|
||||
@Override
|
||||
public void onClick(View widget) {
|
||||
MessagesController.getInstance(currentAccount).openByUserName(getURL(), parentFragment, 1);
|
||||
|
|
@ -1078,10 +1060,13 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
};
|
||||
stringBuilder.setSpan(url, start, end, 0);
|
||||
}
|
||||
if (stringBuilder != null) {
|
||||
title = stringBuilder;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
titleTextView.setText(stringBuilder != null ? stringBuilder : stickerSet.set.title);
|
||||
titleTextView.setText(title);
|
||||
|
||||
if (isEmoji()) {
|
||||
int width = gridView.getMeasuredWidth();
|
||||
|
|
@ -1148,11 +1133,11 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
} else if (notInstalled) {
|
||||
String text;
|
||||
if (stickerSet != null && stickerSet.set != null && stickerSet.set.masks) {
|
||||
text = LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("AddManyMasksCount", stickerSet.documents == null ? 0 : stickerSet.documents.size());
|
||||
} else if (stickerSet != null && stickerSet.set != null && stickerSet.set.emojis) {
|
||||
text = LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("EmojiCountButton", stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("AddManyEmojiCount", stickerSet.documents == null ? 0 : stickerSet.documents.size());
|
||||
} else {
|
||||
text = LocaleController.formatString("AddStickersCount", R.string.AddStickersCount, LocaleController.formatPluralString("Stickers", stickerSet.documents == null ? 0 : stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("AddManyStickersCount", stickerSet == null || stickerSet.documents == null ? 0 : stickerSet.documents.size());
|
||||
}
|
||||
setButton(v -> {
|
||||
dismiss();
|
||||
|
|
@ -1191,11 +1176,11 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
|
|||
} else {
|
||||
String text;
|
||||
if (stickerSet.set.masks) {
|
||||
text = LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("MasksCount", stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("RemoveManyMasksCount", stickerSet.documents.size());
|
||||
} else if (stickerSet.set.emojis) {
|
||||
text = LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("EmojiCountButton", stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("RemoveManyEmojiCount", stickerSet.documents.size());
|
||||
} else {
|
||||
text = LocaleController.formatString("RemoveStickersCount", R.string.RemoveStickersCount, LocaleController.formatPluralString("Stickers", stickerSet.documents.size()));
|
||||
text = LocaleController.formatPluralString("RemoveManyStickersCount", stickerSet.documents.size());
|
||||
}
|
||||
if (stickerSet.set.official) {
|
||||
setButton(v -> {
|
||||
|
|
|
|||
|
|
@ -11,14 +11,29 @@ import android.os.Build;
|
|||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
|
||||
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.DialogObject;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.ImageReceiver;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.CacheControlActivity;
|
||||
|
||||
public class StorageDiagramView extends View {
|
||||
public class StorageDiagramView extends View implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private RectF rectF = new RectF();
|
||||
private ClearViewData[] data;
|
||||
|
|
@ -27,11 +42,17 @@ public class StorageDiagramView extends View {
|
|||
private float[] startFromPercentage;
|
||||
|
||||
private float singleProgress = 0;
|
||||
TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
TextPaint textPaint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
StaticLayout layout1;
|
||||
StaticLayout layout2;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private ImageReceiver avatarImageReceiver;
|
||||
private Long dialogId;
|
||||
|
||||
AnimatedTextView.AnimatedTextDrawable text1 = new AnimatedTextView.AnimatedTextDrawable(false, true, true);
|
||||
AnimatedTextView.AnimatedTextDrawable text2 = new AnimatedTextView.AnimatedTextDrawable(false, true, false);
|
||||
|
||||
CharSequence dialogText;
|
||||
TextPaint dialogTextPaint;
|
||||
StaticLayout dialogTextLayout;
|
||||
|
||||
int enabledCount;
|
||||
|
||||
|
|
@ -39,20 +60,84 @@ public class StorageDiagramView extends View {
|
|||
|
||||
public StorageDiagramView(Context context) {
|
||||
super(context);
|
||||
text1.setCallback(this);
|
||||
text2.setCallback(this);
|
||||
}
|
||||
|
||||
public StorageDiagramView(Context context, long dialogId) {
|
||||
this(context);
|
||||
this.dialogId = dialogId;
|
||||
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
avatarDrawable.setScaleSize(1.5f);
|
||||
avatarImageReceiver = new ImageReceiver();
|
||||
avatarImageReceiver.setParentView(this);
|
||||
|
||||
if (dialogId == CacheControlActivity.UNKNOWN_CHATS_DIALOG_ID) {
|
||||
dialogText = LocaleController.getString("CacheOtherChats", R.string.CacheOtherChats);
|
||||
avatarDrawable.setAvatarType(AvatarDrawable.AVATAR_TYPE_OTHER_CHATS);
|
||||
avatarImageReceiver.setForUserOrChat(null, avatarDrawable);
|
||||
} else {
|
||||
TLObject dialog = MessagesController.getInstance(UserConfig.selectedAccount).getUserOrChat(dialogId);
|
||||
dialogText = DialogObject.setDialogPhotoTitle(avatarImageReceiver, avatarDrawable, dialog);
|
||||
dialogText = Emoji.replaceEmoji(dialogText, null, AndroidUtilities.dp(6), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(110), MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(110), MeasureSpec.EXACTLY)
|
||||
);
|
||||
rectF.set(AndroidUtilities.dp(3), AndroidUtilities.dp(3), getMeasuredWidth() - AndroidUtilities.dp(3), getMeasuredHeight() - AndroidUtilities.dp(3));
|
||||
updateDescription();
|
||||
textPaint.setTextSize(AndroidUtilities.dp(24));
|
||||
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
int left;
|
||||
if (dialogId != null) {
|
||||
super.onMeasure(
|
||||
widthMeasureSpec,
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(166), MeasureSpec.EXACTLY)
|
||||
);
|
||||
int w = MeasureSpec.getSize(widthMeasureSpec);
|
||||
left = (w - AndroidUtilities.dp(110)) / 2;
|
||||
rectF.set(left + AndroidUtilities.dp(3), AndroidUtilities.dp(3), left + AndroidUtilities.dp(110 - 3), AndroidUtilities.dp(110 - 3));
|
||||
} else {
|
||||
super.onMeasure(
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(110), MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(110), MeasureSpec.EXACTLY)
|
||||
);
|
||||
left = 0;
|
||||
rectF.set(AndroidUtilities.dp(3), AndroidUtilities.dp(3), AndroidUtilities.dp(110 - 3), AndroidUtilities.dp(110 - 3));
|
||||
}
|
||||
|
||||
textPaint2.setTextSize(AndroidUtilities.dp(13));
|
||||
text1.setAnimationProperties(.18f, 0, 300, CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
text1.setTextSize(AndroidUtilities.dp(24));
|
||||
text1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
|
||||
text2.setAnimationProperties(.18f, 0, 300, CubicBezierInterpolator.EASE_OUT_QUINT);
|
||||
|
||||
if (dialogId != null) {
|
||||
text2.setTextSize(AndroidUtilities.dp(16));
|
||||
text1.setGravity(Gravity.RIGHT);
|
||||
text2.setGravity(Gravity.LEFT);
|
||||
} else {
|
||||
text2.setTextSize(AndroidUtilities.dp(13));
|
||||
int t1h = (int) text1.getTextSize(), t2h = (int) text2.getTextSize();
|
||||
int top = (int) (AndroidUtilities.dp(110) - t1h - t2h) / 2;
|
||||
text1.setBounds(0, top, getMeasuredWidth(), top + t1h);
|
||||
text2.setBounds(0, top + t1h + AndroidUtilities.dp(2), getMeasuredWidth(), top + t1h + t2h + AndroidUtilities.dp(2));
|
||||
text1.setGravity(Gravity.CENTER);
|
||||
text2.setGravity(Gravity.CENTER);
|
||||
}
|
||||
|
||||
if (dialogText != null) {
|
||||
if (dialogTextPaint == null) {
|
||||
dialogTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
dialogTextPaint.setTextSize(AndroidUtilities.dp(13));
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec) - AndroidUtilities.dp(60);
|
||||
dialogTextLayout = StaticLayoutEx.createStaticLayout2(dialogText, dialogTextPaint, width, Layout.Alignment.ALIGN_CENTER, 1, 0, false, TextUtils.TruncateAt.END, width, 1);
|
||||
}
|
||||
if (avatarImageReceiver != null) {
|
||||
avatarImageReceiver.setImageCoords(left + AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(90), AndroidUtilities.dp(90));
|
||||
avatarImageReceiver.setRoundRadius(AndroidUtilities.dp(45));
|
||||
}
|
||||
|
||||
updateDescription();
|
||||
}
|
||||
|
||||
public void setData(ClearViewData[] data) {
|
||||
|
|
@ -69,16 +154,27 @@ public class StorageDiagramView extends View {
|
|||
} else {
|
||||
singleProgress = 1f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private long lastDrawTime;
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (avatarImageReceiver != null) {
|
||||
canvas.save();
|
||||
if (isPressed() && pressedProgress != 1f) {
|
||||
pressedProgress += (float) Math.min(40, 1000f / AndroidUtilities.screenRefreshRate) / 100f;
|
||||
pressedProgress = Utilities.clamp(pressedProgress, 1f, 0);
|
||||
invalidate();
|
||||
}
|
||||
float s = 0.85f + 0.15f * (1f - pressedProgress);
|
||||
canvas.scale(s, s, avatarImageReceiver.getCenterX(), avatarImageReceiver.getCenterY());
|
||||
}
|
||||
|
||||
if (enabledCount > 1) {
|
||||
if (singleProgress > 0) {
|
||||
singleProgress -= 0.04;
|
||||
|
|
@ -159,20 +255,31 @@ public class StorageDiagramView extends View {
|
|||
startFrom += percent;
|
||||
}
|
||||
|
||||
if (layout1 != null) {
|
||||
canvas.save();
|
||||
canvas.translate(
|
||||
(getMeasuredWidth() - layout1.getWidth()) >> 1,
|
||||
((getMeasuredHeight() - layout1.getHeight() - layout2.getHeight()) >> 1) + AndroidUtilities.dp(2)
|
||||
);
|
||||
textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
textPaint2.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
||||
layout1.draw(canvas);
|
||||
canvas.translate(0,layout1.getHeight());
|
||||
layout2.draw(canvas);
|
||||
if (avatarImageReceiver != null) {
|
||||
avatarImageReceiver.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
if (text1 != null) {
|
||||
text1.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
text2.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
if (dialogId != null) {
|
||||
int textWidth = text1.getCurrentWidth() + AndroidUtilities.dp(4) + text2.getCurrentWidth();
|
||||
int leftpad = (getWidth() - textWidth) / 2;
|
||||
text1.setBounds(0, AndroidUtilities.dp(115), leftpad + text1.getCurrentWidth(), AndroidUtilities.dp(115 + 30));
|
||||
text2.setBounds(leftpad + textWidth - text2.getCurrentWidth(), AndroidUtilities.dp(115 + 3), getWidth(), AndroidUtilities.dp(115 + 3 + 30));
|
||||
}
|
||||
text1.draw(canvas);
|
||||
text2.draw(canvas);
|
||||
}
|
||||
|
||||
if (dialogTextLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(AndroidUtilities.dp(30), AndroidUtilities.dp(148) - (dialogTextLayout.getHeight() - AndroidUtilities.dp(13)) / 2f);
|
||||
dialogTextPaint.setColor(Theme.getColor(Theme.key_dialogTextBlack));
|
||||
dialogTextLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClearViewData {
|
||||
|
|
@ -286,6 +393,66 @@ public class StorageDiagramView extends View {
|
|||
}
|
||||
}
|
||||
|
||||
protected void onAvatarClick() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean hitAvatar = (
|
||||
avatarImageReceiver != null && dialogId != null && dialogId != CacheControlActivity.UNKNOWN_CHATS_DIALOG_ID &&
|
||||
event.getX() > avatarImageReceiver.getImageX() && event.getX() <= avatarImageReceiver.getImageX2() &&
|
||||
event.getY() > avatarImageReceiver.getImageY() && event.getY() <= avatarImageReceiver.getImageY2()
|
||||
);
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (hitAvatar) {
|
||||
setPressed(true);
|
||||
return true;
|
||||
}
|
||||
} else if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
if (hitAvatar && event.getAction() != MotionEvent.ACTION_CANCEL) {
|
||||
AndroidUtilities.runOnUIThread(this::onAvatarClick, 80);
|
||||
}
|
||||
setPressed(false);
|
||||
return true;
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
float pressedProgress;
|
||||
ValueAnimator backAnimator;
|
||||
|
||||
@Override
|
||||
public void setPressed(boolean pressed) {
|
||||
if (isPressed() != pressed) {
|
||||
super.setPressed(pressed);
|
||||
invalidate();
|
||||
if (pressed) {
|
||||
if (backAnimator != null) {
|
||||
backAnimator.removeAllListeners();
|
||||
backAnimator.cancel();
|
||||
}
|
||||
}
|
||||
if (!pressed && pressedProgress != 0) {
|
||||
backAnimator = ValueAnimator.ofFloat(pressedProgress, 0);
|
||||
backAnimator.addUpdateListener(animation -> {
|
||||
pressedProgress = (float) animation.getAnimatedValue();
|
||||
invalidate();
|
||||
});
|
||||
backAnimator.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
backAnimator = null;
|
||||
}
|
||||
});
|
||||
backAnimator.setInterpolator(new OvershootInterpolator(2f));
|
||||
backAnimator.setDuration(350);
|
||||
backAnimator.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDescription() {
|
||||
if (data == null) {
|
||||
return;
|
||||
|
|
@ -299,8 +466,33 @@ public class StorageDiagramView extends View {
|
|||
}
|
||||
String[] str = AndroidUtilities.formatFileSize(total).split(" ");
|
||||
if (str.length > 1) {
|
||||
layout1 = new StaticLayout(total == 0 ? " " : str[0], textPaint, getMeasuredWidth(), Layout.Alignment.ALIGN_CENTER, 1f, 0, false);
|
||||
layout2 = new StaticLayout(total == 0 ? " " : str[1], textPaint2, getMeasuredWidth(), Layout.Alignment.ALIGN_CENTER, 1f, 0, false);
|
||||
text1.setText(total == 0 ? " " : str[0], true, false);
|
||||
text2.setText(total == 0 ? " " : str[1], true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
if (avatarImageReceiver != null) {
|
||||
avatarImageReceiver.onAttachedToWindow();
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (avatarImageReceiver != null) {
|
||||
avatarImageReceiver.onDetachedFromWindow();
|
||||
}
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.emojiLoaded) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.telegram.ui.ActionBar.Theme;
|
|||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.voip.CellFlickerDrawable;
|
||||
|
||||
public class StroageUsageView extends FrameLayout {
|
||||
public class StorageUsageView extends FrameLayout {
|
||||
|
||||
private Paint paintFill = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private Paint paintCalculcating = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
|
@ -57,7 +57,7 @@ public class StroageUsageView extends FrameLayout {
|
|||
|
||||
CellFlickerDrawable cellFlickerDrawable = new CellFlickerDrawable(220, 255);
|
||||
|
||||
public StroageUsageView(Context context) {
|
||||
public StorageUsageView(Context context) {
|
||||
super(context);
|
||||
setWillNotDraw(false);
|
||||
|
||||
|
|
@ -217,9 +217,8 @@ public class StroageUsageView extends FrameLayout {
|
|||
textSettingsCell.setVisibility(VISIBLE);
|
||||
telegramCacheTextView.setVisibility(View.VISIBLE);
|
||||
telegramDatabaseTextView.setVisibility(GONE);
|
||||
textSettingsCell.setText(LocaleController.getString("ClearTelegramCache", R.string.ClearTelegramCache), false);
|
||||
textSettingsCell.setTextAndValue(LocaleController.getString("ClearTelegramCache", R.string.ClearTelegramCache), AndroidUtilities.formatFileSize(totalSize), true);
|
||||
telegramCacheTextView.setText(LocaleController.formatString("TelegramCacheSize", R.string.TelegramCacheSize, AndroidUtilities.formatFileSize(totalSize + database)));
|
||||
|
||||
} else {
|
||||
telegramCacheTextView.setVisibility(View.GONE);
|
||||
telegramDatabaseTextView.setVisibility(VISIBLE);
|
||||
|
|
@ -299,7 +299,7 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter.
|
|||
searchRunnable = () -> {
|
||||
ArrayList<MediaDataController.KeywordResult> standard = new ArrayList<>(1);
|
||||
standard.add(new MediaDataController.KeywordResult(emoji, null));
|
||||
MediaDataController.getInstance(currentAccount).fillWithAnimatedEmoji(standard, 15, () -> {
|
||||
MediaDataController.getInstance(currentAccount).fillWithAnimatedEmoji(standard, 15, false, () -> {
|
||||
if (id == lastQueryId) {
|
||||
lastQuery = emoji;
|
||||
lastQueryType = 2;
|
||||
|
|
@ -541,16 +541,16 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter.
|
|||
|
||||
float leftAlpha = leftGradientAlpha.set(listView.canScrollHorizontally(-1) ? 1f : 0f);
|
||||
if (leftAlpha > 0) {
|
||||
Theme.chat_gradientLeftDrawable.setBounds((int) left, (int) top, (int) left + AndroidUtilities.dp(32), (int) bottom);
|
||||
Theme.chat_gradientLeftDrawable.setAlpha((int) (255 * leftAlpha));
|
||||
Theme.chat_gradientLeftDrawable.draw(canvas);
|
||||
Theme.chat_gradientRightDrawable.setBounds((int) left, (int) top, (int) left + AndroidUtilities.dp(32), (int) bottom);
|
||||
Theme.chat_gradientRightDrawable.setAlpha((int) (255 * leftAlpha));
|
||||
Theme.chat_gradientRightDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
float rightAlpha = rightGradientAlpha.set(listView.canScrollHorizontally(1) ? 1f : 0f);
|
||||
if (rightAlpha > 0) {
|
||||
Theme.chat_gradientRightDrawable.setBounds((int) right - AndroidUtilities.dp(32), (int) top, (int) right, (int) bottom);
|
||||
Theme.chat_gradientRightDrawable.setAlpha((int) (255 * rightAlpha));
|
||||
Theme.chat_gradientRightDrawable.draw(canvas);
|
||||
Theme.chat_gradientLeftDrawable.setBounds((int) right - AndroidUtilities.dp(32), (int) top, (int) right, (int) bottom);
|
||||
Theme.chat_gradientLeftDrawable.setAlpha((int) (255 * rightAlpha));
|
||||
Theme.chat_gradientLeftDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
|
|
@ -669,12 +669,20 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter.
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPressed(boolean pressed) {
|
||||
super.setPressed(pressed);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
float scale = 0.8f + 0.2f * (1f - pressed.set(isPressed() ? 1f : 0f));
|
||||
if (drawable != null) {
|
||||
int cx = getWidth() / 2, cy = (getHeight() - getPaddingBottom() + getPaddingTop()) / 2, w = getWidth() - getPaddingLeft() - getPaddingRight(), h = getHeight() - getPaddingTop() - getPaddingBottom();
|
||||
drawable.setBounds((int) (cx - w / 2 * scale), (int) (cy - h / 2 * scale), (int) (cx + w / 2 * scale), (int) (cy + h / 2 * scale));
|
||||
int cx = getWidth() / 2;
|
||||
int cy = (getHeight() - getPaddingBottom() + getPaddingTop()) / 2;
|
||||
drawable.setBounds(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom());
|
||||
canvas.scale(scale, scale, cx, cy);
|
||||
if (drawable instanceof AnimatedEmojiDrawable) {
|
||||
((AnimatedEmojiDrawable) drawable).setTime(System.currentTimeMillis());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import android.graphics.PorterDuff;
|
|||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.View;
|
||||
|
|
@ -96,6 +95,7 @@ public class SwipeGestureSettingsView extends FrameLayout {
|
|||
canvas.drawLine(AndroidUtilities.dp(2), y, getMeasuredWidth() - AndroidUtilities.dp(2), y, pickerDividersPaint);
|
||||
}
|
||||
};
|
||||
picker.setWrapSelectorWheel(true);
|
||||
picker.setMinValue(0);
|
||||
picker.setDrawDividers(false);
|
||||
hasTabs = !MessagesController.getInstance(currentAccount).dialogFilters.isEmpty();
|
||||
|
|
|
|||
|
|
@ -287,15 +287,7 @@ public class Switch extends View {
|
|||
onCheckedChangeListener.onCheckedChanged(this, checked);
|
||||
}
|
||||
}
|
||||
if (drawIconType != iconType) {
|
||||
drawIconType = iconType;
|
||||
if (attachedToWindow && animated) {
|
||||
animateIcon(iconType == 0);
|
||||
} else {
|
||||
cancelIconAnimator();
|
||||
setIconProgress(iconType == 0 ? 1.0f : 0.0f);
|
||||
}
|
||||
}
|
||||
setDrawIconType(iconType, animated);
|
||||
}
|
||||
|
||||
public void setIcon(int icon) {
|
||||
|
|
@ -310,6 +302,18 @@ public class Switch extends View {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void setDrawIconType(int iconType, boolean animated) {
|
||||
if (drawIconType != iconType) {
|
||||
drawIconType = iconType;
|
||||
if (attachedToWindow && animated) {
|
||||
animateIcon(iconType == 0);
|
||||
} else {
|
||||
cancelIconAnimator();
|
||||
setIconProgress(iconType == 0 ? 1.0f : 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasIcon() {
|
||||
return iconDrawable != null;
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue