update to 11.7.0 (5663)

This commit is contained in:
dkaraush 2025-01-26 19:30:37 +04:00
parent 9dcd88b8c1
commit eee720ef5e
432 changed files with 39485 additions and 33312 deletions

View file

@ -377,6 +377,17 @@ TL_username *TL_username::TLdeserialize(NativeByteBuffer *stream, uint32_t const
return result;
}
TL_peerColor *TL_peerColor::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
if (TL_peerColor::constructor != constructor) {
error = true;
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in TL_peerColor", constructor);
return nullptr;
}
TL_peerColor *result = new TL_peerColor();
result->readParams(stream, instanceNum, error);
return result;
}
void TL_restrictionReason::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
platform = stream->readString(&error);
reason = stream->readString(&error);
@ -405,6 +416,132 @@ void TL_username::serializeToStream(NativeByteBuffer *stream) {
stream->writeString(username);
}
void TL_peerColor::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
flags = stream->readInt32(&error);
if ((flags & 1) != 0) {
color = stream->readInt32(&error);
}
if ((flags & 2) != 0) {
background_emoji_id = stream->readInt64(&error);
}
}
void TL_peerColor::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
stream->writeInt32(flags);
if ((flags & 1) != 0) {
stream->writeInt32(color);
}
if ((flags & 2) != 0) {
stream->writeInt64(background_emoji_id);
}
}
EmojiStatus *EmojiStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
EmojiStatus *result = nullptr;
switch (constructor) {
case TL_emojiStatusEmpty::constructor:
result = new TL_emojiStatusEmpty();
break;
case TL_emojiStatus::constructor:
result = new TL_emojiStatus();
break;
case TL_emojiStatusCollectible::constructor:
result = new TL_emojiStatusCollectible();
break;
case TL_emojiStatus_layer197::constructor:
result = new TL_emojiStatus_layer197();
break;
case TL_emojiStatusUntil_layer197::constructor:
result = new TL_emojiStatusUntil_layer197();
break;
default:
error = true;
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in User", constructor);
return nullptr;
}
result->readParams(stream, instanceNum, error);
return result;
}
void TL_emojiStatusEmpty::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
}
void TL_emojiStatusEmpty::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
}
void TL_emojiStatus::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
flags = stream->readInt32(&error);
document_id = stream->readInt64(&error);
if ((flags & 1) != 0) {
until = stream->readInt64(&error);
}
}
void TL_emojiStatus::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
stream->writeInt32(flags);
stream->writeInt64(document_id);
if ((flags & 1) != 0) {
stream->writeInt32(until);
}
}
void TL_emojiStatus_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
document_id = stream->readInt64(&error);
}
void TL_emojiStatus_layer197::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
stream->writeInt64(document_id);
}
void TL_emojiStatusUntil_layer197::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
document_id = stream->readInt64(&error);
until = stream->readInt32(&error);
}
void TL_emojiStatusUntil_layer197::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
stream->writeInt64(document_id);
stream->writeInt32(until);
}
void TL_emojiStatusCollectible::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
flags = stream->readInt32(&error);
collectible_id = stream->readInt64(&error);
document_id = stream->readInt64(&error);
title = stream->readString(&error);
slug = stream->readString(&error);
pattern_document_id = stream->readInt64(&error);
center_color = stream->readInt32(&error);
edge_color = stream->readInt32(&error);
pattern_color = stream->readInt32(&error);
text_color = stream->readInt32(&error);
if ((flags & 1) != 0) {
until = stream->readInt64(&error);
}
}
void TL_emojiStatusCollectible::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
stream->writeInt32(flags);
stream->writeInt64(collectible_id);
stream->writeInt64(document_id);
stream->writeString(title);
stream->writeString(slug);
stream->writeInt64(pattern_document_id);
stream->writeInt32(center_color);
stream->writeInt32(edge_color);
stream->writeInt32(pattern_color);
stream->writeInt32(text_color);
if ((flags & 1) != 0) {
stream->writeInt32(until);
}
}
User *User::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
User *result = nullptr;
switch (constructor) {
@ -483,21 +620,7 @@ void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &er
lang_code = stream->readString(&error);
}
if ((flags & 1073741824) != 0) {
emojiStatusMagic = stream->readUint32(&error);
if (emojiStatusMagic == 0x2de11aae) {
// emojiStatusEmpty
} else if (emojiStatusMagic == 0x929b619d) {
// emojiStatus
emojiStatusDocumentId = stream->readInt64(&error);
} else if (emojiStatusMagic == 0xfa30a8c7) {
// emojiStatusUntil
emojiStatusDocumentId = stream->readInt64(&error);
emojiStatusUntil = stream->readInt32(&error);
} else {
error = true;
if (LOGS_ENABLED) DEBUG_FATAL("wrong EmojiStatus magic, got %x", emojiStatusMagic);
return;
}
emoji_status = std::unique_ptr<EmojiStatus>(EmojiStatus::TLdeserialize(stream, stream->readInt32(&error), instanceNum, error));
}
if ((flags2 & 1) != 0) {
uint32_t magic = stream->readUint32(&error);
@ -519,18 +642,17 @@ void TL_user::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &er
stories_max_id = stream->readInt32(&error);
}
if ((flags2 & 256) != 0) {
int magic = stream->readInt32(&error);
color_color = stream->readInt32(&error);
color_background_emoji_id = stream->readInt64(&error);
color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
}
if ((flags2 & 512) != 0) {
int magic = stream->readInt32(&error);
profile_color_color = stream->readInt32(&error);
profile_color_background_emoji_id = stream->readInt64(&error);
profile_color = std::unique_ptr<TL_peerColor>(TL_peerColor::TLdeserialize(stream, stream->readUint32(&error), instanceNum, error));
}
if ((flags2 & 4096) != 0) {
bot_active_users = stream->readInt32(&error);
}
if ((flags2 & 16384) != 0) {
bot_verification_icon = stream->readInt64(&error);
}
}
void TL_user::serializeToStream(NativeByteBuffer *stream) {
@ -577,15 +699,7 @@ void TL_user::serializeToStream(NativeByteBuffer *stream) {
stream->writeString(lang_code);
}
if ((flags & 1073741824) != 0) {
stream->writeInt32(emojiStatusMagic);
if (emojiStatusMagic == 0x929b619d) {
// emojiStatus
stream->writeInt64(emojiStatusDocumentId);
} else if (emojiStatusMagic == 0xfa30a8c7) {
// emojiStatusUntil
stream->writeInt64(emojiStatusDocumentId);
stream->writeInt32(emojiStatusUntil);
}
emoji_status->serializeToStream(stream);
}
if ((flags2 & 1) != 0) {
stream->writeInt32(0x1cb5c415);
@ -599,18 +713,17 @@ void TL_user::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(stories_max_id);
}
if ((flags2 & 256) != 0) {
stream->writeInt32(0xba278146);
stream->writeInt32(color_color);
stream->writeInt32(color_background_emoji_id);
color->serializeToStream(stream);
}
if ((flags2 & 512) != 0) {
stream->writeInt32(0xba278146);
stream->writeInt32(profile_color_color);
stream->writeInt32(profile_color_background_emoji_id);
profile_color->serializeToStream(stream);
}
if ((flags2 & 4096) != 0) {
stream->writeInt32(bot_active_users);
}
if ((flags2 & 16384) != 0) {
stream->writeInt64(bot_verification_icon);
}
}
InputPeer *InputPeer::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {

View file

@ -362,6 +362,85 @@ public:
void serializeToStream(NativeByteBuffer *stream);
};
class TL_peerColor : public TLObject {
public:
static const uint32_t constructor = 0xb54b5acf;
int32_t flags;
int32_t color;
int64_t background_emoji_id;
static TL_peerColor *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error);
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class EmojiStatus : public TLObject {
public:
static EmojiStatus *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error);
};
class TL_emojiStatusEmpty : public EmojiStatus {
public:
static const uint32_t constructor = 0xb54b5acf;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class TL_emojiStatus : public EmojiStatus {
public:
static const uint32_t constructor = 0xe7ff068a;
int32_t flags;
int64_t document_id;
int32_t until;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class TL_emojiStatus_layer197 : public EmojiStatus {
public:
static const uint32_t constructor = 0x929b619d;
int64_t document_id;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class TL_emojiStatusUntil_layer197 : public EmojiStatus {
public:
static const uint32_t constructor = 0xfa30a8c7;
int64_t document_id;
int32_t until;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class TL_emojiStatusCollectible : public EmojiStatus {
public:
static const uint32_t constructor = 0x7141dbf;
int32_t flags;
int64_t collectible_id;
int64_t document_id;
std::string title;
std::string slug;
int64_t pattern_document_id;
int32_t center_color;
int32_t edge_color;
int32_t pattern_color;
int32_t text_color;
int32_t until;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);
};
class User : public TLObject {
public:
@ -381,14 +460,11 @@ public:
std::string lang_code;
std::vector<std::unique_ptr<TL_username>> usernames;
int32_t stories_max_id;
int32_t emojiStatusMagic;
int64_t emojiStatusDocumentId;
int32_t emojiStatusUntil;
int32_t color_color;
int64_t color_background_emoji_id;
int32_t profile_color_color;
int64_t profile_color_background_emoji_id;
std::unique_ptr<EmojiStatus> emoji_status;
std::unique_ptr<TL_peerColor> color;
std::unique_ptr<TL_peerColor> profile_color;
int32_t bot_active_users;
int64_t bot_verification_icon;
static User *TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error);
};
@ -405,7 +481,7 @@ public:
class TL_user : public User {
public:
static const uint32_t constructor = 0x83314fca;
static const uint32_t constructor = 0x4b46c37e;
void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
void serializeToStream(NativeByteBuffer *stream);

View file

@ -1759,9 +1759,9 @@ int TurnEntry::Send(const void* data,
size_t size,
bool payload,
const rtc::PacketOptions& options) {
if (port_ == nullptr) return -1;
rtc::ByteBufferWriter buf;
if (state_ != STATE_BOUND ||
!port_->TurnCustomizerAllowChannelData(data, size, payload)) {
if (state_ != STATE_BOUND || !port_->TurnCustomizerAllowChannelData(data, size, payload)) {
// If we haven't bound the channel yet, we have to use a Send Indication.
// The turn_customizer_ can also make us use Send Indication.
TurnMessage msg(TURN_SEND_INDICATION);
@ -1781,6 +1781,7 @@ int TurnEntry::Send(const void* data,
state_ = STATE_BINDING;
}
} else {
if (data == nullptr && size > 0) return -1;
// If the channel is bound, we can send the data as a Channel Message.
buf.WriteUInt16(channel_id_);
buf.WriteUInt16(static_cast<uint16_t>(size));

View file

@ -453,3 +453,6 @@ table_background=177390847
table_border=436207615
dialogCardShadow=1073741824
dialogTopBackground=-13473128
share_icon=-1
share_linkText=-1207959553
share_linkBackground=352321535

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View file

@ -476,3 +476,6 @@ table_background=177390847
table_border=436207615
dialogCardShadow=1073741824
dialogTopBackground=-13473128
share_icon=-1
share_linkText=-1207959553
share_linkBackground=352321535

View file

@ -22,10 +22,14 @@ uniform vec3 specColor;
uniform vec2 resolution;
uniform vec4 gradientPosition;
uniform int modelIndex;
uniform int type;
uniform bool night;
uniform float time;
uniform mat4 world;
#define TYPE_COIN 1
#define TYPE_DEAL 3
void main() {
vec2 uv = vUV;
if (modelIndex == 2) {
@ -55,11 +59,22 @@ void main() {
vec3(0.39608, 0.18824, 0.98039),
diagonal
);
} else if (type == TYPE_DEAL) {
baseColor = mix(
vec3(0.91373, 0.62353, 0.99608),
vec3(0.67451, 0.58824, 1.00000),
clamp((uv.y - .1) / .8, 0.0, 1.0)
) * 1.05;
baseColor = mix(baseColor, vec3(1.0), .1 + .25 * texture2D(u_Texture, vUV).a);
if (night) {
baseColor = mix(baseColor, vec3(.0), .06);
}
} else {
baseColor = mix(
vec3(0.91373, 0.62353, 0.99608),
vec3(0.67451, 0.58824, 1.00000),
clamp((uv.y - .2) / .6, 0.0, 1.0)
clamp((uv.y - .1) / .8, 0.0, 1.0)
);
baseColor = mix(baseColor, vec3(1.0), .1 + .45 * texture2D(u_Texture, vUV).a);

View file

@ -439,12 +439,16 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
public boolean animateMove(RecyclerView.ViewHolder holder, ItemHolderInfo info, int fromX, int fromY, int toX, int toY) {
final View view = holder.itemView;
ChatMessageCell chatMessageCell = null;
ChatActionCell chatActionCell = null;
if (holder.itemView instanceof ChatMessageCell) {
chatMessageCell = ((ChatMessageCell) holder.itemView);
fromX += (int) chatMessageCell.getAnimationOffsetX();
if (chatMessageCell.getTransitionParams().lastTopOffset != chatMessageCell.getTopMediaOffset()) {
fromY += chatMessageCell.getTransitionParams().lastTopOffset - chatMessageCell.getTopMediaOffset();
}
} else if (holder.itemView instanceof ChatActionCell) {
chatActionCell = ((ChatActionCell) holder.itemView);
fromX += (int) holder.itemView.getTranslationX();
} else {
fromX += (int) holder.itemView.getTranslationX();
}
@ -689,16 +693,46 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
params.changePinnedBottomProgress = 0;
}
moveInfo.animateChangeInternal = chatMessageCell.getTransitionParams().animateChange();
moveInfo.animateChangeInternal = params.animateChange();
if (moveInfo.animateChangeInternal) {
chatMessageCell.getTransitionParams().animateChange = true;
chatMessageCell.getTransitionParams().animateChangeProgress = 0f;
params.animateChange = true;
params.animateChangeProgress = 0f;
}
if (deltaX == 0 && deltaY == 0 && !moveInfo.animateImage && !moveInfo.animateRemoveGroup && !moveInfo.animateChangeGroupBackground && !moveInfo.animatePinnedBottom && !moveInfo.animateBackgroundOnly && !moveInfo.animateChangeInternal) {
dispatchMoveFinished(holder);
return false;
}
} else if (chatActionCell != null) {
ChatActionCell.TransitionParams params = chatActionCell.getTransitionParams();
if (!params.supportChangeAnimation()) {
if (deltaX == 0 && deltaY == 0) {
dispatchMoveFinished(holder);
return false;
}
if (deltaX != 0) {
view.setTranslationX(-deltaX);
}
mPendingMoves.add(moveInfo);
checkIsRunning();
return true;
}
if (deltaX != 0) {
view.setTranslationX(-deltaX);
}
moveInfo.animateChangeInternal = params.animateChange();
if (moveInfo.animateChangeInternal) {
params.animateChange = true;
params.animateChangeProgress = 0f;
}
if (deltaX == 0 && deltaY == 0 && !moveInfo.animateChangeInternal) {
dispatchMoveFinished(holder);
return false;
}
} else if (holder.itemView instanceof BotHelpCell) {
BotHelpCell botInfo = (BotHelpCell) holder.itemView;
botInfo.setAnimating(true);
@ -902,6 +936,19 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
});
animatorSet.playTogether(valueAnimator);
}
} else if (holder.itemView instanceof ChatActionCell) {
ChatActionCell chatActionCell = (ChatActionCell) holder.itemView;
ChatActionCell.TransitionParams params = chatActionCell.getTransitionParams();
if (moveInfoExtended.animateChangeInternal) {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f);
params.animateChange = true;
valueAnimator.addUpdateListener(animation -> {
params.animateChangeProgress = (float) animation.getAnimatedValue();
chatActionCell.invalidate();
});
animatorSet.playTogether(valueAnimator);
}
}
if (withThanos) {
@ -1141,6 +1188,8 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
} else if (view instanceof ChatMessageCell) {
((ChatMessageCell) view).getTransitionParams().resetAnimation();
((ChatMessageCell) view).setAnimationOffsetX(0f);
} else if (view instanceof ChatActionCell) {
((ChatActionCell) view).getTransitionParams().resetAnimation();
} else {
view.setTranslationX(0f);
}

View file

@ -694,9 +694,7 @@ public class ItemTouchHelper extends RecyclerView.ItemDecoration
if (actionState == ACTION_STATE_DRAG) {
try {
mSelected.itemView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {
}
} catch (Exception ignore) {}
}
}
final ViewParent rvParent = mRecyclerView.getParent();

View file

@ -778,7 +778,8 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
sb.append(" ").append(super.toString())
.append(", adapter:").append(mAdapter)
.append(", layout:").append(mLayout)
.append(", context:").append(getContext());
.append(", context:").append(getContext())
.append(", ainfo:").append(moreInfo);
final String lastNotifies = mAdapterHelper.getLastNotifies();
if (lastNotifies != null) {
sb.append(", last notifies:\n").append(lastNotifies);
@ -786,6 +787,11 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
return sb.toString();
}
private String moreInfo;
public void setAdditionalDebugInfo(String moreInfo) {
this.moreInfo = moreInfo;
}
/**
* If not explicitly specified, this view and its children don't support autofill.
* <p>

View file

@ -305,6 +305,7 @@ public class AndroidUtilities {
public static Pattern BAD_CHARS_MESSAGE_PATTERN = null;
public static Pattern BAD_CHARS_MESSAGE_LONG_PATTERN = null;
public static Pattern REMOVE_MULTIPLE_DIACRITICS = null;
public static Pattern REMOVE_RTL = null;
private static Pattern singleTagPatter = null;
public static String removeDiacritics(String str) {
@ -315,6 +316,20 @@ public class AndroidUtilities {
return matcher.replaceAll("$1");
}
public static String removeRTL(String str) {
if (str == null) return null;
if (REMOVE_RTL == null) {
REMOVE_RTL = Pattern.compile("[\\u200E\\u200F\\u202A-\\u202E]");
}
Matcher matcher = REMOVE_RTL.matcher(str);
if (matcher == null) return str;
return matcher.replaceAll("");
}
public static String escape(String str) {
return removeRTL(removeDiacritics(str));
}
static {
try {
final String GOOD_IRI_CHAR = "a-zA-Z0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF";
@ -971,6 +986,16 @@ public class AndroidUtilities {
}
}
@RequiresApi(api = Build.VERSION_CODES.N)
public static void getBitmapFromSurface(SurfaceView surfaceView, Bitmap surfaceBitmap, Runnable done) {
if (surfaceView == null || ApplicationLoader.applicationHandler == null || !surfaceView.getHolder().getSurface().isValid()) {
return;
}
PixelCopy.request(surfaceView, surfaceBitmap, copyResult -> {
done.run();
}, ApplicationLoader.applicationHandler);
}
@RequiresApi(api = Build.VERSION_CODES.N)
public static void getBitmapFromSurface(Surface surface, Bitmap surfaceBitmap) {
if (surface == null || !surface.isValid()) {
@ -1018,6 +1043,13 @@ public class AndroidUtilities {
}
public static void doOnLayout(View view, Runnable runnable) {
if (runnable == null) {
return;
}
if (view == null) {
runnable.run();
return;
}
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
@ -2666,6 +2698,7 @@ public class AndroidUtilities {
}
ViewConfiguration vc = ViewConfiguration.get(context);
touchSlop = vc.getScaledTouchSlop();
isSmallScreen = null;
} catch (Exception e) {
FileLog.e(e);
}
@ -3212,6 +3245,14 @@ public class AndroidUtilities {
return new SpannableStringBuilder(str);
}
public static CharSequence replaceTags(CharSequence cs) {
if (cs instanceof SpannableStringBuilder) {
return replaceTags((SpannableStringBuilder) cs);
} else {
return replaceTags(new SpannableStringBuilder(cs));
}
}
public static SpannableStringBuilder replaceTags(SpannableStringBuilder stringBuilder) {
try {
int start;
@ -3753,6 +3794,23 @@ public class AndroidUtilities {
return formatDuration(duration, false);
}
public static String formatTimestamp(int duration) {
int h = duration / 3600;
int m = duration / 60 % 60;
int s = duration % 60;
if (h > 0) {
return String.format(Locale.US, "%dh%02dm%02ds", h, m, s);
}
if (m > 0) {
if (s > 0) {
return String.format(Locale.US, "%dm%02ds", m, s);
} else {
return String.format(Locale.US, "%dm", m);
}
}
return String.format(Locale.US, "%d", s);
}
public static String formatLongDuration(int duration) {
return formatDuration(duration, true);
}
@ -4898,6 +4956,10 @@ public class AndroidUtilities {
return a + f * (b - a);
}
public static float lerp(boolean a, boolean b, float f) {
return (a ? 1.0f : 0.0f) + f * ((b ? 1.0f : 0.0f) - (a ? 1.0f : 0.0f));
}
public static double lerp(double a, double b, float f) {
return a + f * (b - a);
}
@ -4946,6 +5008,24 @@ public class AndroidUtilities {
}
}
public static void lerp(float[] a, float[] b, float f, float[] to) {
if (to == null) return;
for (int i = 0; i < to.length; ++i) {
float av = a == null || i >= a.length ? 0 : a[i];
float bv = b == null || i >= b.length ? 0 : b[i];
to[i] = lerp(av, bv, f);
}
}
private static final float[] tempFloats = new float[9], tempFloats2 = new float[9];
public static void lerp(Matrix a, Matrix b, float t, Matrix to) {
if (a == null || b == null) return;
a.getValues(tempFloats);
b.getValues(tempFloats2);
lerp(tempFloats, tempFloats2, t, tempFloats2);
to.setValues(tempFloats2);
}
public static void scaleRect(RectF rect, float scale) {
scaleRect(rect, scale, rect.centerX(), rect.centerY());
}
@ -5401,8 +5481,8 @@ public class AndroidUtilities {
view.setVisibility(show ? View.VISIBLE : View.GONE);
view.setTag(show ? 1 : null);
view.setAlpha(1f);
view.setScaleX(scale && !show ? 0f : 1f);
view.setScaleY(scale && !show ? 0f : 1f);
view.setScaleX(scale && !show ? 0.5f : 1f);
view.setScaleY(scale && !show ? 0.5f : 1f);
if (translate != 0) {
view.setTranslationY(show ? 0 : AndroidUtilities.dp(-16) * translate);
}
@ -5413,8 +5493,8 @@ public class AndroidUtilities {
if (view.getVisibility() != View.VISIBLE) {
view.setVisibility(View.VISIBLE);
view.setAlpha(0f);
view.setScaleX(scale ? 0 : 1);
view.setScaleY(scale ? 0 : 1);
view.setScaleX(scale ? 0.5f : 1);
view.setScaleY(scale ? 0.5f : 1);
if (translate != 0) {
view.setTranslationY(AndroidUtilities.dp(-16) * translate);
}
@ -5427,7 +5507,7 @@ public class AndroidUtilities {
animate.start();
} else {
ViewPropertyAnimator animate = view.animate();
animate = animate.alpha(0).scaleY(scale ? 0 : 1).scaleX(scale ? 0 : 1).setListener(new HideViewAfterAnimation(view)).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).setDuration(340).withEndAction(onDone);
animate = animate.alpha(0).scaleY(scale ? 0.5f : 1).scaleX(scale ? 0.5f : 1).setListener(new HideViewAfterAnimation(view)).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).setDuration(340).withEndAction(onDone);
if (translate != 0) {
animate.translationY(AndroidUtilities.dp(-16) * translate);
}
@ -5629,7 +5709,7 @@ public class AndroidUtilities {
views.add((View) getRootView.invoke(wmgInstance, viewName));
}
return views;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
Class wmiClass = Class.forName("android.view.WindowManagerImpl");
Object wmiInstance = wmiClass.getMethod("getDefault").invoke(null);

View file

@ -1,17 +1,18 @@
package org.telegram.messenger;
import android.content.SharedPreferences;
import android.os.Build;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@ -62,7 +63,7 @@ public class BirthdayController {
MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> {
final ArrayList<TLRPC.User> users = MessagesStorage.getInstance(currentAccount).getUsers(uids);
AndroidUtilities.runOnUIThread(() -> {
TLRPC.TL_contacts_contactBirthdays contacts = new TLRPC.TL_contacts_contactBirthdays();
TL_account.contactBirthdays contacts = new TL_account.contactBirthdays();
contacts.contacts = birthdays.contacts;
contacts.users = users;
state = BirthdayState.from(contacts);
@ -104,10 +105,10 @@ public class BirthdayController {
}
loading = true;
ConnectionsManager.getInstance(currentAccount).sendRequest(new TLRPC.TL_account_getBirthdays(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TLRPC.TL_contacts_contactBirthdays) {
ConnectionsManager.getInstance(currentAccount).sendRequest(new TL_account.getBirthdays(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TL_account.contactBirthdays) {
lastCheckDate = System.currentTimeMillis();
TLRPC.TL_contacts_contactBirthdays response = (TLRPC.TL_contacts_contactBirthdays) res;
TL_account.contactBirthdays response = (TL_account.contactBirthdays) res;
state = BirthdayState.from(response);
MessagesController.getInstance(currentAccount).putUsers(response.users, false);
@ -171,7 +172,7 @@ public class BirthdayController {
this.tomorrowKey = tomorrowKey;
}
public static BirthdayState from(TLRPC.TL_contacts_contactBirthdays tl) {
public static BirthdayState from(TL_account.contactBirthdays tl) {
Calendar calendar = Calendar.getInstance();
int todayDay = calendar.get(Calendar.DAY_OF_MONTH);
int todayMonth = 1 + calendar.get(Calendar.MONTH);
@ -194,7 +195,7 @@ public class BirthdayController {
tomorrowDay + "_" + tomorrowMonth + "_" + tomorrowYear
);
for (TLRPC.TL_contactBirthday contact : tl.contacts) {
for (TL_account.TL_contactBirthday contact : tl.contacts) {
ArrayList<TLRPC.User> array = null;
if (contact.birthday.day == todayDay && contact.birthday.month == todayMonth) {
array = state.today;
@ -244,9 +245,9 @@ public class BirthdayController {
private static class TL_birthdays extends TLObject {
public static final int constructor = 0x114ff30d;
public ArrayList<TLRPC.TL_contactBirthday> contacts = new ArrayList<>();
public ArrayList<TL_account.TL_contactBirthday> contacts = new ArrayList<>();
public static TL_birthdays TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
public static TL_birthdays TLdeserialize(InputSerializedData stream, int constructor, boolean exception) {
if (constructor != TL_birthdays.constructor) {
if (exception) {
throw new RuntimeException(String.format("can't parse magic %x in TL_birthdays", constructor));
@ -259,7 +260,7 @@ public class BirthdayController {
}
@Override
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
@ -269,12 +270,12 @@ public class BirthdayController {
}
int count = stream.readInt32(exception);
for (int i = 0; i < count; ++i) {
contacts.add(TLRPC.TL_contactBirthday.TLdeserialize(stream, stream.readInt32(exception), exception));
contacts.add(TL_account.TL_contactBirthday.TLdeserialize(stream, stream.readInt32(exception), exception));
}
}
@Override
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(0x1cb5c415);
int count = contacts.size();
@ -299,7 +300,7 @@ public class BirthdayController {
return isToday(userFull.birthday);
}
public static boolean isToday(TLRPC.TL_birthday birthday) {
public static boolean isToday(TL_account.TL_birthday birthday) {
if (birthday == null) return false;
Calendar calendar = Calendar.getInstance();
int todayDay = calendar.get(Calendar.DAY_OF_MONTH);

View file

@ -28,13 +28,11 @@ public class CacheByChatsController {
private final int currentAccount;
int[] keepMediaByTypes = {-1, -1, -1, -1};
private boolean gotKeepMediaByTypes = false;
private final int[] keepMediaByTypes = { -1, -1, -1, -1 };
public CacheByChatsController(int currentAccount) {
this.currentAccount = currentAccount;
for (int i = 0; i < 4; i++) {
keepMediaByTypes[i] = SharedConfig.getPreferences().getInt("keep_media_type_" + i, getDefault(i));
}
}
public static int getDefault(int type) {
@ -122,6 +120,12 @@ public class CacheByChatsController {
}
public int getKeepMedia(int type) {
if (!gotKeepMediaByTypes) {
gotKeepMediaByTypes = true;
for (int i = 0; i < 4; i++) {
keepMediaByTypes[i] = SharedConfig.getPreferences().getInt("keep_media_type_" + i, getDefault(i));
}
}
if (keepMediaByTypes[type] == -1) {
return SharedConfig.keepMedia;
}
@ -129,6 +133,12 @@ public class CacheByChatsController {
}
public void setKeepMedia(int type, int keepMedia) {
if (!gotKeepMediaByTypes) {
gotKeepMediaByTypes = true;
for (int i = 0; i < 4; i++) {
keepMediaByTypes[i] = SharedConfig.getPreferences().getInt("keep_media_type_" + i, getDefault(i));
}
}
keepMediaByTypes[type] = keepMedia;
SharedConfig.getPreferences().edit().putInt("keep_media_type_" + type, keepMedia).apply();
}

View file

@ -10,9 +10,9 @@ import java.util.ArrayList;
public class ChatMessagesMetadataController {
final ChatActivity chatActivity;
private ArrayList<MessageObject> reactionsToCheck = new ArrayList<>(10);
private ArrayList<MessageObject> extendedMediaToCheck = new ArrayList<>(10);
private ArrayList<MessageObject> storiesToCheck = new ArrayList<>(10);
private final ArrayList<MessageObject> reactionsToCheck = new ArrayList<>(10);
private final ArrayList<MessageObject> extendedMediaToCheck = new ArrayList<>(10);
private final ArrayList<MessageObject> storiesToCheck = new ArrayList<>(10);
ArrayList<Integer> reactionsRequests = new ArrayList<>();
ArrayList<Integer> extendedMediaRequests = new ArrayList<>();
@ -38,7 +38,7 @@ public class ChatMessagesMetadataController {
storiesToCheck.clear();
for (int i = from; i < to; i++) {
MessageObject messageObject = messages.get(i);
if (chatActivity.getThreadMessage() != messageObject && messageObject.getId() > 0 && messageObject.messageOwner.action == null && (currentTime - messageObject.reactionsLastCheckTime) > 15000L) {
if (chatActivity.getThreadMessage() != messageObject && messageObject.getId() > 0 && (messageObject.messageOwner.action == null || messageObject.canSetReaction()) && (currentTime - messageObject.reactionsLastCheckTime) > 15000L) {
messageObject.reactionsLastCheckTime = currentTime;
reactionsToCheck.add(messageObject);
}

View file

@ -21,6 +21,7 @@ import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.voip.Instance;
import org.telegram.messenger.voip.VoIPService;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_phone;
import org.telegram.ui.GroupCallActivity;
import java.lang.annotation.Retention;
@ -270,7 +271,7 @@ public class ChatObject {
}
};
public void setCall(AccountInstance account, long chatId, TLRPC.TL_phone_groupCall groupCall) {
public void setCall(AccountInstance account, long chatId, TL_phone.groupCall groupCall) {
this.chatId = chatId;
currentAccount = account;
call = groupCall.call;
@ -308,7 +309,7 @@ public class ChatObject {
// }, ConnectionsManager.RequestFlagFailOnServerErrors, ConnectionsManager.ConnectionTypeDownload, call.stream_dc_id);
// }
public void createRtmpStreamParticipant(List<TLRPC.TL_groupCallStreamChannel> channels) {
public void createRtmpStreamParticipant(List<TL_phone.TL_groupCallStreamChannel> channels) {
if (loadedRtmpStreamParticipant && rtmpStreamParticipant != null) {
return;
}
@ -318,7 +319,7 @@ public class ChatObject {
participant.video = new TLRPC.TL_groupCallParticipantVideo();
TLRPC.TL_groupCallParticipantVideoSourceGroup sourceGroup = new TLRPC.TL_groupCallParticipantVideoSourceGroup();
sourceGroup.semantics = "SIM";
for (TLRPC.TL_groupCallStreamChannel channel : channels) {
for (TL_phone.TL_groupCallStreamChannel channel : channels) {
sourceGroup.sources.add(channel.channel);
}
participant.video.source_groups.add(sourceGroup);
@ -504,7 +505,7 @@ public class ChatObject {
reloadingMembers = true;
}
loadingMembers = true;
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
TL_phone.getGroupParticipants req = new TL_phone.getGroupParticipants();
req.call = getInputGroupCall();
req.offset = nextLoadOffset != null ? nextLoadOffset : "";
req.limit = 20;
@ -514,7 +515,7 @@ public class ChatObject {
reloadingMembers = false;
}
if (response != null) {
TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response;
TL_phone.groupParticipants groupParticipants = (TL_phone.groupParticipants) response;
currentAccount.getMessagesController().putUsers(groupParticipants.users, false);
currentAccount.getMessagesController().putChats(groupParticipants.chats, false);
onParticipantsLoad(groupParticipants.participants, fromBegin, req.offset, groupParticipants.next_offset, groupParticipants.version, groupParticipants.count);
@ -530,7 +531,7 @@ public class ChatObject {
}
public void setTitle(String title) {
TLRPC.TL_phone_editGroupCallTitle req = new TLRPC.TL_phone_editGroupCallTitle();
TL_phone.editGroupCallTitle req = new TL_phone.editGroupCallTitle();
req.call = getInputGroupCall();
req.title = title;
currentAccount.getConnectionsManager().sendRequest(req, (response, error) -> {
@ -596,7 +597,7 @@ public class ChatObject {
int guid = ++lastLoadGuid;
loadingGuids.add(guid);
set.addAll(participantsToLoad);
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
TL_phone.getGroupParticipants req = new TL_phone.getGroupParticipants();
req.call = getInputGroupCall();
for (int a = 0, N = participantsToLoad.size(); a < N; a++) {
long uid = participantsToLoad.get(a);
@ -628,7 +629,7 @@ public class ChatObject {
return;
}
if (response != null) {
TLRPC.TL_phone_groupParticipants groupParticipants = (TLRPC.TL_phone_groupParticipants) response;
TL_phone.groupParticipants groupParticipants = (TL_phone.groupParticipants) response;
currentAccount.getMessagesController().putUsers(groupParticipants.users, false);
currentAccount.getMessagesController().putChats(groupParticipants.chats, false);
for (int a = 0, N = groupParticipants.participants.size(); a < N; a++) {
@ -915,12 +916,12 @@ public class ChatObject {
}
public void reloadGroupCall() {
TLRPC.TL_phone_getGroupCall req = new TLRPC.TL_phone_getGroupCall();
TL_phone.getGroupCall req = new TL_phone.getGroupCall();
req.call = getInputGroupCall();
req.limit = 100;
currentAccount.getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_phone_groupCall) {
TLRPC.TL_phone_groupCall phoneGroupCall = (TLRPC.TL_phone_groupCall) response;
if (response instanceof TL_phone.groupCall) {
TL_phone.groupCall phoneGroupCall = (TL_phone.groupCall) response;
call = phoneGroupCall.call;
currentAccount.getMessagesController().putUsers(phoneGroupCall.users, false);
currentAccount.getMessagesController().putChats(phoneGroupCall.chats, false);
@ -934,7 +935,7 @@ public class ChatObject {
return;
}
loadingGroupCall = true;
TLRPC.TL_phone_getGroupParticipants req = new TLRPC.TL_phone_getGroupParticipants();
TL_phone.getGroupParticipants req = new TL_phone.getGroupParticipants();
req.call = getInputGroupCall();
req.offset = "";
req.limit = 1;
@ -942,7 +943,7 @@ public class ChatObject {
lastGroupCallReloadTime = SystemClock.elapsedRealtime();
loadingGroupCall = false;
if (response != null) {
TLRPC.TL_phone_groupParticipants res = (TLRPC.TL_phone_groupParticipants) response;
TL_phone.groupParticipants res = (TL_phone.groupParticipants) response;
currentAccount.getMessagesController().putUsers(res.users, false);
currentAccount.getMessagesController().putChats(res.chats, false);
if (call.participants_count != res.count) {
@ -1468,7 +1469,7 @@ public class ChatObject {
public void toggleRecord(String title, @RecordType int type) {
recording = !recording;
TLRPC.TL_phone_toggleGroupCallRecord req = new TLRPC.TL_phone_toggleGroupCallRecord();
TL_phone.toggleGroupCallRecord req = new TL_phone.toggleGroupCallRecord();
req.call = getInputGroupCall();
req.start = recording;
if (title != null) {
@ -2275,8 +2276,18 @@ public class ChatObject {
}
public static long getProfileEmojiId(TLRPC.Chat chat) {
if (chat != null && chat.emoji_status instanceof TLRPC.TL_emojiStatusCollectible) {
return ((TLRPC.TL_emojiStatusCollectible) chat.emoji_status).pattern_document_id;
}
if (chat != null && chat.profile_color != null && (chat.profile_color.flags & 2) != 0) return chat.profile_color.background_emoji_id;
return 0;
}
public static long getProfileCollectibleId(TLRPC.Chat chat) {
if (chat != null && chat.emoji_status instanceof TLRPC.TL_emojiStatusCollectible) {
return ((TLRPC.TL_emojiStatusCollectible) chat.emoji_status).collectible_id;
}
return 0;
}
}

View file

@ -11,6 +11,7 @@ import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.ResultCallback;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.ui.ActionBar.EmojiThemes;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ChatBackgroundDrawable;
@ -72,13 +73,13 @@ public class ChatThemeController extends BaseController {
boolean needReload = System.currentTimeMillis() - lastReloadTimeMs > reloadTimeoutMs;
if (allChatThemes == null || allChatThemes.isEmpty() || needReload) {
TLRPC.TL_account_getChatThemes request = new TLRPC.TL_account_getChatThemes();
TL_account.getChatThemes request = new TL_account.getChatThemes();
request.hash = themesHash;
ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(request, (response, error) -> chatThemeQueue.postRunnable(() -> {
boolean isError = false;
final List<EmojiThemes> chatThemes;
if (response instanceof TLRPC.TL_account_themes) {
TLRPC.TL_account_themes resp = (TLRPC.TL_account_themes) response;
if (response instanceof TL_account.TL_themes) {
TL_account.TL_themes resp = (TL_account.TL_themes) response;
themesHash = resp.hash;
lastReloadTimeMs = System.currentTimeMillis();
@ -99,7 +100,7 @@ public class ChatThemeController extends BaseController {
chatThemes.add(chatTheme);
}
editor.apply();
} else if (response instanceof TLRPC.TL_account_themesNotModified) {
} else if (response instanceof TL_account.TL_themesNotModified) {
// if (allChatThemes == null || allChatThemes.isEmpty()) {
chatThemes = getAllChatThemesFromPrefs();
// } else {

View file

@ -31,12 +31,12 @@ import android.util.SparseArray;
import androidx.annotation.NonNull;
import androidx.collection.LongSparseArray;
import com.google.android.exoplayer2.util.Log;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.Bulletin;
@ -2585,10 +2585,10 @@ public class ContactsController extends BaseController {
editor.putBoolean("needGetStatuses", true).commit();
TLRPC.TL_contacts_getStatuses req = new TLRPC.TL_contacts_getStatuses();
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
if (response instanceof Vector) {
AndroidUtilities.runOnUIThread(() -> {
editor.remove("needGetStatuses").commit();
TLRPC.Vector vector = (TLRPC.Vector) response;
Vector vector = (Vector) response;
if (!vector.objects.isEmpty()) {
ArrayList<TLRPC.User> dbUsersStatus = new ArrayList<>();
for (Object object : vector.objects) {
@ -2624,7 +2624,7 @@ public class ContactsController extends BaseController {
public void loadGlobalPrivacySetting() {
if (loadingGlobalSettings == 0) {
loadingGlobalSettings = 1;
TLRPC.TL_account_getGlobalPrivacySettings req = new TLRPC.TL_account_getGlobalPrivacySettings();
TL_account.getGlobalPrivacySettings req = new TL_account.getGlobalPrivacySettings();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
globalPrivacySettings = (TLRPC.TL_globalPrivacySettings) response;
@ -2640,7 +2640,7 @@ public class ContactsController extends BaseController {
public void loadPrivacySettings() {
if (loadingDeleteInfo == 0) {
loadingDeleteInfo = 1;
TLRPC.TL_account_getAccountTTL req = new TLRPC.TL_account_getAccountTTL();
TL_account.getAccountTTL req = new TL_account.getAccountTTL();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
TLRPC.TL_accountDaysTTL ttl = (TLRPC.TL_accountDaysTTL) response;
@ -2660,7 +2660,7 @@ public class ContactsController extends BaseController {
loadingPrivacyInfo[a] = 1;
final int num = a;
TLRPC.TL_account_getPrivacy req = new TLRPC.TL_account_getPrivacy();
TL_account.getPrivacy req = new TL_account.getPrivacy();
switch (num) {
case PRIVACY_RULES_TYPE_LASTSEEN:
@ -2705,7 +2705,7 @@ public class ContactsController extends BaseController {
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
TLRPC.TL_account_privacyRules rules = (TLRPC.TL_account_privacyRules) response;
TL_account.privacyRules rules = (TL_account.privacyRules) response;
getMessagesController().putUsers(rules.users, false);
getMessagesController().putChats(rules.chats, false);

View file

@ -1535,6 +1535,25 @@ public class DatabaseMigrationHelper {
version = 159;
}
if (version == 159) {
database.executeFast("ALTER TABLE dialog_filter ADD COLUMN entities BLOB").stepThis().dispose();
database.executeFast("PRAGMA user_version = 160").stepThis().dispose();
version = 160;
}
if (version == 160) {
database.executeFast("ALTER TABLE dialog_filter ADD COLUMN noanimate INTEGER").stepThis().dispose();
database.executeFast("PRAGMA user_version = 161").stepThis().dispose();
version = 161;
}
if (version == 161) {
database.executeFast("DELETE FROM popular_bots").stepThis().dispose();
database.executeFast("ALTER TABLE popular_bots ADD COLUMN pos INTEGER").stepThis().dispose();
database.executeFast("PRAGMA user_version = 162").stepThis().dispose();
version = 162;
}
return version;
}

View file

@ -10,13 +10,15 @@ package org.telegram.messenger;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import java.util.ArrayList;
import java.util.HashSet;
public class DialogObject {
@ -153,6 +155,49 @@ public class DialogObject {
return title;
}
@NonNull
public static String getName(long dialogId) {
return getName(MessagesController.getInstance(UserConfig.selectedAccount).getUserOrChat(dialogId));
}
@NonNull
public static String getName(TLObject obj) {
if (obj instanceof TLRPC.User) {
return UserObject.getUserName((TLRPC.User) obj);
} else if (obj instanceof TLRPC.Chat) {
final TLRPC.Chat chat = (TLRPC.Chat) obj;
return chat != null ? chat.title : "";
} else {
return "";
}
}
@NonNull
public static String getShortName(long dialogId) {
return getShortName(MessagesController.getInstance(UserConfig.selectedAccount).getUserOrChat(dialogId));
}
@NonNull
public static String getShortName(TLObject obj) {
if (obj instanceof TLRPC.User) {
return UserObject.getForcedFirstName((TLRPC.User) obj);
} else if (obj instanceof TLRPC.Chat) {
final TLRPC.Chat chat = (TLRPC.Chat) obj;
return chat != null ? chat.title : "";
} else {
return "";
}
}
public static boolean hasPhoto(TLObject obj) {
if (obj instanceof TLRPC.User) {
return ((TLRPC.User) obj).photo != null;
} else if (obj instanceof TLRPC.Chat) {
return ((TLRPC.Chat) obj).photo != null;
}
return false;
}
public static String setDialogPhotoTitle(BackupImageView imageView, TLObject dialog) {
if (imageView != null) {
return setDialogPhotoTitle(imageView.getImageReceiver(), imageView.getAvatarDrawable(), dialog);
@ -262,28 +307,107 @@ public class DialogObject {
return costs[s2.length()];
}
public static boolean isEmojiStatusCollectible(long dialogId) {
if (dialogId >= 0) {
final TLRPC.User user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(dialogId);
if (user == null) return false;
return isEmojiStatusCollectible(user.emoji_status);
} else {
final TLRPC.Chat chat = MessagesController.getInstance(UserConfig.selectedAccount).getChat(-dialogId);
if (chat == null) return false;
return isEmojiStatusCollectible(chat.emoji_status);
}
}
public static boolean isEmojiStatusCollectible(TLRPC.EmojiStatus emojiStatus) {
if (MessagesController.getInstance(UserConfig.selectedAccount).premiumFeaturesBlocked()) {
return false;
}
if (emojiStatus instanceof TLRPC.TL_emojiStatusCollectible) {
final TLRPC.TL_emojiStatusCollectible status = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return false;
}
return true;
}
return false;
}
public static long getEmojiStatusDocumentId(long dialogId) {
if (dialogId >= 0) {
final TLRPC.User user = MessagesController.getInstance(UserConfig.selectedAccount).getUser(dialogId);
if (user == null) return 0;
return getEmojiStatusDocumentId(user.emoji_status);
} else {
final TLRPC.Chat chat = MessagesController.getInstance(UserConfig.selectedAccount).getChat(-dialogId);
if (chat == null) return 0;
return getEmojiStatusDocumentId(chat.emoji_status);
}
}
public static long getEmojiStatusDocumentId(TLRPC.EmojiStatus emojiStatus) {
if (MessagesController.getInstance(UserConfig.selectedAccount).premiumFeaturesBlocked()) {
return 0;
}
if (emojiStatus instanceof TLRPC.TL_emojiStatus) {
return ((TLRPC.TL_emojiStatus) emojiStatus).document_id;
} else if (emojiStatus instanceof TLRPC.TL_emojiStatusUntil && ((TLRPC.TL_emojiStatusUntil) emojiStatus).until > (int) (System.currentTimeMillis() / 1000)) {
return ((TLRPC.TL_emojiStatusUntil) emojiStatus).document_id;
} else {
return 0;
}
}
public static int getEmojiStatusUntil(TLRPC.EmojiStatus emojiStatus) {
if (emojiStatus instanceof TLRPC.TL_emojiStatusUntil && ((TLRPC.TL_emojiStatusUntil) emojiStatus).until > (int) (System.currentTimeMillis() / 1000)) {
return ((TLRPC.TL_emojiStatusUntil) emojiStatus).until;
final TLRPC.TL_emojiStatus status = (TLRPC.TL_emojiStatus) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return 0;
}
return status.document_id;
} else if (emojiStatus instanceof TLRPC.TL_emojiStatusCollectible) {
final TLRPC.TL_emojiStatusCollectible status = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return 0;
}
return status.document_id;
}
return 0;
}
public static long getEmojiStatusCollectibleId(TLRPC.EmojiStatus emojiStatus) {
if (MessagesController.getInstance(UserConfig.selectedAccount).premiumFeaturesBlocked()) {
return 0;
}
if (emojiStatus instanceof TLRPC.TL_emojiStatusCollectible) {
final TLRPC.TL_emojiStatusCollectible status = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return 0;
}
return status.collectible_id;
}
return 0;
}
public static int getEmojiStatusUntil(TLRPC.EmojiStatus emojiStatus) {
if (emojiStatus instanceof TLRPC.TL_emojiStatus) {
final TLRPC.TL_emojiStatus status = (TLRPC.TL_emojiStatus) emojiStatus;
if ((status.flags & 1) != 0) {
return status.until;
}
} else if (emojiStatus instanceof TLRPC.TL_emojiStatusCollectible) {
final TLRPC.TL_emojiStatusCollectible status = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
if ((status.flags & 1) != 0) {
return status.until;
}
}
return 0;
}
public static TLRPC.EmojiStatus filterEmojiStatus(TLRPC.EmojiStatus emojiStatus) {
final int until = getEmojiStatusUntil(emojiStatus);
if (until != 0 && until <= (int) (System.currentTimeMillis() / 1000)) {
return null;
}
return emojiStatus;
}
public static boolean emojiStatusesEqual(TLRPC.EmojiStatus a, TLRPC.EmojiStatus b) {
return getEmojiStatusDocumentId(a) == getEmojiStatusDocumentId(b) && getEmojiStatusUntil(a) == getEmojiStatusUntil(b);
return (
getEmojiStatusDocumentId(a) == getEmojiStatusDocumentId(b) &&
getEmojiStatusCollectibleId(a) == getEmojiStatusCollectibleId(b) &&
getEmojiStatusUntil(a) == getEmojiStatusUntil(b)
);
}
public static TLRPC.TL_username findUsername(String username, TLRPC.User user) {
@ -306,4 +430,24 @@ public class DialogObject {
return null;
}
public static TL_bots.botVerification getBotVerification(TLObject object) {
if (object instanceof TLRPC.UserFull) {
return ((TLRPC.UserFull) object).bot_verification;
} else if (object instanceof TLRPC.ChatFull) {
return ((TLRPC.ChatFull) object).bot_verification;
} else {
return null;
}
}
public static long getBotVerificationIcon(TLObject object) {
if (object instanceof TLRPC.User) {
return ((TLRPC.User) object).bot_verification_icon;
} else if (object instanceof TLRPC.Chat) {
return ((TLRPC.Chat) object).bot_verification_icon;
} else {
return 0;
}
}
}

View file

@ -1,5 +1,7 @@
package org.telegram.messenger;
import android.os.Build;
import android.os.Looper;
import android.os.SystemClock;
import android.util.SparseIntArray;
@ -11,16 +13,16 @@ import java.util.LinkedList;
public class DispatchQueuePool {
private LinkedList<DispatchQueue> queues = new LinkedList<>();
private SparseIntArray busyQueuesMap = new SparseIntArray();
private LinkedList<DispatchQueue> busyQueues = new LinkedList<>();
private final LinkedList<DispatchQueue> queues = new LinkedList<>();
private final SparseIntArray busyQueuesMap = new SparseIntArray();
private final LinkedList<DispatchQueue> busyQueues = new LinkedList<>();
private int maxCount;
private int createdCount;
private int guid;
private int totalTasksCount;
private boolean cleanupScheduled;
private Runnable cleanupRunnable = new Runnable() {
private final Runnable cleanupRunnable = new Runnable() {
@Override
public void run() {
if (!queues.isEmpty()) {
@ -52,6 +54,10 @@ public class DispatchQueuePool {
@UiThread
public void execute(Runnable runnable) {
if (Looper.myLooper() != Looper.getMainLooper()) {
AndroidUtilities.runOnUIThread(() -> execute(runnable));
return;
}
DispatchQueue queue;
if (!busyQueues.isEmpty() && (totalTasksCount / 2 <= busyQueues.size() || queues.isEmpty() && createdCount >= maxCount)) {
queue = busyQueues.remove(0);

View file

@ -24,6 +24,7 @@ import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.LaunchActivity;
@ -352,13 +353,13 @@ public class DownloadController extends BaseController implements NotificationCe
return;
}
loadingAutoDownloadConfig = true;
TLRPC.TL_account_getAutoDownloadSettings req = new TLRPC.TL_account_getAutoDownloadSettings();
TL_account.getAutoDownloadSettings req = new TL_account.getAutoDownloadSettings();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingAutoDownloadConfig = false;
getUserConfig().autoDownloadConfigLoadTime = System.currentTimeMillis();
getUserConfig().saveConfig(false);
if (response != null) {
TLRPC.TL_account_autoDownloadSettings res = (TLRPC.TL_account_autoDownloadSettings) response;
TL_account.autoDownloadSettings res = (TL_account.autoDownloadSettings) response;
lowPreset.set(res.low);
lowPreset.preloadStories = false;
mediumPreset.set(res.medium);
@ -666,6 +667,24 @@ public class DownloadController extends BaseController implements NotificationCe
return canDownloadMediaInternal(messageObject);
}
public int canDownloadMediaType(MessageObject messageObject, long overrideSize) {
if (messageObject.type == MessageObject.TYPE_STORY) {
if (!SharedConfig.isAutoplayVideo()) return 0;
TLRPC.TL_messageMediaStory mediaStory = (TLRPC.TL_messageMediaStory) MessageObject.getMedia(messageObject);
TL_stories.StoryItem storyItem = mediaStory.storyItem;
if (storyItem == null || storyItem.media == null || storyItem.media.document == null || !storyItem.isPublic) {
return 0;
}
return 2;
}
if (messageObject.sponsoredMedia != null) {
return 2;
}
if (messageObject.isHiddenSensitive())
return 0;
return canDownloadMediaInternal(messageObject, overrideSize);
}
private int canDownloadMediaInternal(MessageObject message) {
if (message == null || message.messageOwner == null) return 0;
if (message.messageOwner.media instanceof TLRPC.TL_messageMediaStory) {
@ -756,6 +775,89 @@ public class DownloadController extends BaseController implements NotificationCe
}
}
private int canDownloadMediaInternal(MessageObject message, long overrideSize) {
if (message == null || message.messageOwner == null) return 0;
if (message.messageOwner.media instanceof TLRPC.TL_messageMediaStory) {
return canPreloadStories() ? 2 : 0;
}
TLRPC.Message msg = message.messageOwner;
int type;
boolean isVideo;
if ((isVideo = MessageObject.isVideoMessage(msg)) || MessageObject.isGifMessage(msg) || MessageObject.isRoundVideoMessage(msg) || MessageObject.isGameMessage(msg)) {
type = AUTODOWNLOAD_TYPE_VIDEO;
} else if (MessageObject.isVoiceMessage(msg)) {
type = AUTODOWNLOAD_TYPE_AUDIO;
} else if (MessageObject.isPhoto(msg) || MessageObject.isStickerMessage(msg) || MessageObject.isAnimatedStickerMessage(msg)) {
type = AUTODOWNLOAD_TYPE_PHOTO;
} else if (MessageObject.getDocument(msg) != null) {
type = AUTODOWNLOAD_TYPE_DOCUMENT;
} else {
return 0;
}
int index;
TLRPC.Peer peer = msg.peer_id;
if (peer != null) {
if (peer.user_id != 0) {
if (getContactsController().contactsDict.containsKey(peer.user_id)) {
index = 0;
} else {
index = 1;
}
} else if (peer.chat_id != 0) {
if (msg.from_id instanceof TLRPC.TL_peerUser && getContactsController().contactsDict.containsKey(msg.from_id.user_id)) {
index = 0;
} else {
index = 2;
}
} else {
TLRPC.Chat chat = msg.peer_id.channel_id != 0 ? getMessagesController().getChat(msg.peer_id.channel_id) : null;
if (ChatObject.isChannel(chat) && chat.megagroup) {
if (msg.from_id instanceof TLRPC.TL_peerUser && getContactsController().contactsDict.containsKey(msg.from_id.user_id)) {
index = 0;
} else {
index = 2;
}
} else {
index = 3;
}
}
} else {
index = 1;
}
Preset preset;
int networkType = ApplicationLoader.getAutodownloadNetworkType();
if (networkType == StatsController.TYPE_WIFI) {
if (!wifiPreset.enabled) {
return 0;
}
preset = getCurrentWiFiPreset();
} else if (networkType == StatsController.TYPE_ROAMING) {
if (!roamingPreset.enabled) {
return 0;
}
preset = getCurrentRoamingPreset();
} else {
if (!mobilePreset.enabled) {
return 0;
}
preset = getCurrentMobilePreset();
}
final int mask = preset.mask[index];
final long maxSize;
if (type == AUTODOWNLOAD_TYPE_AUDIO) {
maxSize = Math.max(512 * 1024, preset.sizes[typeToIndex(type)]);
} else {
maxSize = preset.sizes[typeToIndex(type)];
}
final long size = overrideSize;
if (isVideo && preset.preloadVideo && size > maxSize && maxSize > 2 * 1024 * 1024) {
return (mask & type) != 0 ? 2 : 0;
} else {
return (type == AUTODOWNLOAD_TYPE_PHOTO || size != 0 && size <= maxSize) && (type == AUTODOWNLOAD_TYPE_AUDIO || (mask & type) != 0) ? 1 : 0;
}
}
public int canDownloadMedia(TLRPC.Message message) {
if (message == null || message.media instanceof TLRPC.TL_messageMediaStory) {
return canPreloadStories() ? 2 : 0;
@ -963,7 +1065,7 @@ public class DownloadController extends BaseController implements NotificationCe
}
public void savePresetToServer(int type) {
TLRPC.TL_account_saveAutoDownloadSettings req = new TLRPC.TL_account_saveAutoDownloadSettings();
TL_account.saveAutoDownloadSettings req = new TL_account.saveAutoDownloadSettings();
Preset preset;
boolean enabled;
if (type == 0) {

View file

@ -28,7 +28,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.checkerframework.checker.units.qual.A;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedEmojiDrawable;
import org.telegram.ui.Components.AnimatedEmojiSpan;
@ -563,8 +562,8 @@ public class Emoji {
return replaceEmoji(cs, fontMetrics, createNew, null);
}
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, int size, boolean createNew) {
return replaceEmoji(cs, fontMetrics, createNew, null);
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, boolean createNew, float scale) {
return replaceEmoji(cs, fontMetrics, createNew, null, DynamicDrawableSpan.ALIGN_BOTTOM, scale);
}
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, boolean createNew, int[] emojiOnly) {
@ -572,7 +571,11 @@ public class Emoji {
}
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, boolean createNew, int[] emojiOnly, int alignment) {
if (SharedConfig.useSystemEmoji || cs == null || cs.length() == 0) {
return replaceEmoji(cs, fontMetrics, createNew, emojiOnly, alignment, 1.0f);
}
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, boolean createNew, int[] emojiOnly, int alignment, float scale) {
if (SharedConfig.useSystemEmoji || cs == null || cs.length() == 0) {
return cs;
}
Spannable s;
@ -624,6 +627,7 @@ public class Emoji {
if (drawable != null) {
span = new EmojiSpan(drawable, alignment, fontMetrics);
span.emoji = emojiRange.code == null ? null : emojiRange.code.toString();
span.scale = scale;
s.setSpan(span, emojiRange.start, emojiRange.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} catch (Exception e) {

View file

@ -36,6 +36,7 @@ import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.AlertDialogDecor;
import org.telegram.ui.ActionBar.BaseFragment;
@ -175,8 +176,8 @@ public class FactCheckController {
if (!req.msg_id.isEmpty()) {
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
ArrayList<TLRPC.TL_factCheck> factChecks = new ArrayList<>();
if (res instanceof TLRPC.Vector) {
ArrayList<Object> objects = ((TLRPC.Vector) res).objects;
if (res instanceof Vector) {
ArrayList<Object> objects = ((Vector) res).objects;
for (int k = 0; k < objects.size(); ++k) {
if (objects.get(k) instanceof TLRPC.TL_factCheck) {
factChecks.add((TLRPC.TL_factCheck) objects.get(k));
@ -481,7 +482,9 @@ public class FactCheckController {
ignoreTextChange = true;
s.delete(MAX_LENGTH, s.length());
AndroidUtilities.shakeView(editText);
editText.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
try {
editText.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {}
ignoreTextChange = false;
}
@ -573,7 +576,9 @@ public class FactCheckController {
progressDialog.showDelayed(320);
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TLRPC.Updates) {
MessagesController.getInstance(currentAccount).processUpdates((TLRPC.Updates) res, false);
Utilities.stageQueue.postRunnable(() -> {
MessagesController.getInstance(currentAccount).processUpdates((TLRPC.Updates) res, false);
});
BaseFragment fragment = LaunchActivity.getSafeLastFragment();
if (fragment != null) {

View file

@ -13,6 +13,7 @@ import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.Storage.CacheModel;
@ -778,12 +779,12 @@ public class FileLoadOperation {
}
FileLog.e("FileLoadOperation " + getFileName() + " removing stream listener " + operation);
streamListeners.remove(operation);
if (!isStory && streamListeners.isEmpty()) {
Utilities.stageQueue.cancelRunnable(cancelAfterNoStreamListeners);
Utilities.stageQueue.postRunnable(cancelAfterNoStreamListeners, 1200);
} else if (!streamListeners.isEmpty()) {
Utilities.stageQueue.cancelRunnable(cancelAfterNoStreamListeners);
}
// if (!isStory && streamListeners.isEmpty()) {
// Utilities.stageQueue.cancelRunnable(cancelAfterNoStreamListeners);
// Utilities.stageQueue.postRunnable(cancelAfterNoStreamListeners, 1200);
// } else if (!streamListeners.isEmpty()) {
// Utilities.stageQueue.cancelRunnable(cancelAfterNoStreamListeners);
// }
});
}
@ -1767,15 +1768,15 @@ public class FileLoadOperation {
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (error != null) {
onFail(false, 0);
} else {
} else if (response instanceof Vector) {
requestingCdnOffsets = false;
TLRPC.Vector vector = (TLRPC.Vector) response;
final Vector<TLRPC.TL_fileHash> vector = (Vector) response;
if (!vector.objects.isEmpty()) {
if (cdnHashes == null) {
cdnHashes = new HashMap<>();
}
for (int a = 0; a < vector.objects.size(); a++) {
TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a);
final TLRPC.TL_fileHash hash = vector.objects.get(a);
cdnHashes.put(hash.offset, hash);
}
}
@ -2548,19 +2549,19 @@ public class FileLoadOperation {
req.request_token = res.request_token;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response1, error1) -> {
reuploadingCdn = false;
if (error1 == null) {
TLRPC.Vector vector = (TLRPC.Vector) response1;
if (response1 instanceof Vector) {
final Vector<TLRPC.TL_fileHash> vector = (Vector) response1;
if (!vector.objects.isEmpty()) {
if (cdnHashes == null) {
cdnHashes = new HashMap<>();
}
for (int a1 = 0; a1 < vector.objects.size(); a1++) {
TLRPC.TL_fileHash hash = (TLRPC.TL_fileHash) vector.objects.get(a1);
final TLRPC.TL_fileHash hash = vector.objects.get(a1);
cdnHashes.put(hash.offset, hash);
}
}
startDownloadRequest(connectionType);
} else {
} else if (error1 != null) {
if (error1.text.equals("FILE_TOKEN_INVALID") || error1.text.equals("REQUEST_TOKEN_INVALID")) {
isCdn = false;
clearOperation(requestInfo, false, false);

View file

@ -215,9 +215,9 @@ public class FileLoader extends BaseController {
private final ConcurrentHashMap<String, FileLoadOperation> loadOperationPaths = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, LoadOperationUIObject> loadOperationPathsUI = new ConcurrentHashMap<>(10, 1, 2);
private HashMap<String, Long> uploadSizes = new HashMap<>();
private final HashMap<String, Long> uploadSizes = new HashMap<>();
private HashMap<String, Boolean> loadingVideos = new HashMap<>();
private final HashMap<String, Boolean> loadingVideos = new HashMap<>();
private String forceLoadingFile;
@ -225,7 +225,7 @@ public class FileLoader extends BaseController {
private FileLoaderDelegate delegate = null;
private int lastReferenceId;
private ConcurrentHashMap<Integer, Object> parentObjectReferences = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Integer, Object> parentObjectReferences = new ConcurrentHashMap<>();
private static final FileLoader[] Instance = new FileLoader[UserConfig.MAX_ACCOUNT_COUNT];
@ -1400,6 +1400,17 @@ public class FileLoader extends BaseController {
return filePathDatabase;
}
public static TLRPC.TL_photoStrippedSize getStrippedPhotoSize(ArrayList<TLRPC.PhotoSize> sizes) {
if (sizes == null) return null;
for (int i = 0; i < sizes.size(); ++i) {
final TLRPC.PhotoSize photoSize = sizes.get(i);
if (photoSize instanceof TLRPC.TL_photoStrippedSize) {
return (TLRPC.TL_photoStrippedSize) photoSize;
}
}
return null;
}
public static TLRPC.PhotoSize getClosestPhotoSizeWithSize(ArrayList<TLRPC.PhotoSize> sizes, int side) {
return getClosestPhotoSizeWithSize(sizes, side, false);
}

View file

@ -166,7 +166,7 @@ public class FileLog {
private static void checkGson() {
if (gson == null) {
privateFields = new HashSet<>();
privateFields.add("message");
// privateFields.add("message");
privateFields.add("phone");
privateFields.add("about");
privateFields.add("status_text");

View file

@ -5,6 +5,8 @@ import android.os.SystemClock;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.ActionBar.Theme;
@ -499,7 +501,7 @@ public class FileRefController extends BaseController {
}
} else if (parentObject instanceof TLRPC.TL_wallPaper) {
TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) parentObject;
TLRPC.TL_account_getWallPaper req = new TLRPC.TL_account_getWallPaper();
TL_account.getWallPaper req = new TL_account.getWallPaper();
TLRPC.TL_inputWallPaper inputWallPaper = new TLRPC.TL_inputWallPaper();
inputWallPaper.id = wallPaper.id;
inputWallPaper.access_hash = wallPaper.access_hash;
@ -507,7 +509,7 @@ public class FileRefController extends BaseController {
getConnectionsManager().sendRequest(req, (response, error) -> onRequestComplete(locationKey, parentKey, response, error, true, false));
} else if (parentObject instanceof TLRPC.TL_theme) {
TLRPC.TL_theme theme = (TLRPC.TL_theme) parentObject;
TLRPC.TL_account_getTheme req = new TLRPC.TL_account_getTheme();
TL_account.getTheme req = new TL_account.getTheme();
TLRPC.TL_inputTheme inputTheme = new TLRPC.TL_inputTheme();
inputTheme.id = theme.id;
inputTheme.access_hash = theme.access_hash;
@ -540,7 +542,7 @@ public class FileRefController extends BaseController {
String string = (String) parentObject;
if ("wallpaper".equals(string)) {
if (wallpaperWaiters.isEmpty()) {
TLRPC.TL_account_getWallPapers req = new TLRPC.TL_account_getWallPapers();
TL_account.getWallPapers req = new TL_account.getWallPapers();
getConnectionsManager().sendRequest(req, (response, error) -> broadcastWaitersData(wallpaperWaiters, response, error));
}
wallpaperWaiters.add(new Waiter(locationKey, parentKey));
@ -897,7 +899,7 @@ public class FileRefController extends BaseController {
String cacheKey = parentKey;
if (response instanceof TLRPC.TL_help_premiumPromo) {
cacheKey = "premium_promo";
} else if (response instanceof TLRPC.TL_account_wallPapers) {
} else if (response instanceof TL_account.TL_wallPapers) {
cacheKey = "wallpaper";
} else if (response instanceof TLRPC.TL_messages_savedGifs) {
cacheKey = "gif";
@ -1140,8 +1142,8 @@ public class FileRefController extends BaseController {
result = getFileReference(res.webpage, requester.location, needReplacement, locationReplacement);
} else if (response instanceof TLRPC.WebPage) {
result = getFileReference((TLRPC.WebPage) response, requester.location, needReplacement, locationReplacement);
} else if (response instanceof TLRPC.TL_account_wallPapers) {
TLRPC.TL_account_wallPapers accountWallPapers = (TLRPC.TL_account_wallPapers) response;
} else if (response instanceof TL_account.TL_wallPapers) {
TL_account.TL_wallPapers accountWallPapers = (TL_account.TL_wallPapers) response;
for (int i = 0, size10 = accountWallPapers.wallpapers.size(); i < size10; i++) {
result = getFileReference(((TLRPC.WallPaper) accountWallPapers.wallpapers.get(i)).document, null, requester.location, needReplacement, locationReplacement);
if (result != null) {
@ -1165,8 +1167,8 @@ public class FileRefController extends BaseController {
if (result != null && cache) {
AndroidUtilities.runOnUIThread(() -> Theme.setThemeFileReference(theme));
}
} else if (response instanceof TLRPC.Vector) {
TLRPC.Vector vector = (TLRPC.Vector) response;
} else if (response instanceof Vector) {
Vector vector = (Vector) response;
if (!vector.objects.isEmpty()) {
for (int i = 0, size10 = vector.objects.size(); i < size10; i++) {
Object object = vector.objects.get(i);

View file

@ -220,6 +220,9 @@ public class FileStreamLoadOperation extends BaseDataSource implements FileLoadO
bytesTransferred += bytesRead;
bytesTransferred(bytesRead);
}
} catch (InterruptedException e) {
FileLog.e(e);
return C.RESULT_NOTHING_READ;
} catch (Exception e) {
throw new IOException(e);
}

View file

@ -167,17 +167,17 @@ public class HashtagSearchController {
final String username = _username;
search.loading = true;
final int[] reqId = new int[1];
TLObject chat = null;
if (!TextUtils.isEmpty(username)) {
chat = MessagesController.getInstance(currentAccount).getUserOrChat(username);
if (chat == null) {
reqId[0] = search.reqId = MessagesController.getInstance(currentAccount).getUserNameResolver().resolve(username, resolvedChatId -> {
Runnable[] cancel = new Runnable[1];
cancel[0] = search.cancel = MessagesController.getInstance(currentAccount).getUserNameResolver().resolve(username, resolvedChatId -> {
if (!TextUtils.equals(search.lastHashtag, query)) return;
final TLObject resolvedChat = MessagesController.getInstance(currentAccount).getUserOrChat(username);
if (resolvedChat == null) {
if (reqId[0] == search.reqId) {
search.reqId = -1;
if (cancel[0] == search.cancel) {
search.cancel = null;
} else {
return;
}
@ -231,6 +231,7 @@ public class HashtagSearchController {
request = req;
}
}
final int[] reqId = new int[1];
reqId[0] = search.reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(request, (res, err) -> {
if (res instanceof TLRPC.messages_Messages) {
TLRPC.messages_Messages messages = (TLRPC.messages_Messages) res;
@ -340,6 +341,7 @@ public class HashtagSearchController {
}
public int reqId = -1;
public Runnable cancel;
public boolean loading;
public int lastOffsetRate;
public int lastOffsetId;
@ -366,6 +368,10 @@ public class HashtagSearchController {
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
reqId = -1;
}
if (cancel != null) {
cancel.run();
cancel = null;
}
messages.clear();
generatedIds.clear();
lastOffsetRate = 0;

View file

@ -35,6 +35,7 @@ import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.graphics.ColorUtils;
@ -4073,6 +4074,62 @@ public class ImageLoader {
}
}
@Nullable
public static TLRPC.PhotoSize fileToSize(String path, boolean forceCacheDir) {
if (path == null) {
return null;
}
int w, h;
try {
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(path, o);
w = o.outWidth;
h = o.outHeight;
} catch (Exception e) {
FileLog.e(e);
return null;
}
TLRPC.TL_fileLocationToBeDeprecated location = new TLRPC.TL_fileLocationToBeDeprecated();
location.volume_id = Integer.MIN_VALUE;
location.dc_id = Integer.MIN_VALUE;
location.local_id = SharedConfig.getLastLocalId();
location.file_reference = new byte[0];
TLRPC.TL_photoSize_layer127 photoSize = new TLRPC.TL_photoSize_layer127();
photoSize.location = location;
photoSize.w = w;
photoSize.h = h;
if (photoSize.w <= 100 && photoSize.h <= 100) {
photoSize.type = "s";
} else if (photoSize.w <= 320 && photoSize.h <= 320) {
photoSize.type = "m";
} else if (photoSize.w <= 800 && photoSize.h <= 800) {
photoSize.type = "x";
} else if (photoSize.w <= 1280 && photoSize.h <= 1280) {
photoSize.type = "y";
} else {
photoSize.type = "w";
}
String external = ".jpg";
String fileName = location.volume_id + "_" + location.local_id + external;
File fileDir;
if (forceCacheDir) {
fileDir = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE);
} else {
fileDir = location.volume_id != Integer.MIN_VALUE ? FileLoader.getDirectory(FileLoader.MEDIA_DIR_IMAGE) : FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE);
}
final File cacheFile = new File(fileDir, fileName);
new File(path).renameTo(cacheFile);
photoSize.size = (int) cacheFile.length();
return photoSize;
}
private static TLRPC.PhotoSize scaleAndSaveImageInternal(TLRPC.PhotoSize photoSize, Bitmap bitmap, Bitmap.CompressFormat compressFormat, boolean progressive, int w, int h, float photoW, float photoH, float scaleFactor, int quality, boolean cache, boolean scaleAnyway, boolean forceCacheDir) throws Exception {
Bitmap scaledBitmap;
if (scaleFactor > 1 || scaleAnyway) {

View file

@ -290,7 +290,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
private boolean allowLottieVibration = true;
private boolean allowStartAnimation = true;
private boolean allowStartLottieAnimation = true;
private boolean useSharedAnimationQueue;
public boolean useSharedAnimationQueue;
private boolean allowDecodeSingleFrame;
private int autoRepeat = 1;
private int autoRepeatCount = -1;

View file

@ -17,6 +17,7 @@ import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.Xml;
@ -24,6 +25,7 @@ import android.util.Xml;
import androidx.annotation.StringRes;
import org.telegram.messenger.time.FastDateFormat;
import org.telegram.tgnet.Vector;
import org.telegram.ui.Stars.StarsController;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
@ -1456,6 +1458,20 @@ public class LocaleController {
return formatString(param, key + "_other", resourceId, fallbackResourceId, argsWithPlural);
}
public static CharSequence formatPluralSpannable(String key, int plural, CharSequence... args) {
if (key == null || key.length() == 0 || getInstance().currentPluralRules == null) {
return "LOC_ERR:" + key;
}
String param = getInstance().stringForQuantity(getInstance().currentPluralRules.quantityForNumber(plural));
param = key + "_" + param;
int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName());
int fallbackResourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(key + "_other", "string", ApplicationLoader.applicationContext.getPackageName());
Object[] argsWithPlural = new Object[args.length + 1];
argsWithPlural[0] = plural;
System.arraycopy(args, 0, argsWithPlural, 1, args.length);
return formatSpannable(param, key + "_other", resourceId, fallbackResourceId, argsWithPlural);
}
public static String getStringParamForNumber(int number) {
return getInstance().stringForQuantity(getInstance().currentPluralRules.quantityForNumber(number));
}
@ -1561,15 +1577,13 @@ public class LocaleController {
if (fallbackRes != 0) {
try {
value = ApplicationLoader.applicationContext.getString(fallbackRes);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
}
}
} else if (fallbackRes != 0) {
try {
value = ApplicationLoader.applicationContext.getString(fallbackRes);
} catch (Exception ignored) {
}
} catch (Exception ignored) {}
}
}
}
@ -1585,6 +1599,75 @@ public class LocaleController {
}
}
public static CharSequence formatSpannable(@StringRes int res, Object... args) {
String key = resourcesCacheMap.get(res);
if (key == null) {
resourcesCacheMap.put(res, key = ApplicationLoader.applicationContext.getResources().getResourceEntryName(res));
}
return formatSpannable(key, res, args);
}
public static CharSequence formatSpannable(String key, int res, Object... args) {
return formatSpannable(key, null, res, 0, args);
}
public static CharSequence formatSpannable(String key, String fallback, int res, int fallbackRes, Object... args) {
try {
String value = BuildVars.USE_CLOUD_STRINGS ? getInstance().localeValues.get(key) : null;
if (value == null) {
if (BuildVars.USE_CLOUD_STRINGS && fallback != null) {
value = getInstance().localeValues.get(fallback);
}
if (value == null) {
if (res != 0) {
try {
value = ApplicationLoader.applicationContext.getString(res);
} catch (Exception e) {
if (fallbackRes != 0) {
try {
value = ApplicationLoader.applicationContext.getString(fallbackRes);
} catch (Exception ignored) {}
}
}
} else if (fallbackRes != 0) {
try {
value = ApplicationLoader.applicationContext.getString(fallbackRes);
} catch (Exception ignored) {}
}
}
}
SpannableStringBuilder builder = new SpannableStringBuilder(value);
for (int i = 0; i < args.length; i++) {
String formatter = "s";
CharSequence replaceWith = "";
if (args[i] instanceof CharSequence) {
replaceWith = (CharSequence) args[i];
} else if (args[i] instanceof Integer) {
formatter = "d";
replaceWith = "" + (Integer) args[i];
} else if (args[i] == null) {
replaceWith = "null";
}
final String placeholder = "%" + (i + 1) + "$" + formatter;
int start = builder.toString().indexOf(placeholder);
if (start != -1) {
builder.replace(start, start + placeholder.length(), replaceWith);
} else {
final String placeholder2 = "%" + formatter;
start = builder.toString().indexOf(placeholder2);
if (start != -1) {
builder.replace(start, start + placeholder2.length(), replaceWith);
}
}
}
return builder;
} catch (Exception e) {
FileLog.e(e);
return "LOC_ERR: " + key;
}
}
public static String formatTTLString(int ttl) {
if (ttl < 60) {
return LocaleController.formatPluralString("Seconds", ttl);
@ -2843,10 +2926,10 @@ public class LocaleController {
loadingRemoteLanguages = true;
TLRPC.TL_langpack_getLanguages req = new TLRPC.TL_langpack_getLanguages();
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) {
if (response instanceof Vector) {
AndroidUtilities.runOnUIThread(() -> {
loadingRemoteLanguages = false;
TLRPC.Vector res = (TLRPC.Vector) response;
Vector res = (Vector) response;
for (int a = 0, size = remoteLanguages.size(); a < size; a++) {
remoteLanguages.get(a).serverIndex = Integer.MAX_VALUE;
}

View file

@ -76,6 +76,8 @@ import org.telegram.messenger.video.MediaCodecVideoConvertor;
import org.telegram.messenger.voip.VoIPService;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_stories;
@ -230,7 +232,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
public float blurExcludeBlurSize;
public float blurAngle;
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
stream.writeFloat(enhanceValue);
stream.writeFloat(softenSkinValue);
stream.writeFloat(exposureValue);
@ -259,7 +261,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
stream.writeFloat(blurAngle);
}
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
enhanceValue = stream.readFloat(exception);
softenSkinValue = stream.readFloat(exception);
exposureValue = stream.readFloat(exception);
@ -312,7 +314,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
}
public static class CropState {
public static class CropState extends TLObject {
public static final int constructor = 0x44a3abcd;
public float cropPx;
public float cropPy;
public float cropScale = 1;
@ -331,6 +335,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
public int height;
public boolean freeform;
public float lockedAspectRatio;
public int orientation;
public Matrix useMatrix;
@ -358,6 +363,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
cloned.height = this.height;
cloned.freeform = this.freeform;
cloned.lockedAspectRatio = this.lockedAspectRatio;
cloned.orientation = this.orientation;
cloned.initied = this.initied;
cloned.useMatrix = this.useMatrix;
@ -370,12 +376,91 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
transformRotation == 0 && !mirrored && stateScale == 0 && scale == 0 && width == 0 && height == 0 && !freeform && lockedAspectRatio == 0;
}
@Override
public void readParams(InputSerializedData stream, boolean exception) {
cropPx = stream.readFloat(exception);
cropPy = stream.readFloat(exception);
cropScale = stream.readFloat(exception);
cropRotate = stream.readFloat(exception);
cropPw = stream.readFloat(exception);
cropPh = stream.readFloat(exception);
transformWidth = stream.readInt32(exception);
transformHeight = stream.readInt32(exception);
transformRotation = stream.readInt32(exception);
mirrored = stream.readBool(exception);
stateScale = stream.readFloat(exception);
scale = stream.readFloat(exception);
final float[] values = new float[9];
for (int i = 0; i < values.length; ++i) {
values[i] = stream.readFloat(exception);
}
matrix = new Matrix();
matrix.setValues(values);
width = stream.readInt32(exception);
height = stream.readInt32(exception);
freeform = stream.readBool(exception);
lockedAspectRatio = stream.readFloat(exception);
int magic = stream.readInt32(exception);
if (magic == 0xaa23a61) {
for (int i = 0; i < values.length; ++i) {
values[i] = stream.readFloat(exception);
}
useMatrix = new Matrix();
useMatrix.setValues(values);
}
initied = stream.readBool(exception);
orientation = stream.readInt32(exception);
}
@Override
public void serializeToStream(OutputSerializedData stream) {
stream.writeInt32(constructor);
stream.writeFloat(cropPx);
stream.writeFloat(cropPy);
stream.writeFloat(cropScale);
stream.writeFloat(cropRotate);
stream.writeFloat(cropPw);
stream.writeFloat(cropPh);
stream.writeInt32(transformWidth);
stream.writeInt32(transformHeight);
stream.writeInt32(transformRotation);
stream.writeBool(mirrored);
stream.writeFloat(stateScale);
stream.writeFloat(scale);
final float[] values = new float[9];
if (matrix != null) {
matrix.getValues(values);
} else for (int i = 0; i < values.length; ++i) {
values[i] = 0.0f;
}
for (int i = 0; i < values.length; ++i) {
stream.writeFloat(values[i]);
}
stream.writeInt32(width);
stream.writeInt32(height);
stream.writeBool(freeform);
stream.writeFloat(lockedAspectRatio);
if (useMatrix == null) {
stream.writeInt32(TLRPC.TL_null.constructor);
} else {
stream.writeInt32(0xaa23a61);
useMatrix.getValues(values);
for (int i = 0; i < values.length; ++i) {
stream.writeFloat(values[i]);
}
}
stream.writeBool(initied);
stream.writeInt32(orientation);
}
}
public static class MediaEditState {
public CharSequence caption;
public long customThumbSavedPosition;
public boolean customThumb;
public String thumbPath;
public String imagePath;
public String filterPath;
@ -4080,9 +4165,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
try {
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {
}
} catch (Exception ignore) {}
recordQueue.postRunnable(recordStartRunnable = () -> {
if (audioRecorder != null) {
@ -4349,9 +4432,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
try {
feedbackView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
} catch (Exception ignore) {
}
} catch (Exception ignore) {}
AndroidUtilities.runOnUIThread(() -> NotificationCenter.getInstance(recordingCurrentAccount).postNotificationName(NotificationCenter.recordStopped, recordingGuid, send == 2 ? 1 : 0));
});
}
@ -5605,30 +5686,24 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
private static class VideoConvertRunnable implements Runnable {
private final VideoConvertMessage convertMessage;
private final Handler handler;
private VideoConvertMessage convertMessage;
private VideoConvertRunnable(VideoConvertMessage message, Handler handler) {
this.convertMessage = message;
this.handler = handler;
private VideoConvertRunnable(VideoConvertMessage message) {
convertMessage = message;
}
@Override
public void run() {
MediaController.getInstance().convertVideo(convertMessage, handler);
MediaController.getInstance().convertVideo(convertMessage);
}
public static void runConversion(final VideoConvertMessage obj) {
HandlerThread handlerThread = new HandlerThread("VideoConvertRunnableThread");
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());
new Thread(() -> {
try {
VideoConvertRunnable wrapper = new VideoConvertRunnable(obj, handler);
VideoConvertRunnable wrapper = new VideoConvertRunnable(obj);
Thread th = new Thread(wrapper, "VideoConvertRunnable");
th.start();
th.join();
handlerThread.join();
} catch (Exception e) {
FileLog.e(e);
}
@ -5637,7 +5712,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
private boolean convertVideo(final VideoConvertMessage convertMessage, final Handler handler) {
private boolean convertVideo(final VideoConvertMessage convertMessage) {
MessageObject messageObject = convertMessage.messageObject;
VideoEditedInfo info = convertMessage.videoEditedInfo;
if (messageObject == null || info == null) {
@ -5743,7 +5818,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
callback,
info);
convertVideoParams.soundInfos.addAll(info.mixedSoundInfos);
boolean error = videoConvertor.convertVideo(convertVideoParams, handler);
boolean error = videoConvertor.convertVideo(convertVideoParams);
boolean canceled = info.canceled;

View file

@ -35,7 +35,6 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
@ -60,6 +59,8 @@ import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.EmojiThemes;
@ -4227,8 +4228,8 @@ public class MediaDataController extends BaseController {
counts[i] = 0;
}
}
if (response != null) {
TLRPC.Vector res = (TLRPC.Vector) response;
if (response instanceof Vector) {
Vector res = (Vector) response;
for (int a = 0, N = res.objects.size(); a < N; a++) {
TLRPC.TL_messages_searchCounter searchCounter = (TLRPC.TL_messages_searchCounter) res.objects.get(a);
int type;
@ -4301,10 +4302,10 @@ public class MediaDataController extends BaseController {
return;
}
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (response != null) {
TLRPC.Vector res = (TLRPC.Vector) response;
if (response instanceof Vector) {
final Vector res = (Vector) response;
if (!res.objects.isEmpty()) {
TLRPC.TL_messages_searchCounter counter = (TLRPC.TL_messages_searchCounter) res.objects.get(0);
final TLRPC.TL_messages_searchCounter counter = (TLRPC.TL_messages_searchCounter) res.objects.get(0);
processLoadedMediaCount(counter.count, dialogId, topicId, type, classGuid, false, 0);
}
}
@ -6852,11 +6853,15 @@ public class MediaDataController extends BaseController {
public static void addTextStyleRuns(ArrayList<TLRPC.MessageEntity> entities, CharSequence messageText, Spannable text, int allowedFlags) {
for (TextStyleSpan prevSpan : text.getSpans(0, text.length(), TextStyleSpan.class))
text.removeSpan(prevSpan);
for (TextStyleSpan.TextStyleRun run : MediaDataController.getTextStyleRuns(entities, messageText, allowedFlags)) {
final ArrayList<TextStyleSpan.TextStyleRun> runs = MediaDataController.getTextStyleRuns(entities, messageText, allowedFlags);
for (int i = 0; i < Math.min(MAX_STYLE_RUNS_COUNT, runs.size()); ++i) {
final TextStyleSpan.TextStyleRun run = runs.get(i);
MediaDataController.addStyleToText(new TextStyleSpan(run), run.start, run.end, text, true);
}
}
public static final int MAX_STYLE_RUNS_COUNT = 1000;
public static void addAnimatedEmojiSpans(ArrayList<TLRPC.MessageEntity> entities, CharSequence messageText, Paint.FontMetricsInt fontMetricsInt) {
if (!(messageText instanceof Spannable) || entities == null) {
return;
@ -7324,6 +7329,13 @@ public class MediaDataController extends BaseController {
return entities;
}
public static void offsetEntities(ArrayList<TLRPC.MessageEntity> entities, int offset) {
if (entities == null) return;
for (TLRPC.MessageEntity e : entities) {
e.offset += offset;
}
}
public static boolean entitiesEqual(TLRPC.MessageEntity entity1, TLRPC.MessageEntity entity2) {
if (entity1.getClass() != entity2.getClass() ||
entity1.offset != entity2.offset ||
@ -8260,15 +8272,15 @@ public class MediaDataController extends BaseController {
}
}
}
TLRPC.TL_account_saveRingtone saveRingtone = new TLRPC.TL_account_saveRingtone();
TL_account.saveRingtone saveRingtone = new TL_account.saveRingtone();
saveRingtone.id = new TLRPC.TL_inputDocument();
saveRingtone.id.id = document.id;
saveRingtone.id.file_reference = document.file_reference;
saveRingtone.id.access_hash = document.access_hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(saveRingtone, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
if (response instanceof TLRPC.TL_account_savedRingtoneConverted) {
ringtoneDataStore.addTone(((TLRPC.TL_account_savedRingtoneConverted) response).document);
if (response instanceof TL_account.TL_savedRingtoneConverted) {
ringtoneDataStore.addTone(((TL_account.TL_savedRingtoneConverted) response).document);
} else {
ringtoneDataStore.addTone(document);
}
@ -9156,7 +9168,7 @@ public class MediaDataController extends BaseController {
emojiStatuses[type].remove(emojiStatuses[type].size() - 1);
}
TLRPC.TL_account_emojiStatuses statuses = new TLRPC.TL_account_emojiStatuses();
TL_account.TL_emojiStatuses statuses = new TL_account.TL_emojiStatuses();
// todo: calc hash
statuses.hash = emojiStatusesHash[type];
statuses.statuses = emojiStatuses[type];
@ -9177,8 +9189,8 @@ public class MediaDataController extends BaseController {
if (cursor.next() && cursor.getColumnCount() > 0 && !cursor.isNull(0)) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
TLRPC.account_EmojiStatuses response = TLRPC.account_EmojiStatuses.TLdeserialize(data, data.readInt32(false), false);
if (response instanceof TLRPC.TL_account_emojiStatuses) {
TL_account.EmojiStatuses response = TL_account.EmojiStatuses.TLdeserialize(data, data.readInt32(false), false);
if (response instanceof TL_account.TL_emojiStatuses) {
emojiStatusesHash[type] = response.hash;
emojiStatuses[type] = response.statuses;
done = true;
@ -9203,24 +9215,24 @@ public class MediaDataController extends BaseController {
} else {
TLObject req;
if (type == 0) {
TLRPC.TL_account_getRecentEmojiStatuses recentReq = new TLRPC.TL_account_getRecentEmojiStatuses();
TL_account.getRecentEmojiStatuses recentReq = new TL_account.getRecentEmojiStatuses();
recentReq.hash = emojiStatusesHash[type];
req = recentReq;
} else if (type == 1) {
TLRPC.TL_account_getDefaultEmojiStatuses defaultReq = new TLRPC.TL_account_getDefaultEmojiStatuses();
TL_account.getDefaultEmojiStatuses defaultReq = new TL_account.getDefaultEmojiStatuses();
defaultReq.hash = emojiStatusesHash[type];
req = defaultReq;
} else {
TLRPC.TL_account_getChannelDefaultEmojiStatuses defaultReq = new TLRPC.TL_account_getChannelDefaultEmojiStatuses();
TL_account.getChannelDefaultEmojiStatuses defaultReq = new TL_account.getChannelDefaultEmojiStatuses();
defaultReq.hash = emojiStatusesHash[type];
req = defaultReq;
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> {
emojiStatusesFetchDate[type] = System.currentTimeMillis() / 1000;
if (res instanceof TLRPC.TL_account_emojiStatusesNotModified) {
if (res instanceof TL_account.TL_emojiStatusesNotModified) {
emojiStatusesFetching[type] = false;
} else if (res instanceof TLRPC.TL_account_emojiStatuses) {
TLRPC.TL_account_emojiStatuses response = (TLRPC.TL_account_emojiStatuses) res;
} else if (res instanceof TL_account.TL_emojiStatuses) {
TL_account.TL_emojiStatuses response = (TL_account.TL_emojiStatuses) res;
emojiStatusesHash[type] = response.hash;
emojiStatuses[type] = response.statuses;
updateEmojiStatuses(type, response);
@ -9232,7 +9244,7 @@ public class MediaDataController extends BaseController {
}
}
private void updateEmojiStatuses(int type, TLRPC.TL_account_emojiStatuses response) {
private void updateEmojiStatuses(int type, TL_account.TL_emojiStatuses response) {
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
getMessagesStorage().getDatabase().executeFast("DELETE FROM emoji_statuses WHERE type = " + type).stepThis().dispose();
@ -9450,7 +9462,7 @@ public class MediaDataController extends BaseController {
}
if (emojiList == null || (System.currentTimeMillis() - lastCheckTime) > 24 * 60 * 60 * 1000 || BuildVars.DEBUG_PRIVATE_VERSION) {
TLRPC.TL_account_getDefaultProfilePhotoEmojis req = new TLRPC.TL_account_getDefaultProfilePhotoEmojis();
TL_account.getDefaultProfilePhotoEmojis req = new TL_account.getDefaultProfilePhotoEmojis();
if (emojiList != null) {
req.hash = emojiList.hash;
}
@ -9493,7 +9505,7 @@ public class MediaDataController extends BaseController {
}
if (emojiList == null || (System.currentTimeMillis() - lastCheckTime) > 24 * 60 * 60 * 1000 || BuildVars.DEBUG_PRIVATE_VERSION) {
TLRPC.TL_account_getDefaultBackgroundEmojis req = new TLRPC.TL_account_getDefaultBackgroundEmojis();
TL_account.getDefaultBackgroundEmojis req = new TL_account.getDefaultBackgroundEmojis();
if (emojiList != null) {
req.hash = emojiList.hash;
}
@ -9531,7 +9543,7 @@ public class MediaDataController extends BaseController {
}
if (emojiList == null || (System.currentTimeMillis() - lastCheckTime) > 24 * 60 * 60 * 1000) {
TLRPC.TL_account_getChannelRestrictedStatusEmojis req = new TLRPC.TL_account_getChannelRestrictedStatusEmojis();
TL_account.getChannelRestrictedStatusEmojis req = new TL_account.getChannelRestrictedStatusEmojis();
if (emojiList != null) {
req.hash = emojiList.hash;
}

View file

@ -1,7 +1,9 @@
package org.telegram.messenger;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
@ -82,7 +84,7 @@ public class MessageCustomParamsHelper {
}
@Override
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
stream.writeInt32(VERSION);
flags = message.voiceTranscriptionForce ? (flags | 2) : (flags &~ 2);
stream.writeInt32(flags);
@ -108,7 +110,7 @@ public class MessageCustomParamsHelper {
}
@Override
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
flags = stream.readInt32(true);
if ((flags & 1) != 0) {
message.voiceTranscription = stream.readString(exception);

View file

@ -10,6 +10,7 @@ package org.telegram.messenger;
import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.LocaleController.formatPluralString;
import static org.telegram.messenger.LocaleController.formatPluralStringComma;
import static org.telegram.messenger.LocaleController.formatString;
import static org.telegram.messenger.LocaleController.getString;
@ -75,8 +76,11 @@ import org.telegram.ui.Components.URLSpanNoUnderlineBold;
import org.telegram.ui.Components.URLSpanReplacement;
import org.telegram.ui.Components.URLSpanUserMention;
import org.telegram.ui.Components.VideoPlayer;
import org.telegram.ui.Components.WebPlayerView;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PeerColorActivity;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Stars.StarsController;
import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.ui.Stories.StoriesController;
@ -3159,7 +3163,7 @@ public class MessageObject {
prev.setSpan(new AnimatedEmojiSpan(DialogObject.getEmojiStatusDocumentId(action.prev_value), Theme.chat_actionTextPaint.getFontMetricsInt()), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
boolean hasUntil = action.new_value instanceof TLRPC.TL_emojiStatusUntil;
final int until = DialogObject.getEmojiStatusUntil(action.new_value);
SpannableString next;
if (action.new_value instanceof TLRPC.TL_emojiStatusEmpty) {
@ -3171,17 +3175,17 @@ public class MessageObject {
SpannableStringBuilder ssb = new SpannableStringBuilder(getString(
prevNone ? (
hasUntil ? (isChannel ? R.string.EventLogChangedEmojiStatusFor : R.string.EventLogChangedEmojiStatusForGroup) : (isChannel ? R.string.EventLogChangedEmojiStatus : R.string.EventLogChangedEmojiStatusGroup)
until != 0 ? (isChannel ? R.string.EventLogChangedEmojiStatusFor : R.string.EventLogChangedEmojiStatusForGroup) : (isChannel ? R.string.EventLogChangedEmojiStatus : R.string.EventLogChangedEmojiStatusGroup)
) : (
hasUntil ? (isChannel ? R.string.EventLogChangedEmojiStatusFromFor : R.string.EventLogChangedEmojiStatusFromForGroup) : (isChannel ? R.string.EventLogChangedEmojiStatusFrom : R.string.EventLogChangedEmojiStatusFromGroup)
until != 0 ? (isChannel ? R.string.EventLogChangedEmojiStatusFromFor : R.string.EventLogChangedEmojiStatusFromForGroup) : (isChannel ? R.string.EventLogChangedEmojiStatusFrom : R.string.EventLogChangedEmojiStatusFromGroup)
)
));
ssb = AndroidUtilities.replaceCharSequence("%1$s", ssb, prev);
ssb = AndroidUtilities.replaceCharSequence("%2$s", ssb, next);
if (hasUntil) {
String until = LocaleController.formatTTLString((int) ((DialogObject.getEmojiStatusUntil(action.new_value) - event.date) * 1.05f));
ssb = AndroidUtilities.replaceCharSequence("%3$s", ssb, until);
if (until != 0) {
final String untilString = LocaleController.formatTTLString((int) ((until - event.date) * 1.05f));
ssb = AndroidUtilities.replaceCharSequence("%3$s", ssb, untilString);
}
messageText = replaceWithLink(ssb, "un1", fromUser);
@ -3627,7 +3631,7 @@ public class MessageObject {
messageText = LocaleController.formatPluralString("NotificationPinnedPaidMedia", (int) paidMedia.stars_amount, username);
} else if (getMedia(replyMessageObject) instanceof TLRPC.TL_messageMediaGame) {
messageText = replaceWithLink(formatString("ActionPinnedGame", R.string.ActionPinnedGame, "\uD83C\uDFAE " + getMedia(replyMessageObject).game.title), "un1", fromUser != null ? fromUser : chat);
messageText = Emoji.replaceEmoji(messageText, Theme.chat_msgTextPaint.getFontMetricsInt(), dp(20), false);
messageText = Emoji.replaceEmoji(messageText, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
} else if (replyMessageObject.messageText != null && replyMessageObject.messageText.length() > 0) {
CharSequence mess = AnimatedEmojiSpan.cloneSpans(replyMessageObject.messageText);
boolean ellipsize = false;
@ -3635,7 +3639,7 @@ public class MessageObject {
mess = mess.subSequence(0, 20);
ellipsize = true;
}
mess = Emoji.replaceEmoji(mess, Theme.chat_msgTextPaint.getFontMetricsInt(), dp(20), true);
mess = Emoji.replaceEmoji(mess, Theme.chat_msgTextPaint.getFontMetricsInt(), true);
if (replyMessageObject != null && replyMessageObject.messageOwner != null) {
mess = replyMessageObject.replaceAnimatedEmoji(mess, Theme.chat_msgTextPaint.getFontMetricsInt());
}
@ -4033,7 +4037,7 @@ public class MessageObject {
if (str == null) {
str = "";
}
text = Emoji.replaceEmoji(str, Theme.chat_msgBotButtonPaint.getFontMetricsInt(), dp(15), false);
text = Emoji.replaceEmoji(str, Theme.chat_msgBotButtonPaint.getFontMetricsInt(), false);
}
StaticLayout staticLayout = new StaticLayout(text, Theme.chat_msgBotButtonPaint, dp(2000), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (staticLayout.getLineCount() > 0) {
@ -4365,7 +4369,7 @@ public class MessageObject {
boolean isChannel = ChatObject.isChannelAndNotMegaGroup(chat);
boolean isStars = (giveawayLaunch.flags & 1) != 0;
if (isStars) {
messageText = LocaleController.formatPluralStringComma(isChannel ? "BoostingStarsGiveawayJustStarted" : "BoostingStarsGiveawayJustStartedGroup", (int) giveawayLaunch.stars, chat != null ? chat.title : "");
messageText = formatPluralStringComma(isChannel ? "BoostingStarsGiveawayJustStarted" : "BoostingStarsGiveawayJustStartedGroup", (int) giveawayLaunch.stars, chat != null ? chat.title : "");
} else {
messageText = formatString(isChannel ? R.string.BoostingGiveawayJustStarted : R.string.BoostingGiveawayJustStartedGroup, chat != null ? chat.title : "");
}
@ -4401,7 +4405,7 @@ public class MessageObject {
TLRPC.TL_messageActionGiveawayResults giveawayResults = (TLRPC.TL_messageActionGiveawayResults) messageOwner.action;
SpannableStringBuilder stringBuilder = new SpannableStringBuilder();
if (giveawayResults.stars) {
stringBuilder.append(LocaleController.formatPluralStringComma("BoostingStarsGiveawayServiceWinnersSelected", giveawayResults.winners_count));
stringBuilder.append(formatPluralStringComma("BoostingStarsGiveawayServiceWinnersSelected", giveawayResults.winners_count));
if (giveawayResults.unclaimed_count > 0) {
stringBuilder.append("\n");
stringBuilder.append(LocaleController.formatPluralString(isChannel ? "BoostingStarsGiveawayServiceUndistributed" : "BoostingStarsGiveawayServiceUndistributedGroup", giveawayResults.unclaimed_count));
@ -4418,15 +4422,48 @@ public class MessageObject {
final TLRPC.TL_messageActionPrizeStars action = (TLRPC.TL_messageActionPrizeStars) messageOwner.action;
final long chatId = -DialogObject.getPeerDialogId(action.boost_peer);
final TLRPC.Chat chat = getChat(chats, sChats, chatId);
messageText = replaceWithLink(AndroidUtilities.replaceTags(LocaleController.formatPluralStringComma("ActionStarGiveawayPrize", (int) action.stars)), "un1", chat);
messageText = replaceWithLink(AndroidUtilities.replaceTags(formatPluralStringComma("ActionStarGiveawayPrize", (int) action.stars)), "un1", chat);
} else if (messageOwner.action instanceof TLRPC.TL_messageActionStarGift) {
TLRPC.TL_messageActionStarGift action = (TLRPC.TL_messageActionStarGift) messageOwner.action;
final TLRPC.TL_messageActionStarGift action = (TLRPC.TL_messageActionStarGift) messageOwner.action;
int stars = 0;
if (action.gift != null) {
stars = (int) action.gift.stars;
}
if (fromObject instanceof TLRPC.User && ((TLRPC.User) fromObject).self && !action.forceIn) {
TLRPC.User user = getUser(users, sUsers, messageOwner.peer_id.user_id);
// if (action.can_upgrade && action.upgrade_stars == 0) {
stars += (int) action.upgrade_stars;
// }
final boolean isForChannel = action.peer != null && DialogObject.getPeerDialogId(action.peer) < 0;
TLRPC.User user = getUser(users, sUsers, messageOwner.peer_id.user_id);
TLObject obj = fromObject;
if (action.from_id != null) {
final long fromId = DialogObject.getPeerDialogId(action.from_id);
if (fromId >= 0) {
obj = getUser(users, sUsers, fromId);
} else {
obj = getChat(chats, sChats, -fromId);
}
}
TLObject peerObj = null;
if (action.peer != null) {
final long peerId = DialogObject.getPeerDialogId(action.peer);
if (peerId >= 0) {
peerObj = getUser(users, sUsers, peerId);
} else {
peerObj = getChat(chats, sChats, -peerId);
}
}
if (UserObject.isService(getDialogId()) && action.from_id == null) {
messageText = AndroidUtilities.replaceTags(getString(R.string.ActionGiftSomeone));
messageTextShort = getString(R.string.ActionStarGift);
} else if (isForChannel) {
messageText = AndroidUtilities.replaceTags(formatPluralStringComma("ActionGiftChannel", stars));
messageText = replaceWithLink(messageText, "un1", obj);
messageText = replaceWithLink(messageText, "un2", peerObj);
messageTextShort = getString(R.string.ActionStarGift);
} else if (UserObject.isUserSelf(user)) {
messageText = AndroidUtilities.replaceTags(getString(R.string.ActionGiftSelf));
messageTextShort = getString(R.string.ActionStarGift);
} else if (obj instanceof TLRPC.User && ((TLRPC.User) obj).self && !action.forceIn) {
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(R.string.ActionGiftOutbound)), "un1", user);
if (action.message != null && !TextUtils.isEmpty(action.message.text)) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(action.message.text);
@ -4435,10 +4472,10 @@ public class MessageObject {
} else {
messageTextShort = getString(R.string.ActionStarGift);
}
} else if (fromObject instanceof TLRPC.User && UserObject.isService(((TLRPC.User) fromObject).id)) {
} else if (obj instanceof TLRPC.User && UserObject.isService(((TLRPC.User) obj).id)) {
messageText = TextUtils.replace(AndroidUtilities.replaceTags(getString(R.string.ActionGiftInbound)), new String[] {"un1"}, new CharSequence[]{ getString(R.string.StarsTransactionUnknown) });
} else {
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(R.string.ActionGiftInbound)), "un1", fromObject);
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(R.string.ActionGiftInbound)), "un1", obj);
if (action.message != null && !TextUtils.isEmpty(action.message.text)) {
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(action.message.text);
addEntitiesToText(stringBuilder, action.message.entities, isOutOwner(), false, false, false);
@ -4450,7 +4487,51 @@ public class MessageObject {
int i = messageText.toString().indexOf("un2");
if (i != -1) {
SpannableStringBuilder sb = SpannableStringBuilder.valueOf(messageText);
messageText = sb.replace(i, i + 3, LocaleController.formatPluralStringComma("Gift2StarsCount", (int) stars));
messageText = sb.replace(i, i + 3, formatPluralStringComma("Gift2StarsCount", (int) stars));
}
} else if (messageOwner.action instanceof TLRPC.TL_messageActionStarGiftUnique) {
TLRPC.TL_messageActionStarGiftUnique action = (TLRPC.TL_messageActionStarGiftUnique) messageOwner.action;
TLRPC.User user = getUser(users, sUsers, getDialogId());
if (action.upgrade) {
if (action.peer != null) {
long peerId = DialogObject.getPeerDialogId(action.peer);
TLObject peer;
if (peerId >= 0) {
peer = getUser(users, sUsers, peerId);
} else {
peer = getChat(chats, sChats, -peerId);
}
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(R.string.ActionUniqueGiftUpgradeInboundChannel)), "un1", peer);
} else if (UserObject.isUserSelf(user)) {
messageText = AndroidUtilities.replaceTags(getString(R.string.ActionUniqueGiftUpgradeSelf));
} else {
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(isOutOwner() ? R.string.ActionUniqueGiftUpgradeOutbound : R.string.ActionUniqueGiftUpgradeInbound)), "un1", user);
}
} else {
long fromId = getDialogId();
if (action.from_id != null) {
fromId = DialogObject.getPeerDialogId(action.from_id);
}
TLObject obj;
if (fromId >= 0) {
obj = getUser(users, sUsers, fromId);
} else {
obj = getChat(chats, sChats, -fromId);
}
if (action.peer != null) {
long peerId = DialogObject.getPeerDialogId(action.peer);
TLObject peer;
if (peerId >= 0) {
peer = getUser(users, sUsers, peerId);
} else {
peer = getChat(chats, sChats, -peerId);
}
messageText = AndroidUtilities.replaceTags(getString(R.string.ActionUniqueGiftTransferService));
messageText = replaceWithLink(messageText, "un1", obj);
messageText = replaceWithLink(messageText, "un2", peer);
} else {
messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(isOutOwner() ? R.string.ActionUniqueGiftTransferOutbound : R.string.ActionUniqueGiftTransferInbound)), "un1", obj);
}
}
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGiftStars) {
if (fromObject instanceof TLRPC.User && ((TLRPC.User) fromObject).self) {
@ -5117,6 +5198,10 @@ public class MessageObject {
if (messageText == null) {
messageText = "";
}
isEmbedVideoCached = null;
cachedStartsTimestamp = null;
cachedSavedTimestamp = null;
}
public CharSequence getMediaTitle(TLRPC.MessageMedia media) {
@ -5423,7 +5508,7 @@ public class MessageObject {
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGiftPremium || messageOwner.action instanceof TLRPC.TL_messageActionGiftCode) {
contentType = 1;
type = TYPE_GIFT_PREMIUM;
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGiftStars || messageOwner.action instanceof TLRPC.TL_messageActionStarGift || messageOwner.action instanceof TLRPC.TL_messageActionPrizeStars) {
} else if (messageOwner.action instanceof TLRPC.TL_messageActionGiftStars || messageOwner.action instanceof TLRPC.TL_messageActionStarGift || messageOwner.action instanceof TLRPC.TL_messageActionPrizeStars || messageOwner.action instanceof TLRPC.TL_messageActionStarGiftUnique && ((TLRPC.TL_messageActionStarGiftUnique) messageOwner.action).refunded) {
contentType = 1;
type = TYPE_GIFT_STARS;
} else if (messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
@ -5925,6 +6010,13 @@ public class MessageObject {
return getFileName(messageOwner);
}
public String getFileNameFast() {
if (getDocumentFast() != null) {
return getFileName(getDocumentFast());
}
return getFileName(messageOwner);
}
public static String getFileName(TLRPC.Message messageOwner) {
if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument) {
return getFileName(getDocument(messageOwner));
@ -6088,7 +6180,7 @@ public class MessageObject {
FileLog.e(e);
}
}
linkDescription = Emoji.replaceEmoji(linkDescription, Theme.chat_msgTextPaint.getFontMetricsInt(), dp(20), false);
linkDescription = Emoji.replaceEmoji(linkDescription, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
if (webPageDescriptionEntities != null) {
addEntitiesToText(linkDescription, webPageDescriptionEntities, isOut(), allowUsernames, false, !allowUsernames);
replaceAnimatedEmoji(linkDescription, webPageDescriptionEntities, Theme.chat_msgTextPaint.getFontMetricsInt());
@ -6119,7 +6211,7 @@ public class MessageObject {
}
CharSequence text = messageOwner.voiceTranscription;
if (!TextUtils.isEmpty(text)) {
text = Emoji.replaceEmoji(text, Theme.chat_msgTextPaint.getFontMetricsInt(), dp(20), false);
text = Emoji.replaceEmoji(text, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
}
return text;
}
@ -6179,7 +6271,7 @@ public class MessageObject {
entities = messageOwner.translatedText.entities;
}
if (!isMediaEmpty() && !(getMedia(messageOwner) instanceof TLRPC.TL_messageMediaGame) && !TextUtils.isEmpty(text)) {
caption = Emoji.replaceEmoji(text, Theme.chat_msgTextPaint.getFontMetricsInt(), dp(20), false);
caption = Emoji.replaceEmoji(text, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
caption = replaceAnimatedEmoji(caption, entities, Theme.chat_msgTextPaint.getFontMetricsInt(), false);
boolean hasEntities;
@ -6395,6 +6487,9 @@ public class MessageObject {
public boolean hasValidGroupId() {
return getGroupId() != 0 && (photoThumbs != null && !photoThumbs.isEmpty() || type == TYPE_VIDEO || type == TYPE_PHOTO || isMusic() || isDocument());
}
public boolean hasValidGroupIdFast() {
return getGroupId() != 0 && (photoThumbs != null && !photoThumbs.isEmpty() || type == TYPE_VIDEO || type == TYPE_PHOTO || type == TYPE_MUSIC || type == TYPE_FILE);
}
public long getGroupIdForUse() {
return localSentGroupId != 0 ? localSentGroupId : messageOwner.grouped_id;
@ -6520,6 +6615,13 @@ public class MessageObject {
}
public static Spannable replaceAnimatedEmoji(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, Paint.FontMetricsInt fontMetricsInt, boolean top) {
return replaceAnimatedEmoji(text, entities, fontMetricsInt, top, 1.2f);
}
public static Spannable replaceAnimatedEmoji(CharSequence text, ArrayList<TLRPC.MessageEntity> entities, Paint.FontMetricsInt fontMetricsInt, boolean top, float scale) {
if (text == null) {
return null;
}
Spannable spannable = text instanceof Spannable ? (Spannable) text : new SpannableString(text);
if (entities == null) {
return spannable;
@ -6551,9 +6653,9 @@ public class MessageObject {
AnimatedEmojiSpan span;
if (entity.document != null) {
span = new AnimatedEmojiSpan(entity.document, fontMetricsInt);
span = new AnimatedEmojiSpan(entity.document, scale, fontMetricsInt);
} else {
span = new AnimatedEmojiSpan(entity.document_id, fontMetricsInt);
span = new AnimatedEmojiSpan(entity.document_id, scale, fontMetricsInt);
}
span.top = top;
spannable.setSpan(span, messageEntity.offset, messageEntity.offset + messageEntity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@ -6761,7 +6863,7 @@ public class MessageObject {
}
}
int count = runs.size();
final int count = Math.min(MediaDataController.MAX_STYLE_RUNS_COUNT, runs.size());
for (int a = 0; a < count; a++) {
TextStyleSpan.TextStyleRun run = runs.get(a);
@ -6917,6 +7019,12 @@ public class MessageObject {
return getMedia(messageOwner) instanceof TLRPC.TL_messageMediaWebPage && getMedia(messageOwner).webpage != null && !TextUtils.isEmpty(getMedia(messageOwner).webpage.embed_url) && "YouTube".equals(getMedia(messageOwner).webpage.site_name);
}
private Boolean isEmbedVideoCached;
public boolean isEmbedVideo() {
if (isEmbedVideoCached != null) return messageOwner != null && messageOwner.media != null && messageOwner.media.webpage != null && isEmbedVideoCached;
return isEmbedVideoCached = messageOwner != null && messageOwner.media != null && messageOwner.media.webpage != null && !TextUtils.isEmpty(WebPlayerView.getYouTubeVideoId(messageOwner.media.webpage.url));
}
public int getMaxMessageTextWidth() {
int maxWidth = 0;
if (AndroidUtilities.isTablet() && eventId != 0) {
@ -6939,9 +7047,7 @@ public class MessageObject {
} else if (segment.length() == 6 || segment.length() == 13 && segment.charAt(6) == '-') {
maxWidth = dp(200);
}
} catch (Exception ignore) {
}
} catch (Exception ignore) {}
} else if (isAndroidTheme()) {
maxWidth = dp(200);
}
@ -8272,9 +8378,6 @@ public class MessageObject {
} else {
document = media != null ? media.document : null;
}
if (media != null && !media.alt_documents.isEmpty()) {
document = VideoPlayer.getDocumentForThumb(UserConfig.selectedAccount, media);
}
if (document != null) {
return document.size;
}
@ -8286,6 +8389,8 @@ public class MessageObject {
return highestQuality.document.size;
} else if (thumbQuality != null) {
return thumbQuality.document.size;
} else if (cachedQuality != null) {
return cachedQuality.document.size;
}
return getMessageSize(messageOwner);
}
@ -8506,6 +8611,12 @@ public class MessageObject {
return null;
}
public boolean canSetReaction() {
if (messageOwner instanceof TLRPC.TL_messageService)
return messageOwner.reactions_are_possible;
return true;
}
public boolean isSending() {
return messageOwner.send_state == MESSAGE_SEND_STATE_SENDING && messageOwner.id < 0;
}
@ -8765,6 +8876,13 @@ public class MessageObject {
return getDocument(messageOwner);
}
public TLRPC.Document getDocumentFast() {
if (emojiAnimatedSticker != null) {
return emojiAnimatedSticker;
}
return getDocument(messageOwner);
}
public static TLRPC.Document getDocument(TLRPC.Message message) {
if (getMedia(message) instanceof TLRPC.TL_messageMediaWebPage) {
return getMedia(message).webpage.document;
@ -9103,6 +9221,10 @@ public class MessageObject {
}
public int getApproximateHeight() {
return getApproximateHeight(false);
}
public int getApproximateHeight(boolean fast) {
if (type == TYPE_TEXT) {
int height = textHeight() + (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaWebPage && getMedia(messageOwner).webpage instanceof TLRPC.TL_webPage ? dp(100) : 0);
if (isReply()) {
@ -9178,7 +9300,12 @@ public class MessageObject {
if (photoHeight > AndroidUtilities.getPhotoSize()) {
photoHeight = AndroidUtilities.getPhotoSize();
}
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize());
TLRPC.PhotoSize currentPhotoObject;
if (fast) {
currentPhotoObject = photoThumbs == null || photoThumbs.isEmpty() ? null : photoThumbs.get(0);
} else {
currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(photoThumbs, AndroidUtilities.getPhotoSize());
}
if (currentPhotoObject != null) {
float scale = (float) currentPhotoObject.w / (float) photoWidth;
@ -9191,7 +9318,7 @@ public class MessageObject {
} else if (h < dp(120)) {
h = dp(120);
}
if (needDrawBluredPreview()) {
if (!fast && needDrawBluredPreview()) {
if (AndroidUtilities.isTablet()) {
h = (int) (AndroidUtilities.getMinTabletSide() * 0.5f);
} else {
@ -10277,7 +10404,7 @@ public class MessageObject {
}
public boolean isReactionsAvailable() {
return !isEditing() && !isSponsored() && isSent() && messageOwner.action == null && !isExpiredStory();
return !isEditing() && !isSponsored() && isSent() && !isExpiredStory() && canSetReaction();
}
public boolean isPaidReactionChosen() {
@ -11131,7 +11258,7 @@ public class MessageObject {
public ArrayList<VideoPlayer.Quality> videoQualities;
public TLRPC.Document qualityToSave;
public VideoPlayer.VideoUri highestQuality, thumbQuality;
public VideoPlayer.VideoUri highestQuality, thumbQuality, cachedQuality;
public boolean hasVideoQualities() {
if (videoQualitiesCached == null) {
@ -11143,6 +11270,7 @@ public class MessageObject {
videoQualitiesCached = videoQualities != null && videoQualities.size() > 1;
highestQuality = VideoPlayer.getQualityForPlayer(videoQualities);
thumbQuality = VideoPlayer.getQualityForThumb(videoQualities);
cachedQuality = VideoPlayer.getCachedQuality(videoQualities);
} catch (Exception e) {
FileLog.e(e);
videoQualitiesCached = false;
@ -11152,7 +11280,7 @@ public class MessageObject {
}
public boolean isStarGiftAction() {
return messageOwner != null && messageOwner.action instanceof TLRPC.TL_messageActionStarGift;
return messageOwner != null && (messageOwner.action instanceof TLRPC.TL_messageActionStarGift || messageOwner.action instanceof TLRPC.TL_messageActionStarGiftUnique);
}
public boolean mediaExists() {
@ -11163,12 +11291,49 @@ public class MessageObject {
}
public void updateQualitiesCached(boolean useFileDatabaseQueue) {
if (videoQualities == null) return;
if (videoQualities == null) {
cachedQuality = null;
return;
}
for (VideoPlayer.Quality q : videoQualities) {
for (VideoPlayer.VideoUri u : q.uris) {
u.updateCached(useFileDatabaseQueue);
}
}
highestQuality = VideoPlayer.getQualityForPlayer(videoQualities);
thumbQuality = VideoPlayer.getQualityForThumb(videoQualities);
cachedQuality = VideoPlayer.getCachedQuality(videoQualities);
}
public boolean areTags() {
if (messageOwner == null) return false;
if (messageOwner.reactions == null) return false;
return messageOwner.reactions.reactions_as_tags;
}
public boolean openedInViewer;
private Integer cachedStartsTimestamp;
public int getVideoStartsTimestamp() {
if (cachedStartsTimestamp != null) return cachedStartsTimestamp;
if (!isVideo()) return cachedStartsTimestamp = -1;
final TLRPC.MessageMedia media = getMedia(this);
if (media.video_timestamp != 0) {
return media.video_timestamp;
}
if (media != null && media.webpage != null && media.webpage.url != null) {
try {
return cachedStartsTimestamp = LaunchActivity.getTimestampFromLink(Uri.parse(media.webpage.url));
} catch (Exception e) {}
}
return cachedStartsTimestamp = -1;
}
public Float cachedSavedTimestamp;
public float getVideoSavedProgress() {
// if (cachedSavedTimestamp != null) return cachedSavedTimestamp;
if (cachedSavedTimestamp != null) return PhotoViewer.getSavedProgressFast(this);
return cachedSavedTimestamp = PhotoViewer.getSavedProgress(this);
}
}

View file

@ -13,6 +13,7 @@ import static org.telegram.messenger.LocaleController.getString;
import static org.telegram.messenger.NotificationsController.TYPE_CHANNEL;
import static org.telegram.messenger.NotificationsController.TYPE_PRIVATE;
import static org.telegram.messenger.NotificationsController.TYPE_REACTIONS_MESSAGES;
import static org.telegram.ui.Stars.StarsController.findAttribute;
import android.Manifest;
import android.app.Activity;
@ -60,8 +61,11 @@ import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.tgnet.tl.TL_phone;
import org.telegram.tgnet.tl.TL_stars;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.tgnet.tl.TL_chatlists;
import org.telegram.ui.ActionBar.ActionBarLayout;
@ -114,6 +118,7 @@ import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
public class MessagesController extends BaseController implements NotificationCenter.NotificationCenterDelegate {
@ -131,8 +136,8 @@ public class MessagesController extends BaseController implements NotificationCe
private final LongSparseArray<TLRPC.TL_chatInviteExported> exportedChats = new LongSparseArray<>();
public ArrayList<TLRPC.RecentMeUrl> hintDialogs = new ArrayList<>();
public SparseArray<ArrayList<TLRPC.Dialog>> dialogsByFolder = new SparseArray<>();
protected ArrayList<TLRPC.Dialog> allDialogs = new ArrayList<>();
public final SparseArray<ArrayList<TLRPC.Dialog>> dialogsByFolder = new SparseArray<>();
protected final ArrayList<TLRPC.Dialog> allDialogs = new ArrayList<>();
public ArrayList<TLRPC.Dialog> dialogsForward = new ArrayList<>();
public ArrayList<TLRPC.Dialog> dialogsServerOnly = new ArrayList<>();
public ArrayList<TLRPC.Dialog> dialogsCanAddUsers = new ArrayList<>();
@ -249,7 +254,7 @@ public class MessagesController extends BaseController implements NotificationCe
private long lastViewsCheckTime;
public SparseIntArray premiumFeaturesTypesToPosition = new SparseIntArray();
public SparseIntArray businessFeaturesTypesToPosition = new SparseIntArray();
public ArrayList<DialogFilter> dialogFilters = new ArrayList<>();
public ArrayList<DialogFilter> frozenDialogFilters = null;
public ArrayList<Long> hiddenUndoChats = new ArrayList<>();
@ -644,19 +649,15 @@ public class MessagesController extends BaseController implements NotificationCe
public boolean starrefConnectAllowed;
public int starrefMinCommissionPermille;
public int starrefMaxCommissionPermille;
public int botVerificationDescriptionLengthLimit;
public long paidReactionsAnonymousTime;
public Boolean paidReactionsAnonymous;
public int savedDialogsPinnedLimitDefault;
public int savedDialogsPinnedLimitPremium;
public boolean savedViewAsChats;
public boolean storyQualityFull;
public int uploadMaxFileParts;
public int uploadMaxFilePartsPremium;
public String premiumBotUsername;
public String premiumInvoiceSlug;
@ -703,6 +704,7 @@ public class MessagesController extends BaseController implements NotificationCe
public int stargiftsConvertPeriodMax;
public boolean videoIgnoreAltDocuments;
public boolean disableBotFullscreenBlur;
public String tonBlockchainExplorerUrl;
public int checkResetLangpack;
public boolean folderTags;
@ -1137,6 +1139,7 @@ public class MessagesController extends BaseController implements NotificationCe
public static class DialogFilter {
public int id;
public String name;
public ArrayList<TLRPC.MessageEntity> entities = new ArrayList<>();
public int unreadCount;
public volatile int pendingUnreadCount;
public int order;
@ -1147,6 +1150,7 @@ public class MessagesController extends BaseController implements NotificationCe
public ArrayList<TLRPC.Dialog> dialogs = new ArrayList<>();
public ArrayList<TLRPC.Dialog> dialogsForward = new ArrayList<>();
public int color;
public boolean title_noanimate;
public ArrayList<TL_chatlists.TL_exportedChatlistInvite> invites = null;
@ -1559,6 +1563,7 @@ public class MessagesController extends BaseController implements NotificationCe
stargiftsConvertPeriodMax = mainPreferences.getInt("stargiftsConvertPeriodMax", isTest ? 300 : 90 * 86400);
videoIgnoreAltDocuments = mainPreferences.getBoolean("videoIgnoreAltDocuments", false);
disableBotFullscreenBlur = mainPreferences.getBoolean("disableBotFullscreenBlur", false);
tonBlockchainExplorerUrl = mainPreferences.getString("tonBlockchainExplorerUrl", "https://tonviewer.com/");
storiesPosting = mainPreferences.getString("storiesPosting", "enabled");
storiesEntities = mainPreferences.getString("storiesEntities", "premium");
storiesExportNopublicLink = mainPreferences.getBoolean("storiesExportNopublicLink", false);
@ -1615,6 +1620,7 @@ public class MessagesController extends BaseController implements NotificationCe
starrefStartParamPrefixes = mainPreferences.getStringSet("starrefStartParamPrefixes", new HashSet<>(Arrays.asList("_tgr_")));
starrefMinCommissionPermille = mainPreferences.getInt("starrefMinCommissionPermille", 1);
starrefMaxCommissionPermille = mainPreferences.getInt("starrefMaxCommissionPermille", 400);
botVerificationDescriptionLengthLimit = mainPreferences.getInt("botVerificationDescriptionLengthLimit", 70);
paidReactionsAnonymousTime = mainPreferences.getLong("paidReactionsAnonymousTime", 0);
paidReactionsAnonymous = mainPreferences.contains("paidReactionsAnonymous") && (System.currentTimeMillis() - paidReactionsAnonymousTime) < 1000 * 60 * 60 * 2 ? mainPreferences.getBoolean("paidReactionsAnonymous", false) : null;
scheduleTranscriptionUpdate();
@ -1783,10 +1789,10 @@ public class MessagesController extends BaseController implements NotificationCe
if (response instanceof TLRPC.TL_messages_chats) {
TLRPC.TL_messages_chats res = (TLRPC.TL_messages_chats) response;
chats.addAll(res.chats);
} else if (response instanceof TLRPC.Vector) {
TLRPC.Vector res = (TLRPC.Vector) response;
for (int a = 0, N = res.objects.size(); a < N; a++) {
TLRPC.User user = (TLRPC.User) res.objects.get(a);
} else if (response instanceof Vector) {
Vector vector = (Vector) response;
for (int a = 0, N = vector.objects.size(); a < N; a++) {
TLRPC.User user = (TLRPC.User) vector.objects.get(a);
users.add(user);
}
} else if (response instanceof TLRPC.TL_messages_peerDialogs) {
@ -2211,11 +2217,8 @@ public class MessagesController extends BaseController implements NotificationCe
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingSuggestedFilters = false;
suggestedFilters.clear();
if (response instanceof TLRPC.Vector) {
TLRPC.Vector vector = (TLRPC.Vector) response;
for (int a = 0, N = vector.objects.size(); a < N; a++) {
suggestedFilters.add((TLRPC.TL_dialogFilterSuggested) vector.objects.get(a));
}
if (response instanceof Vector) {
suggestedFilters.addAll(((Vector<TLRPC.TL_dialogFilterSuggested>) response).objects);
}
getNotificationCenter().postNotificationName(NotificationCenter.suggestedFiltersLoaded);
}));
@ -2240,9 +2243,9 @@ public class MessagesController extends BaseController implements NotificationCe
}
TLRPC.TL_messages_getDialogFilters req = new TLRPC.TL_messages_getDialogFilters();
getConnectionsManager().sendRequest(req, (response, error) -> {
if (response instanceof TLRPC.Vector) {
if (response instanceof Vector) {
ArrayList<TLRPC.DialogFilter> filters = new ArrayList<>();
TLRPC.Vector vector = (TLRPC.Vector) response;
Vector vector = (Vector) response;
for (int i = 0; i < vector.objects.size(); ++i) {
filters.add((TLRPC.DialogFilter) vector.objects.get(i));
}
@ -2367,20 +2370,69 @@ public class MessagesController extends BaseController implements NotificationCe
lockFiltersInternal();
}
public void updateEmojiStatus(TLRPC.EmojiStatus newStatus) {
TLRPC.TL_account_updateEmojiStatus req = new TLRPC.TL_account_updateEmojiStatus();
req.emoji_status = newStatus;
TLRPC.User user = getUserConfig().getCurrentUser();
if (user != null) {
user.emoji_status = req.emoji_status;
getNotificationCenter().postNotificationName(NotificationCenter.userEmojiStatusUpdated, user);
getMessagesController().updateEmojiStatusUntilUpdate(user.id, user.emoji_status);
public static TLRPC.TL_emojiStatusCollectible emojiStatusCollectibleFromGift(TL_stars.TL_starGiftUnique gift) {
final TLRPC.TL_emojiStatusCollectible status = new TLRPC.TL_emojiStatusCollectible();
status.collectible_id = gift.id;
final TL_stars.starGiftAttributeModel model = findAttribute(gift.attributes, TL_stars.starGiftAttributeModel.class);
final TL_stars.starGiftAttributeBackdrop backdrop = findAttribute(gift.attributes, TL_stars.starGiftAttributeBackdrop.class);
final TL_stars.starGiftAttributePattern pattern = findAttribute(gift.attributes, TL_stars.starGiftAttributePattern.class);
status.title = gift.title + " #" + gift.num;
if (model != null) {
status.document_id = model.document.id;
}
getConnectionsManager().sendRequest(req, (res, err) -> {
if (!(res instanceof TLRPC.TL_boolTrue)) {
// TODO: reject
if (pattern != null) {
status.pattern_document_id = pattern.document.id;
}
if (backdrop != null) {
status.center_color = backdrop.center_color;
status.edge_color = backdrop.edge_color;
status.text_color = backdrop.text_color;
status.pattern_color = backdrop.pattern_color;
}
return status;
}
public void updateEmojiStatus(TLRPC.EmojiStatus newStatus) {
updateEmojiStatus(newStatus, null);
}
public void updateEmojiStatus(TLRPC.EmojiStatus newStatus, TL_stars.StarGift gift) {
updateEmojiStatus(0, newStatus, gift);
}
public void updateEmojiStatus(long dialogId, TLRPC.EmojiStatus newStatus, TL_stars.StarGift gift) {
final boolean myself = dialogId == 0 || dialogId == getUserConfig().getClientUserId();
TLRPC.EmojiStatus new_emoji_status = newStatus;
if (new_emoji_status instanceof TLRPC.TL_inputEmojiStatusCollectible && gift instanceof TL_stars.TL_starGiftUnique) {
new_emoji_status = emojiStatusCollectibleFromGift((TL_stars.TL_starGiftUnique) gift);
}
TLObject r;
if (myself) {
TL_account.updateEmojiStatus req = new TL_account.updateEmojiStatus();
req.emoji_status = newStatus;
r = req;
TLRPC.User user = getUserConfig().getCurrentUser();
if (user != null) {
user.emoji_status = new_emoji_status;
getNotificationCenter().postNotificationName(NotificationCenter.userEmojiStatusUpdated, user);
}
});
} else {
TLRPC.TL_channels_updateEmojiStatus req = new TLRPC.TL_channels_updateEmojiStatus();
req.channel = getInputChannel(-dialogId);
req.emoji_status = newStatus;
r = req;
TLRPC.Chat chat = getChat(-dialogId);
if (chat != null) {
chat.flags |= 512;
chat.emoji_status = new_emoji_status;
putChat(chat, true);
}
}
getMessagesController().updateEmojiStatusUntilUpdate(dialogId, new_emoji_status);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_EMOJI_STATUS);
getConnectionsManager().sendRequest(r, null);
}
public void removeFilter(DialogFilter filter) {
@ -3760,6 +3812,17 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
case "ton_blockchain_explorer_url": {
if (value.value instanceof TLRPC.TL_jsonString) {
TLRPC.TL_jsonString str = (TLRPC.TL_jsonString) value.value;
if (!TextUtils.equals(str.value, tonBlockchainExplorerUrl)) {
tonBlockchainExplorerUrl = str.value;
editor.putString("tonBlockchainExplorerUrl", tonBlockchainExplorerUrl);
changed = true;
}
}
break;
}
case "stories_posting": {
if (value.value instanceof TLRPC.TL_jsonString) {
TLRPC.TL_jsonString str = (TLRPC.TL_jsonString) value.value;
@ -4479,6 +4542,17 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
case "bot_verification_description_length_limit": {
if (value.value instanceof TLRPC.TL_jsonNumber) {
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
if (num.value != botVerificationDescriptionLengthLimit) {
botVerificationDescriptionLengthLimit = (int) num.value;
editor.putInt("botVerificationDescriptionLengthLimit", botVerificationDescriptionLengthLimit);
changed = true;
}
}
break;
}
}
}
@ -4769,6 +4843,8 @@ public class MessagesController extends BaseController implements NotificationCe
}
public static class PeerColor {
public int patternColor = 0;
public int textColor = 0;
public boolean isDefaultName;
public int id;
public boolean hidden;
@ -4901,6 +4977,24 @@ public class MessagesController extends BaseController implements NotificationCe
sb.append("}");
}
public static PeerColor fromCollectible(TLRPC.EmojiStatus status) {
if (!(status instanceof TLRPC.TL_emojiStatusCollectible)) return null;
final TLRPC.TL_emojiStatusCollectible s = (TLRPC.TL_emojiStatusCollectible) status;
final PeerColor peerColor = new PeerColor();
peerColor.id = -1;
peerColor.hidden = true;
peerColor.colors[0] = s.edge_color | 0xFF000000;
peerColor.colors[1] = s.center_color | 0xFF000000;
peerColor.colors[2] = s.edge_color | 0xFF000000;
peerColor.colors[3] = s.center_color | 0xFF000000;
peerColor.colors[4] = s.text_color | 0xFF000000;
peerColor.colors[5] = s.text_color | 0xFF000000;
System.arraycopy(peerColor.colors, 0, peerColor.darkColors, 0, 6);
peerColor.patternColor = s.pattern_color | 0xFF000000;
peerColor.textColor = s.text_color | 0xFF000000;
return peerColor;
}
public static PeerColor fromTL(TLRPC.TL_help_peerColorOption tl) {
if (tl == null) return null;
@ -5483,7 +5577,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
});
} else if (uploadingWallpaper != null && uploadingWallpaper.equals(location)) {
TLRPC.TL_account_uploadWallPaper req = new TLRPC.TL_account_uploadWallPaper();
TL_account.uploadWallPaper req = new TL_account.uploadWallPaper();
req.file = file;
req.mime_type = "image/jpeg";
Theme.OverrideWallpaperInfo overrideWallpaperInfo = uploadingWallpaperInfo;
@ -5567,7 +5661,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (uploadedFile != null && uploadedThumb != null) {
File f = new File(location);
TLRPC.TL_account_uploadTheme req = new TLRPC.TL_account_uploadTheme();
TL_account.uploadTheme req = new TL_account.uploadTheme();
req.mime_type = "application/x-tgtheme-android";
req.file_name = "theme.attheme";
req.file = uploadedFile;
@ -5650,7 +5744,7 @@ public class MessagesController extends BaseController implements NotificationCe
inputDocument.id = document.id;
inputDocument.file_reference = document.file_reference;
if (info == null || !info.creator) {
TLRPC.TL_account_createTheme req2 = new TLRPC.TL_account_createTheme();
TL_account.createTheme req2 = new TL_account.createTheme();
req2.document = inputDocument;
req2.flags |= 4;
req2.slug = info != null && !TextUtils.isEmpty(info.slug) ? info.slug : "";
@ -5669,7 +5763,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}));
} else {
TLRPC.TL_account_updateTheme req2 = new TLRPC.TL_account_updateTheme();
TL_account.updateTheme req2 = new TL_account.updateTheme();
TLRPC.TL_inputTheme inputTheme = new TLRPC.TL_inputTheme();
inputTheme.id = info.id;
inputTheme.access_hash = info.access_hash;
@ -6268,8 +6362,8 @@ public class MessagesController extends BaseController implements NotificationCe
if (inputPeer == null) return;
req.id.add(inputPeer);
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> {
if (res instanceof TLRPC.Vector) {
ArrayList<Object> objects = ((TLRPC.Vector) res).objects;
if (res instanceof Vector) {
ArrayList<Object> objects = ((Vector) res).objects;
ArrayList<TLRPC.User> users = new ArrayList<>();
for (int i = 0; i < objects.size(); ++i) {
if (objects.get(i) instanceof TLRPC.User) {
@ -6562,12 +6656,12 @@ public class MessagesController extends BaseController implements NotificationCe
if (result == null && load && !loadingGroupCalls.contains(chatId)) {
loadingGroupCalls.add(chatId);
if (chatFull.call != null) {
TLRPC.TL_phone_getGroupCall req = new TLRPC.TL_phone_getGroupCall();
TL_phone.getGroupCall req = new TL_phone.getGroupCall();
req.call = chatFull.call;
req.limit = 20;
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
TLRPC.TL_phone_groupCall groupCall = (TLRPC.TL_phone_groupCall) response;
TL_phone.groupCall groupCall = (TL_phone.groupCall) response;
putUsers(groupCall.users, false);
putChats(groupCall.chats, false);
@ -7147,7 +7241,7 @@ public class MessagesController extends BaseController implements NotificationCe
}, ConnectionsManager.RequestFlagFailOnServerErrors);
} else {
if (geo) {
TLRPC.TL_account_reportPeer req = new TLRPC.TL_account_reportPeer();
TL_account.reportPeer req = new TL_account.reportPeer();
if (currentChat != null) {
req.peer = getInputPeer(-currentChat.id);
} else if (currentUser != null) {
@ -8121,9 +8215,7 @@ public class MessagesController extends BaseController implements NotificationCe
TLRPC.TL_photos_deletePhotos req = new TLRPC.TL_photos_deletePhotos();
req.id.add(photo);
getDialogPhotos(dialogId).removePhoto(photo.id);
getConnectionsManager().sendRequest(req, (response, error) -> {
});
getConnectionsManager().sendRequest(req, null);
}
}
@ -8138,7 +8230,7 @@ public class MessagesController extends BaseController implements NotificationCe
public void saveTheme(Theme.ThemeInfo themeInfo, Theme.ThemeAccent accent, boolean night, boolean unsave) {
TLRPC.TL_theme info = accent != null ? accent.info : themeInfo.info;
if (info != null) {
TLRPC.TL_account_saveTheme req = new TLRPC.TL_account_saveTheme();
TL_account.saveTheme req = new TL_account.saveTheme();
TLRPC.TL_inputTheme inputTheme = new TLRPC.TL_inputTheme();
inputTheme.id = info.id;
inputTheme.access_hash = info.access_hash;
@ -8160,7 +8252,7 @@ public class MessagesController extends BaseController implements NotificationCe
boolean isBlured = accent == null && themeInfo.isBlured;
boolean isMotion = accent != null ? accent.patternMotion : themeInfo.isMotion;
TLRPC.TL_account_installTheme req = new TLRPC.TL_account_installTheme();
TL_account.installTheme req = new TL_account.installTheme();
req.dark = night;
if (info != null) {
req.format = "android";
@ -8175,7 +8267,7 @@ public class MessagesController extends BaseController implements NotificationCe
});
if (!TextUtils.isEmpty(slug)) {
TLRPC.TL_account_installWallPaper req2 = new TLRPC.TL_account_installWallPaper();
TL_account.installWallPaper req2 = new TL_account.installWallPaper();
TLRPC.TL_inputWallPaperSlug inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
inputWallPaperSlug.slug = slug;
req2.wallpaper = inputWallPaperSlug;
@ -8250,12 +8342,12 @@ public class MessagesController extends BaseController implements NotificationCe
TLObject req;
if (install) {
TLRPC.TL_account_installWallPaper request = new TLRPC.TL_account_installWallPaper();
TL_account.installWallPaper request = new TL_account.installWallPaper();
request.wallpaper = inputWallPaper;
request.settings = settings;
req = request;
} else {
TLRPC.TL_account_saveWallPaper request = new TLRPC.TL_account_saveWallPaper();
TL_account.saveWallPaper request = new TL_account.saveWallPaper();
request.wallpaper = inputWallPaper;
request.settings = settings;
req = request;
@ -9344,7 +9436,7 @@ public class MessagesController extends BaseController implements NotificationCe
getConnectionsManager().cancelRequest(statusRequest, true);
}
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
TL_account.updateStatus req = new TL_account.updateStatus();
req.offline = false;
statusRequest = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
@ -9365,7 +9457,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (statusRequest != 0) {
getConnectionsManager().cancelRequest(statusRequest, true);
}
TLRPC.TL_account_updateStatus req = new TLRPC.TL_account_updateStatus();
TL_account.updateStatus req = new TL_account.updateStatus();
req.offline = true;
statusRequest = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
@ -10577,7 +10669,7 @@ public class MessagesController extends BaseController implements NotificationCe
map.put(url, arrayList);
}
arrayList.addAll(messages);
TLRPC.TL_messages_getWebPagePreview req = new TLRPC.TL_messages_getWebPagePreview();
TL_account.getWebPagePreview req = new TL_account.getWebPagePreview();
req.message = url;
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
ArrayList<MessageObject> arrayList1 = map.remove(url);
@ -10585,13 +10677,20 @@ public class MessagesController extends BaseController implements NotificationCe
return;
}
TLRPC.TL_messages_messages messagesRes = new TLRPC.TL_messages_messages();
if (!(response instanceof TLRPC.TL_messageMediaWebPage)) {
TLRPC.TL_messageMediaWebPage media = null;
if (response instanceof TL_account.webPagePreview) {
final TL_account.webPagePreview preview = (TL_account.webPagePreview) response;
putUsers(preview.users, false);
if (preview.media instanceof TLRPC.TL_messageMediaWebPage) {
media = (TLRPC.TL_messageMediaWebPage) preview.media;
}
}
if (media == null) {
for (int a = 0; a < arrayList1.size(); a++) {
arrayList1.get(a).messageOwner.media.webpage = new TLRPC.TL_webPageEmpty();
messagesRes.messages.add(arrayList1.get(a).messageOwner);
}
} else {
TLRPC.TL_messageMediaWebPage media = (TLRPC.TL_messageMediaWebPage) response;
if (media.webpage instanceof TLRPC.TL_webPage || media.webpage instanceof TLRPC.TL_webPageEmpty) {
for (int a = 0; a < arrayList1.size(); a++) {
arrayList1.get(a).messageOwner.media.webpage = media.webpage;
@ -11262,7 +11361,7 @@ public class MessagesController extends BaseController implements NotificationCe
loadingNotificationSettings = 4;
for (int a = 0; a < 3; a++) {
TLRPC.TL_account_getNotifySettings req = new TLRPC.TL_account_getNotifySettings();
TL_account.getNotifySettings req = new TL_account.getNotifySettings();
if (a == 0) {
req.peer = new TLRPC.TL_inputNotifyChats();
} else if (a == 1) {
@ -11338,18 +11437,18 @@ public class MessagesController extends BaseController implements NotificationCe
}));
}
getConnectionsManager().sendRequest(new TLRPC.TL_account_getReactionsNotifySettings(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
getConnectionsManager().sendRequest(new TL_account.getReactionsNotifySettings(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
loadingNotificationSettings--;
if (res instanceof TLRPC.TL_reactionsNotifySettings) {
TLRPC.TL_reactionsNotifySettings notify_settings = (TLRPC.TL_reactionsNotifySettings) res;
if (res instanceof TL_account.TL_reactionsNotifySettings) {
TL_account.TL_reactionsNotifySettings notify_settings = (TL_account.TL_reactionsNotifySettings) res;
SharedPreferences.Editor editor = notificationsPreferences.edit();
editor.putBoolean("EnableReactionsMessages", notify_settings.messages_notify_from != null);
if (notify_settings.messages_notify_from != null) {
editor.putBoolean("EnableReactionsMessagesContacts", notify_settings.messages_notify_from instanceof TLRPC.TL_reactionNotificationsFromContacts);
editor.putBoolean("EnableReactionsMessagesContacts", notify_settings.messages_notify_from instanceof TL_account.TL_reactionNotificationsFromContacts);
}
editor.putBoolean("EnableReactionsStories", notify_settings.stories_notify_from != null);
if (notify_settings.stories_notify_from != null) {
editor.putBoolean("EnableReactionsStoriesContacts", notify_settings.stories_notify_from instanceof TLRPC.TL_reactionNotificationsFromContacts);
editor.putBoolean("EnableReactionsStoriesContacts", notify_settings.stories_notify_from instanceof TL_account.TL_reactionNotificationsFromContacts);
}
editor.putBoolean("EnableReactionsPreview", notify_settings.show_previews);
getNotificationsController().getNotificationsSettingsFacade().applySoundSettings(notify_settings.sound, editor, 0, 0, TYPE_REACTIONS_MESSAGES, false);
@ -11367,17 +11466,17 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void reloadReactionsNotifySettings() {
getConnectionsManager().sendRequest(new TLRPC.TL_account_getReactionsNotifySettings(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TLRPC.TL_reactionsNotifySettings) {
TLRPC.TL_reactionsNotifySettings notify_settings = (TLRPC.TL_reactionsNotifySettings) res;
getConnectionsManager().sendRequest(new TL_account.getReactionsNotifySettings(), (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TL_account.TL_reactionsNotifySettings) {
TL_account.TL_reactionsNotifySettings notify_settings = (TL_account.TL_reactionsNotifySettings) res;
SharedPreferences.Editor editor = notificationsPreferences.edit();
editor.putBoolean("EnableReactionsMessages", notify_settings.messages_notify_from != null);
if (notify_settings.messages_notify_from != null) {
editor.putBoolean("EnableReactionsMessagesContacts", notify_settings.messages_notify_from instanceof TLRPC.TL_reactionNotificationsFromContacts);
editor.putBoolean("EnableReactionsMessagesContacts", notify_settings.messages_notify_from instanceof TL_account.TL_reactionNotificationsFromContacts);
}
editor.putBoolean("EnableReactionsStories", notify_settings.stories_notify_from != null);
if (notify_settings.stories_notify_from != null) {
editor.putBoolean("EnableReactionsStoriesContacts", notify_settings.stories_notify_from instanceof TLRPC.TL_reactionNotificationsFromContacts);
editor.putBoolean("EnableReactionsStoriesContacts", notify_settings.stories_notify_from instanceof TL_account.TL_reactionNotificationsFromContacts);
}
editor.putBoolean("EnableReactionsPreview", notify_settings.show_previews);
getNotificationsController().getNotificationsSettingsFacade().applySoundSettings(notify_settings.sound, editor, 0, 0, TYPE_REACTIONS_MESSAGES, false);
@ -11391,7 +11490,7 @@ public class MessagesController extends BaseController implements NotificationCe
public void loadSignUpNotificationsSettings() {
if (!loadingNotificationSignUpSettings) {
loadingNotificationSignUpSettings = true;
TLRPC.TL_account_getContactSignUpNotification req = new TLRPC.TL_account_getContactSignUpNotification();
TL_account.getContactSignUpNotification req = new TL_account.getContactSignUpNotification();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingNotificationSignUpSettings = false;
SharedPreferences.Editor editor = notificationsPreferences.edit();
@ -13329,9 +13428,7 @@ public class MessagesController extends BaseController implements NotificationCe
req.top_msg_id = (int) topicId;
req.flags |= 1;
}
getConnectionsManager().sendRequest(req, (response, error) -> {
});
getConnectionsManager().sendRequest(req, null);
}
public void markDialogAsRead(long dialogId, int maxPositiveId, int maxNegativeId, int maxDate, boolean popup, long threadId, int countDiff, boolean readNow, int scheduledCount) {
@ -13954,8 +14051,8 @@ public class MessagesController extends BaseController implements NotificationCe
}
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
ArrayList<Long> lockedUserIds = new ArrayList<>();
if (res instanceof TLRPC.Vector) {
TLRPC.Vector vector = (TLRPC.Vector) res;
if (res instanceof Vector) {
Vector vector = (Vector) res;
for (int i = 0; i < vector.objects.size(); ++i) {
if (i < users.size() && vector.objects.get(i) instanceof TLRPC.TL_boolTrue) {
lockedUserIds.add(users.get(i).id);
@ -14466,7 +14563,7 @@ public class MessagesController extends BaseController implements NotificationCe
public void unregistedPush() {
if (getUserConfig().registeredForPush && SharedConfig.pushString.length() == 0) {
TLRPC.TL_account_unregisterDevice req = new TLRPC.TL_account_unregisterDevice();
TL_account.unregisterDevice req = new TL_account.unregisterDevice();
req.token = SharedConfig.pushString;
req.token_type = SharedConfig.pushType;
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
@ -14547,7 +14644,7 @@ public class MessagesController extends BaseController implements NotificationCe
Utilities.random.nextBytes(SharedConfig.pushAuthKey);
SharedConfig.saveConfig();
}
TLRPC.TL_account_registerDevice req = new TLRPC.TL_account_registerDevice();
TL_account.registerDevice req = new TL_account.registerDevice();
req.token_type = pushType;
req.token = regid;
req.no_muted = false;
@ -15514,8 +15611,8 @@ public class MessagesController extends BaseController implements NotificationCe
loadingUnreadDialogs = true;
TLRPC.TL_messages_getDialogUnreadMarks req = new TLRPC.TL_messages_getDialogUnreadMarks();
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
TLRPC.Vector vector = (TLRPC.Vector) response;
if (response instanceof Vector) {
final Vector vector = (Vector) response;
for (int a = 0, size = vector.objects.size(); a < size; a++) {
TLRPC.DialogPeer peer = (TLRPC.DialogPeer) vector.objects.get(a);
if (peer instanceof TLRPC.TL_dialogPeer) {
@ -16175,6 +16272,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
// must be run from Utilities.stageQueue
public void processUpdates(final TLRPC.Updates updates, boolean fromQueue) {
ArrayList<Long> needGetChannelsDiff = null;
boolean needGetDiff = false;
@ -16677,9 +16775,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (needReceivedQueue) {
TLRPC.TL_messages_receivedQueue req = new TLRPC.TL_messages_receivedQueue();
req.max_qts = getMessagesStorage().getLastQtsValue();
getConnectionsManager().sendRequest(req, (response, error) -> {
});
getConnectionsManager().sendRequest(req, null);
}
if (updateStatus) {
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_STATUS));
@ -18513,13 +18609,13 @@ public class MessagesController extends BaseController implements NotificationCe
}
} else if (baseUpdate instanceof TLRPC.TL_updatePhoneCall) {
TLRPC.TL_updatePhoneCall upd = (TLRPC.TL_updatePhoneCall) baseUpdate;
TLRPC.PhoneCall call = upd.phone_call;
TL_phone.PhoneCall call = upd.phone_call;
VoIPService svc = VoIPService.getSharedInstance();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Received call in update: " + call);
FileLog.d("call id " + call.id);
}
if (call instanceof TLRPC.TL_phoneCallRequested) {
if (call instanceof TL_phone.phoneCallRequested) {
if (call.date + callRingTimeout / 1000 < getConnectionsManager().getCurrentTime()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("ignoring too old call");
@ -18556,7 +18652,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Auto-declining call " + call.id + " because there's already active one");
}
TLRPC.TL_phone_discardCall req = new TLRPC.TL_phone_discardCall();
TL_phone.discardCall req = new TL_phone.discardCall();
req.peer = new TLRPC.TL_inputPhoneCall();
req.peer.access_hash = call.access_hash;
req.peer.id = call.id;
@ -18599,7 +18695,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (svc != null && call != null) {
svc.onCallUpdated(call);
} else {
if (call instanceof TLRPC.TL_phoneCallDiscarded) {
if (call instanceof TL_phone.TL_phoneCallDiscarded) {
VoIPPreNotificationService.dismiss(ApplicationLoader.applicationContext, false);
}
if (VoIPService.callIShouldHavePutIntoIntent != null) {
@ -18607,7 +18703,7 @@ public class MessagesController extends BaseController implements NotificationCe
FileLog.d("Updated the call while the service is starting");
}
if (call.id == VoIPService.callIShouldHavePutIntoIntent.id) {
VoIPService.callIShouldHavePutIntoIntent = call instanceof TLRPC.TL_phoneCallDiscarded ? null : call;
VoIPService.callIShouldHavePutIntoIntent = call instanceof TL_phone.TL_phoneCallDiscarded ? null : call;
FileLog.e("(2) set VoIPService.callIShouldHavePutIntoIntent = " + VoIPService.callIShouldHavePutIntoIntent);
}
}
@ -19434,7 +19530,7 @@ public class MessagesController extends BaseController implements NotificationCe
public SponsoredMessagesInfo getSponsoredMessages(long dialogId) {
SponsoredMessagesInfo info = sponsoredMessages.get(dialogId);
if (info != null && (info.loading || Math.abs(SystemClock.elapsedRealtime() - info.loadTime) <= 5 * 60 * 1000)) {
if (info != null && (info.loading || Math.abs(SystemClock.elapsedRealtime() - info.loadTime) <= /*15 * 60*/5 * 1000)) {
return info;
}
if (dialogId < 0 ? !ChatObject.isChannel(getChat(-dialogId)) : !UserObject.isBot(getUser(dialogId))) {
@ -19449,6 +19545,34 @@ public class MessagesController extends BaseController implements NotificationCe
getConnectionsManager().sendRequest(req, (response, error) -> {
ArrayList<MessageObject> result;
Integer posts_between;
if (response instanceof TLRPC.messages_SponsoredMessages) {
TLRPC.messages_SponsoredMessages res = (TLRPC.messages_SponsoredMessages) response;
if (res.messages.isEmpty()) {
@ -19521,6 +19645,7 @@ public class MessagesController extends BaseController implements NotificationCe
sponsoredMessages.remove(dialogId);
} else {
infoFinal.loadTime = SystemClock.elapsedRealtime();
infoFinal.loading = false;
infoFinal.messages = result;
infoFinal.posts_between = posts_between;
getNotificationCenter().postNotificationName(NotificationCenter.didLoadSponsoredMessages, dialogId, result);
@ -20956,14 +21081,14 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void updateEmojiStatusUntilUpdate(long dialogId, TLRPC.EmojiStatus status) {
if (status instanceof TLRPC.TL_emojiStatusUntil) {
emojiStatusUntilValues.put(dialogId, ((TLRPC.TL_emojiStatusUntil) status).until);
final int until = DialogObject.getEmojiStatusUntil(status);
if (until != 0) {
emojiStatusUntilValues.put(dialogId, until);
} else {
if (!emojiStatusUntilValues.containsKey(dialogId))
return;
emojiStatusUntilValues.remove(dialogId);
}
updateEmojiStatusUntil();
}
@ -21276,48 +21401,54 @@ public class MessagesController extends BaseController implements NotificationCe
public static class ChannelRecommendations {
public boolean wasPremium;
public final ArrayList<TLRPC.Chat> chats = new ArrayList<>();
public final ArrayList<TLObject> chats = new ArrayList<>();
public int more;
public static boolean hasRecommendations(ChannelRecommendations rec) {
return rec != null && !rec.chats.isEmpty();
}
public static boolean hasRecommendations(int currentAccount, long chatId) {
return hasRecommendations(MessagesController.getInstance(currentAccount).getChannelRecommendations(chatId));
public static boolean hasRecommendations(int currentAccount, long dialogId) {
return hasRecommendations(MessagesController.getInstance(currentAccount).getChannelRecommendations(dialogId));
}
}
private HashMap<Long, ChannelRecommendations> cachedChannelRecommendations;
public ChannelRecommendations getCachedChannelRecommendations(long chatId) {
public ChannelRecommendations getCachedChannelRecommendations(long dialogId) {
if (cachedChannelRecommendations == null) {
return null;
}
return cachedChannelRecommendations.get(chatId);
return cachedChannelRecommendations.get(dialogId);
}
public ChannelRecommendations getChannelRecommendations(long chatId) {
TLRPC.InputChannel inputChannel = getInputChannel(chatId);
if (inputChannel == null && chatId != 0) {
return null;
}
public ChannelRecommendations getChannelRecommendations(long dialogId) {
if (cachedChannelRecommendations == null) {
cachedChannelRecommendations = new HashMap<>();
}
final boolean isPremium = getUserConfig().isPremium();
ChannelRecommendations rec = null;
if (cachedChannelRecommendations.containsKey(chatId)) {
rec = cachedChannelRecommendations.get(chatId);
if (rec != null && rec.wasPremium == isPremium) {
if (cachedChannelRecommendations.containsKey(dialogId)) {
rec = cachedChannelRecommendations.get(dialogId);
if (rec == null || rec.wasPremium == isPremium) {
return rec;
}
}
cachedChannelRecommendations.put(chatId, null);
TLRPC.TL_channels_getChannelRecommendations req = new TLRPC.TL_channels_getChannelRecommendations();
if (chatId != 0) {
req.flags |= 1;
req.channel = inputChannel;
TLObject req;
if (dialogId > 0) {
TL_bots.getBotRecommendations r = new TL_bots.getBotRecommendations();
r.bot = getInputUser(dialogId);
if (r.bot == null) return null;
req = r;
} else {
TLRPC.TL_channels_getChannelRecommendations r = new TLRPC.TL_channels_getChannelRecommendations();
if (dialogId != 0) {
r.flags |= 1;
r.channel = getInputChannel(-dialogId);
if (r.channel == null) return null;
}
req = r;
}
cachedChannelRecommendations.put(dialogId, null);
getConnectionsManager().sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TLRPC.messages_Chats) {
ArrayList<TLRPC.Chat> chats = ((TLRPC.messages_Chats) res).chats;
@ -21331,8 +21462,22 @@ public class MessagesController extends BaseController implements NotificationCe
} else if (!getUserConfig().isPremium() && BuildVars.DEBUG_PRIVATE_VERSION) {
newrec.more = 90;
}
cachedChannelRecommendations.put(chatId, newrec);
getNotificationCenter().postNotificationName(NotificationCenter.channelRecommendationsLoaded, chatId);
cachedChannelRecommendations.put(dialogId, newrec);
getNotificationCenter().postNotificationName(NotificationCenter.channelRecommendationsLoaded, dialogId);
} else if (res instanceof TLRPC.Users) {
ArrayList<TLRPC.User> users = ((TLRPC.Users) res).users;
putUsers(users, false);
ChannelRecommendations newrec = new ChannelRecommendations();
newrec.wasPremium = isPremium;
newrec.chats.addAll(users);
if (res instanceof TLRPC.TL_usersSlice) {
newrec.more = Math.max(0, ((TLRPC.TL_usersSlice) res).count - users.size());
} else if (!getUserConfig().isPremium() && BuildVars.DEBUG_PRIVATE_VERSION) {
newrec.more = 90;
}
cachedChannelRecommendations.put(dialogId, newrec);
getNotificationCenter().postNotificationName(NotificationCenter.channelRecommendationsLoaded, dialogId);
}
}));
return rec;
@ -21790,8 +21935,8 @@ public class MessagesController extends BaseController implements NotificationCe
}
getConnectionsManager().sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
boolean changed = false;
if (res instanceof TLRPC.Vector) {
ArrayList<Object> objects = ((TLRPC.Vector) res).objects;
if (res instanceof Vector) {
final ArrayList<Object> objects = ((Vector) res).objects;
for (int i = 0; i < Math.min(ids.size(), objects.size()); ++i) {
long userId = ids.get(i);
boolean blocked = objects.get(i) instanceof TLRPC.TL_boolTrue;
@ -21824,7 +21969,7 @@ public class MessagesController extends BaseController implements NotificationCe
userFull.sponsored_enabled = false;
getMessagesStorage().updateUserInfo(userFull, false);
if (send) {
TLRPC.TL_account_toggleSponsoredMessages req = new TLRPC.TL_account_toggleSponsoredMessages();
TL_account.toggleSponsoredMessages req = new TL_account.toggleSponsoredMessages();
req.enabled = false;
getConnectionsManager().sendRequest(req, null);
}
@ -22211,4 +22356,43 @@ public class MessagesController extends BaseController implements NotificationCe
getMainSettings().edit().putInt("movecaptionhint", getMainSettings().getInt("movecaptionhint", 0) + 1).apply();
}
private final HashSet<StarsController.MessageId> reportedMessageDelivery = new HashSet<>();
private final HashSet<Pair<StarsController.MessageId, AtomicBoolean>> pendingReportMessageDelivery = new HashSet<>();
private final Runnable sendReportMessageDeliver = () -> {
final LongSparseArray<Pair<HashSet<Integer>, AtomicBoolean>> arr = new LongSparseArray<>();
for (Pair<StarsController.MessageId, AtomicBoolean> id : pendingReportMessageDelivery) {
Pair<HashSet<Integer>, AtomicBoolean> darr = arr.get(id.first.did);
if (darr == null) {
arr.put(id.first.did, darr = new Pair<>(new HashSet<>(), id.second));
}
if (!id.second.get()) {
darr.second.set(false);
}
darr.first.add(id.first.mid);
}
pendingReportMessageDelivery.clear();
for (int i = 0; i < arr.size(); ++i) {
final Pair<HashSet<Integer>, AtomicBoolean> p = arr.valueAt(i);
final long did = arr.keyAt(i);
final HashSet<Integer> mids = p.first;
final boolean push = p.second.get();
TLRPC.TL_reportMessagesDelivery req = new TLRPC.TL_reportMessagesDelivery();
req.peer = getInputPeer(did);
req.id.addAll(mids);
req.push = push;
getConnectionsManager().sendRequest(req, null);
}
};
public void reportMessageDelivery(long dialogId, int messageId, boolean push) {
final StarsController.MessageId key = StarsController.MessageId.from(dialogId, messageId);
if (reportedMessageDelivery.contains(key)) return;
reportedMessageDelivery.add(key);
pendingReportMessageDelivery.add(new Pair<>(key, new AtomicBoolean(push)));
AndroidUtilities.cancelRunOnUIThread(this.sendReportMessageDeliver);
AndroidUtilities.runOnUIThread(this.sendReportMessageDeliver);
}
}

View file

@ -36,8 +36,10 @@ import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.Vector;
import org.telegram.tgnet.tl.TL_bots;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.ActionBar.Theme;
@ -71,8 +73,8 @@ public class MessagesStorage extends BaseController {
private File cacheFile;
private File walCacheFile;
private File shmCacheFile;
private AtomicLong lastTaskId = new AtomicLong(System.currentTimeMillis());
private SparseArray<ArrayList<Runnable>> tasks = new SparseArray<>();
private final AtomicLong lastTaskId = new AtomicLong(System.currentTimeMillis());
private final SparseArray<ArrayList<Runnable>> tasks = new SparseArray<>();
private int lastDateValue = 0;
private int lastPtsValue = 0;
@ -87,16 +89,16 @@ public class MessagesStorage extends BaseController {
private int lastSavedDate = 0;
private int lastSavedQts = 0;
private ArrayList<MessagesController.DialogFilter> dialogFilters = new ArrayList<>();
private SparseArray<MessagesController.DialogFilter> dialogFiltersMap = new SparseArray<>();
private LongSparseArray<Boolean> unknownDialogsIds = new LongSparseArray<>();
private final ArrayList<MessagesController.DialogFilter> dialogFilters = new ArrayList<>();
private final SparseArray<MessagesController.DialogFilter> dialogFiltersMap = new SparseArray<>();
private final LongSparseArray<Boolean> unknownDialogsIds = new LongSparseArray<>();
private int mainUnreadCount;
private int archiveUnreadCount;
private volatile int pendingMainUnreadCount;
private volatile int pendingArchiveUnreadCount;
private boolean databaseCreated;
private CountDownLatch openSync = new CountDownLatch(1);
private final CountDownLatch openSync = new CountDownLatch(1);
private static volatile MessagesStorage[] Instance = new MessagesStorage[UserConfig.MAX_ACCOUNT_COUNT];
private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
@ -106,10 +108,10 @@ public class MessagesStorage extends BaseController {
}
}
public final static int LAST_DB_VERSION = 159;
public final static int LAST_DB_VERSION = 162;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
private final LongSparseIntArray dialogIsForum = new LongSparseIntArray();
public static MessagesStorage getInstance(int num) {
MessagesStorage localInstance = Instance[num];
@ -560,7 +562,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE INDEX IF NOT EXISTS folder_id_idx_dialogs ON dialogs(folder_id);").stepThis().dispose();
database.executeFast("CREATE INDEX IF NOT EXISTS flags_idx_dialogs ON dialogs(flags);").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_filter(id INTEGER PRIMARY KEY, ord INTEGER, unread_count INTEGER, flags INTEGER, title TEXT, color INTEGER DEFAULT -1)").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_filter(id INTEGER PRIMARY KEY, ord INTEGER, unread_count INTEGER, flags INTEGER, title TEXT, color INTEGER DEFAULT -1, entities BLOB, noanimate INTEGER)").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_filter_ep(id INTEGER, peer INTEGER, PRIMARY KEY (id, peer))").stepThis().dispose();
database.executeFast("CREATE TABLE dialog_filter_pin_v2(id INTEGER, peer INTEGER, pin INTEGER, PRIMARY KEY (id, peer))").stepThis().dispose();
@ -725,7 +727,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE TABLE business_links(data BLOB, order_value INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE fact_checks(hash INTEGER PRIMARY KEY, data BLOB, expires INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE popular_bots(uid INTEGER PRIMARY KEY, time INTEGER, offset TEXT);").stepThis().dispose();
database.executeFast("CREATE TABLE popular_bots(uid INTEGER PRIMARY KEY, time INTEGER, offset TEXT, pos INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE star_gifts2(id INTEGER PRIMARY KEY, data BLOB, hash INTEGER, time INTEGER, pos INTEGER);").stepThis().dispose();
@ -2436,7 +2438,7 @@ public class MessagesStorage extends BaseController {
usersToLoad.add(getUserConfig().getClientUserId());
filtersCursor = database.queryFinalized("SELECT id, ord, unread_count, flags, title, color FROM dialog_filter WHERE 1");
filtersCursor = database.queryFinalized("SELECT id, ord, unread_count, flags, title, color, entities, noanimate FROM dialog_filter WHERE 1");
boolean updateCounters = false;
boolean hasDefaultFilter = false;
@ -2448,6 +2450,13 @@ public class MessagesStorage extends BaseController {
filter.flags = filtersCursor.intValue(3);
filter.name = filtersCursor.stringValue(4);
filter.color = filtersCursor.intValue(5);
filter.entities = new ArrayList<>();
NativeByteBuffer buff = filtersCursor.byteBufferValue(6);
if (buff != null) {
filter.entities = Vector.deserialize(buff, TLRPC.MessageEntity::TLdeserialize, false);
buff.reuse();
}
filter.title_noanimate = filtersCursor.intValue(7) == 1;
dialogFilters.add(filter);
dialogFiltersMap.put(filter.id, filter);
filtersById.put(filter.id, filter);
@ -2517,15 +2526,21 @@ public class MessagesStorage extends BaseController {
dialogFiltersMap.put(filter.id, filter);
filtersById.put(filter.id, filter);
state = database.executeFast("REPLACE INTO dialog_filter VALUES(?, ?, ?, ?, ?, ?)");
state = database.executeFast("REPLACE INTO dialog_filter VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
state.bindInteger(1, filter.id);
state.bindInteger(2, filter.order);
state.bindInteger(3, filter.unreadCount);
state.bindInteger(4, filter.flags);
state.bindString(5, filter.name);
state.bindInteger(6, filter.color);
final Vector<TLRPC.MessageEntity> entitiesVector = new Vector<>(TLRPC.MessageEntity::TLdeserialize);
final NativeByteBuffer entitiesBuffer = new NativeByteBuffer(entitiesVector.getObjectSize());
entitiesVector.serializeToStream(entitiesBuffer);
state.bindByteBuffer(7, entitiesBuffer);
state.bindInteger(8, filter.title_noanimate ? 1 : 0);
state.stepThis().dispose();
state = null;
entitiesBuffer.reuse();
}
Collections.sort(dialogFilters, (o1, o2) -> {
@ -2996,15 +3011,22 @@ public class MessagesStorage extends BaseController {
dialogFiltersMap.put(filter.id, filter);
}
state = database.executeFast("REPLACE INTO dialog_filter VALUES(?, ?, ?, ?, ?, ?)");
state = database.executeFast("REPLACE INTO dialog_filter VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
state.bindInteger(1, filter.id);
state.bindInteger(2, filter.order);
state.bindInteger(3, filter.unreadCount);
state.bindInteger(4, filter.flags);
state.bindString(5, filter.id == 0 ? "ALL_CHATS" : filter.name);
state.bindInteger(6, filter.color);
final Vector<TLRPC.MessageEntity> entitiesVector = new Vector<>(TLRPC.MessageEntity::TLdeserialize);
entitiesVector.objects.addAll(filter.entities);
final NativeByteBuffer entitiesBuffer = new NativeByteBuffer(entitiesVector.getObjectSize());
entitiesVector.serializeToStream(entitiesBuffer);
state.bindByteBuffer(7, entitiesBuffer);
state.bindInteger(8, filter.title_noanimate ? 1 : 0);
state.step();
state.dispose();
entitiesBuffer.reuse();
state = null;
if (peers) {
database.executeFast("DELETE FROM dialog_filter_ep WHERE id = " + filter.id).stepThis().dispose();
@ -3138,9 +3160,14 @@ public class MessagesStorage extends BaseController {
filtersToDelete.remove(newFilter.id);
boolean changed = false;
boolean unreadChanged = false;
if (!TextUtils.equals(filter.name, newFilter.title)) {
if (!TextUtils.equals(filter.name, newFilter.title.text) || !MediaDataController.entitiesEqual(filter.entities, newFilter.title.entities)) {
changed = true;
filter.name = newFilter.title;
filter.name = newFilter.title.text;
filter.entities = newFilter.title.entities;
}
if (filter.title_noanimate != newFilter.title_noanimate) {
changed = true;
filter.title_noanimate= newFilter.title_noanimate;
}
final int color = (newFilter.flags & 134217728) != 0 ? newFilter.color : -1;
if (filter.color != color) {
@ -3280,7 +3307,9 @@ public class MessagesStorage extends BaseController {
filter = new MessagesController.DialogFilter();
filter.id = newFilter.id;
filter.flags = newFlags;
filter.name = newFilter.title;
filter.name = newFilter.title.text;
filter.entities = newFilter.title.entities;
filter.title_noanimate = newFilter.title_noanimate;
filter.color = (newFilter.flags & 134217728) != 0 ? newFilter.color : -1;
filter.pendingUnreadCount = -1;
for (int c = 0; c < 2; c++) {
@ -11097,6 +11126,7 @@ public class MessagesStorage extends BaseController {
SQLitePreparedStatement state_topics_update = null;
SQLitePreparedStatement state_media_topics = null;
SQLiteCursor cursor = null;
ArrayList<Pair<Long, Integer>> reportMessagesDelivery = null;
try {
if (messages != null && !messages.isEmpty() && MessageObject.isQuickReply(messages.get(0))) {
mode = ChatActivity.MODE_QUICK_REPLIES;
@ -11104,6 +11134,27 @@ public class MessagesStorage extends BaseController {
threadMessageId = MessageObject.getQuickReplyId(currentAccount, messages.get(0));
}
}
if (messages != null && mode == ChatActivity.MODE_DEFAULT) {
int currentTime = -1;
for (int i = 0; i < messages.size(); ++i) {
TLRPC.Message msg = messages.get(i);
if (msg != null && msg.report_delivery_until_date != 0) {
if (currentTime < 0) {
currentTime = getConnectionsManager().getCurrentTime();
}
if (currentTime <= msg.report_delivery_until_date) {
final long did = MessageObject.getDialogId(msg);
final int mid = msg.id;
if (reportMessagesDelivery == null) {
reportMessagesDelivery = new ArrayList<>();
}
reportMessagesDelivery.add(new Pair<>(did, mid));
}
msg.flags2 &=~ 32;
msg.report_delivery_until_date = 0;
}
}
}
final boolean scheduled = mode == ChatActivity.MODE_SCHEDULED;
final boolean saved = mode == ChatActivity.MODE_SAVED;
final boolean quickReplies = mode == ChatActivity.MODE_QUICK_REPLIES;
@ -12404,6 +12455,14 @@ public class MessagesStorage extends BaseController {
if (cursor != null) {
cursor = null;
}
if (reportMessagesDelivery != null) {
final ArrayList<Pair<Long, Integer>> finalReportMessagesDelivery = reportMessagesDelivery;
AndroidUtilities.runOnUIThread(() -> {
for (Pair<Long, Integer> p : finalReportMessagesDelivery) {
getMessagesController().reportMessageDelivery(p.first, p.second, false);
}
});
}
}
}
@ -16485,6 +16544,37 @@ public class MessagesStorage extends BaseController {
});
}
public int getDialogReadMaxSync(boolean outbox, long dialog_id) {
int max = 0;
SQLiteCursor cursor = null;
try {
if (outbox) {
cursor = database.queryFinalized("SELECT outbox_max FROM dialogs WHERE did = " + dialog_id);
if (cursor.next()) {
max = cursor.intValue(0);
}
} else {
cursor = database.queryFinalized("SELECT last_mid, inbox_max FROM dialogs WHERE did = " + dialog_id);
if (cursor.next()) {
int lastMid = cursor.intValue(0);
int inboxMax = cursor.intValue(1);
if (inboxMax > lastMid) {
max = 0;
} else {
max = inboxMax;
}
}
}
} catch (Exception e) {
checkSQLException(e);
} finally {
if (cursor != null) {
cursor.dispose();
}
}
return max;
}
public int getDialogReadMax(boolean outbox, long dialog_id) {
CountDownLatch countDownLatch = new CountDownLatch(1);
Integer[] max = new Integer[]{0};

View file

@ -67,13 +67,13 @@ import androidx.core.graphics.drawable.IconCompat;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.BubbleActivity;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.spoilers.SpoilerEffect;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PopupNotificationActivity;
import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.ui.Stories.recorder.StoryEntry;
import java.io.File;
@ -4086,8 +4086,10 @@ public class NotificationsController extends BaseController {
mBuilder.setContentText(message);
if (!allowSummary) {
detailText = message;
mBuilder.setStyle(new NotificationCompat.BigTextStyle().setBigContentTitle(name).setSummaryText(message));
} else {
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
}
mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
} else {
mBuilder.setContentText(detailText);
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
@ -5762,7 +5764,7 @@ public class NotificationsController extends BaseController {
return;
}
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
TL_account.updateNotifySettings req = new TL_account.updateNotifySettings();
req.settings = new TLRPC.TL_inputPeerNotifySettings();
final String key = NotificationsController.getSharedPrefKey(dialogId, topicId);
@ -5832,22 +5834,22 @@ public class NotificationsController extends BaseController {
public void updateServerNotificationsSettings(int type) {
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
if (type == TYPE_REACTIONS_MESSAGES || type == TYPE_REACTIONS_STORIES) {
TLRPC.TL_account_setReactionsNotifySettings req = new TLRPC.TL_account_setReactionsNotifySettings();
req.settings = new TLRPC.TL_reactionsNotifySettings();
TL_account.setReactionsNotifySettings req = new TL_account.setReactionsNotifySettings();
req.settings = new TL_account.TL_reactionsNotifySettings();
if (preferences.getBoolean("EnableReactionsMessages", true)) {
req.settings.flags |= 1;
if (preferences.getBoolean("EnableReactionsMessagesContacts", false)) {
req.settings.messages_notify_from = new TLRPC.TL_reactionNotificationsFromContacts();
req.settings.messages_notify_from = new TL_account.TL_reactionNotificationsFromContacts();
} else {
req.settings.messages_notify_from = new TLRPC.TL_reactionNotificationsFromAll();
req.settings.messages_notify_from = new TL_account.TL_reactionNotificationsFromAll();
}
}
if (preferences.getBoolean("EnableReactionsStories", true)) {
req.settings.flags |= 2;
if (preferences.getBoolean("EnableReactionsStoriesContacts", false)) {
req.settings.stories_notify_from = new TLRPC.TL_reactionNotificationsFromContacts();
req.settings.stories_notify_from = new TL_account.TL_reactionNotificationsFromContacts();
} else {
req.settings.stories_notify_from = new TLRPC.TL_reactionNotificationsFromAll();
req.settings.stories_notify_from = new TL_account.TL_reactionNotificationsFromAll();
}
}
req.settings.show_previews = preferences.getBoolean("EnableReactionsPreview", true);
@ -5856,7 +5858,7 @@ public class NotificationsController extends BaseController {
return;
}
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
TL_account.updateNotifySettings req = new TL_account.updateNotifySettings();
req.settings = new TLRPC.TL_inputPeerNotifySettings();
req.settings.flags = 5;
if (type == TYPE_GROUP) {

View file

@ -1,5 +1,7 @@
package org.telegram.messenger;
import static org.telegram.messenger.LocaleController.getString;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
@ -469,7 +471,7 @@ public class PushListenerController {
} else {
switch (loc_key) {
case "STORY_NOTEXT": {
messageText = LocaleController.getString("StoryNotificationSingle");
messageText = getString(R.string.StoryNotificationSingle);
message1 = null;
msg_id = story_id;
break;
@ -482,17 +484,17 @@ public class PushListenerController {
}
case "MESSAGE_SAME_WALLPAPER": {
messageText = LocaleController.formatString("ActionSetSameWallpaperForThisChat", R.string.ActionSetSameWallpaperForThisChat, args[0]);
message1 = LocaleController.getString(R.string.WallpaperSameNotification);
message1 = getString(R.string.WallpaperSameNotification);
break;
}
case "MESSAGE_WALLPAPER": {
messageText = LocaleController.formatString("ActionSetWallpaperForThisChat", R.string.ActionSetWallpaperForThisChat, args[0]);
message1 = LocaleController.getString(R.string.WallpaperNotification);
message1 = getString(R.string.WallpaperNotification);
break;
}
case "MESSAGE_RECURRING_PAY": {
messageText = LocaleController.formatString("NotificationMessageRecurringPay", R.string.NotificationMessageRecurringPay, args[0], args[1]);
message1 = LocaleController.getString(R.string.PaymentInvoice);
message1 = getString(R.string.PaymentInvoice);
break;
}
case "MESSAGE_TEXT":
@ -507,6 +509,18 @@ public class PushListenerController {
message1 = LocaleController.formatPluralStringComma("Gift2Notification", Integer.parseInt(args[1]));
break;
}
case "MESSAGE_UNIQUE_STARGIFT": {
userName = args[0];
messageText = LocaleController.formatString(R.string.NotificationMessageUniqueStarGift, args[0]);
message1 = getString(R.string.Gift2UniqueNotification);
break;
}
case "MESSAGE_STARGIFT_UPGRADE": {
userName = args[0];
messageText = LocaleController.formatString(R.string.NotificationMessageUniqueStarGiftUpgrade, args[0]);
message1 = getString(R.string.Gift2UniqueUpgradeNotification);
break;
}
case "MESSAGE_PAID_MEDIA": {
int stars = Integer.parseInt(args[1]);
messageText = LocaleController.formatPluralString("NotificationMessagePaidMedia", stars, args[0]);
@ -539,101 +553,101 @@ public class PushListenerController {
}
case "MESSAGE_NOTEXT": {
messageText = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, args[0]);
message1 = LocaleController.getString(R.string.Message);
message1 = getString(R.string.Message);
break;
}
case "MESSAGE_STORY": {
messageText = LocaleController.formatString("NotificationStory", R.string.NotificationStory, args[0]);
message1 = LocaleController.getString(R.string.Story);
message1 = getString(R.string.Story);
break;
}
case "MESSAGE_STORY_MENTION": {
messageText = LocaleController.getString(R.string.StoryNotificationMention);
messageText = getString(R.string.StoryNotificationMention);
message1 = null;
break;
}
case "MESSAGE_PHOTO": {
messageText = LocaleController.formatString("NotificationMessagePhoto", R.string.NotificationMessagePhoto, args[0]);
message1 = LocaleController.getString(R.string.AttachPhoto);
message1 = getString(R.string.AttachPhoto);
break;
}
case "MESSAGE_PHOTO_SECRET": {
messageText = LocaleController.formatString("NotificationMessageSDPhoto", R.string.NotificationMessageSDPhoto, args[0]);
message1 = LocaleController.getString(R.string.AttachDestructingPhoto);
message1 = getString(R.string.AttachDestructingPhoto);
break;
}
case "MESSAGE_VIDEO": {
messageText = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, args[0]);
message1 = LocaleController.getString(R.string.AttachVideo);
message1 = getString(R.string.AttachVideo);
break;
}
case "MESSAGE_VIDEO_SECRET": {
messageText = LocaleController.formatString("NotificationMessageSDVideo", R.string.NotificationMessageSDVideo, args[0]);
message1 = LocaleController.getString(R.string.AttachDestructingVideo);
message1 = getString(R.string.AttachDestructingVideo);
break;
}
case "MESSAGE_SCREENSHOT": {
messageText = LocaleController.getString(R.string.ActionTakeScreenshoot).replace("un1", args[0]);
messageText = getString(R.string.ActionTakeScreenshoot).replace("un1", args[0]);
break;
}
case "MESSAGE_ROUND": {
messageText = LocaleController.formatString("NotificationMessageRound", R.string.NotificationMessageRound, args[0]);
message1 = LocaleController.getString(R.string.AttachRound);
message1 = getString(R.string.AttachRound);
break;
}
case "MESSAGE_DOC": {
messageText = LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, args[0]);
message1 = LocaleController.getString(R.string.AttachDocument);
message1 = getString(R.string.AttachDocument);
break;
}
case "MESSAGE_STICKER": {
if (args.length > 1 && !TextUtils.isEmpty(args[1])) {
messageText = LocaleController.formatString("NotificationMessageStickerEmoji", R.string.NotificationMessageStickerEmoji, args[0], args[1]);
message1 = args[1] + " " + LocaleController.getString(R.string.AttachSticker);
message1 = args[1] + " " + getString(R.string.AttachSticker);
} else {
messageText = LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, args[0]);
message1 = LocaleController.getString(R.string.AttachSticker);
message1 = getString(R.string.AttachSticker);
}
break;
}
case "MESSAGE_AUDIO": {
messageText = LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, args[0]);
message1 = LocaleController.getString(R.string.AttachAudio);
messageText = LocaleController.formatString(R.string.NotificationMessageAudio, args[0]);
message1 = getString(R.string.AttachAudio);
break;
}
case "MESSAGE_CONTACT": {
messageText = LocaleController.formatString("NotificationMessageContact2", R.string.NotificationMessageContact2, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachContact);
messageText = LocaleController.formatString(R.string.NotificationMessageContact2, args[0], args[1]);
message1 = getString(R.string.AttachContact);
break;
}
case "MESSAGE_QUIZ": {
messageText = LocaleController.formatString("NotificationMessageQuiz2", R.string.NotificationMessageQuiz2, args[0], args[1]);
message1 = LocaleController.getString(R.string.QuizPoll);
messageText = LocaleController.formatString(R.string.NotificationMessageQuiz2, args[0], args[1]);
message1 = getString(R.string.QuizPoll);
break;
}
case "MESSAGE_POLL": {
messageText = LocaleController.formatString("NotificationMessagePoll2", R.string.NotificationMessagePoll2, args[0], args[1]);
message1 = LocaleController.getString(R.string.Poll);
messageText = LocaleController.formatString(R.string.NotificationMessagePoll2, args[0], args[1]);
message1 = getString(R.string.Poll);
break;
}
case "MESSAGE_GEO": {
messageText = LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, args[0]);
message1 = LocaleController.getString(R.string.AttachLocation);
message1 = getString(R.string.AttachLocation);
break;
}
case "MESSAGE_GEOLIVE": {
messageText = LocaleController.formatString("NotificationMessageLiveLocation", R.string.NotificationMessageLiveLocation, args[0]);
message1 = LocaleController.getString(R.string.AttachLiveLocation);
message1 = getString(R.string.AttachLiveLocation);
break;
}
case "MESSAGE_GIF": {
messageText = LocaleController.formatString("NotificationMessageGif", R.string.NotificationMessageGif, args[0]);
message1 = LocaleController.getString(R.string.AttachGif);
message1 = getString(R.string.AttachGif);
break;
}
case "MESSAGE_GAME": {
messageText = LocaleController.formatString("NotificationMessageGame", R.string.NotificationMessageGame, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachGame);
message1 = getString(R.string.AttachGame);
break;
}
case "MESSAGE_GAME_SCORE":
@ -643,7 +657,7 @@ public class PushListenerController {
}
case "MESSAGE_INVOICE": {
messageText = LocaleController.formatString("NotificationMessageInvoice", R.string.NotificationMessageInvoice, args[0], args[1]);
message1 = LocaleController.getString(R.string.PaymentInvoice);
message1 = getString(R.string.PaymentInvoice);
break;
}
case "MESSAGE_FWDS": {
@ -697,7 +711,7 @@ public class PushListenerController {
}
case "CHANNEL_MESSAGE_GIVEAWAY": {
messageText = LocaleController.formatString("NotificationMessageChannelGiveaway", R.string.NotificationMessageChannelGiveaway, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.BoostingGiveaway);
message1 = getString(R.string.BoostingGiveaway);
break;
}
case "CHANNEL_MESSAGE_GIVEAWAY_STARS": {
@ -706,87 +720,87 @@ public class PushListenerController {
winners = Integer.parseInt(args[1]);
} catch (Exception ignore) {}
messageText = LocaleController.formatString(R.string.NotificationMessageChannelStarsGiveaway2, args[0], LocaleController.formatPluralString("AmongWinners", winners), args[2]);
message1 = LocaleController.getString(R.string.BoostingGiveaway);
message1 = getString(R.string.BoostingGiveaway);
break;
}
case "CHANNEL_MESSAGE_NOTEXT": {
messageText = LocaleController.formatString("ChannelMessageNoText", R.string.ChannelMessageNoText, args[0]);
message1 = LocaleController.getString(R.string.Message);
message1 = getString(R.string.Message);
break;
}
case "CHANNEL_MESSAGE_STORY": {
messageText = LocaleController.formatString("NotificationChannelStory", R.string.NotificationChannelStory, args[0]);
message1 = LocaleController.getString(R.string.Story);
message1 = getString(R.string.Story);
break;
}
case "CHANNEL_MESSAGE_PHOTO": {
messageText = LocaleController.formatString("ChannelMessagePhoto", R.string.ChannelMessagePhoto, args[0]);
message1 = LocaleController.getString(R.string.AttachPhoto);
message1 = getString(R.string.AttachPhoto);
break;
}
case "CHANNEL_MESSAGE_VIDEO": {
messageText = LocaleController.formatString("ChannelMessageVideo", R.string.ChannelMessageVideo, args[0]);
message1 = LocaleController.getString(R.string.AttachVideo);
message1 = getString(R.string.AttachVideo);
break;
}
case "CHANNEL_MESSAGE_ROUND": {
messageText = LocaleController.formatString("ChannelMessageRound", R.string.ChannelMessageRound, args[0]);
message1 = LocaleController.getString(R.string.AttachRound);
message1 = getString(R.string.AttachRound);
break;
}
case "CHANNEL_MESSAGE_DOC": {
messageText = LocaleController.formatString("ChannelMessageDocument", R.string.ChannelMessageDocument, args[0]);
message1 = LocaleController.getString(R.string.AttachDocument);
message1 = getString(R.string.AttachDocument);
break;
}
case "CHANNEL_MESSAGE_STICKER": {
if (args.length > 1 && !TextUtils.isEmpty(args[1])) {
messageText = LocaleController.formatString("ChannelMessageStickerEmoji", R.string.ChannelMessageStickerEmoji, args[0], args[1]);
message1 = args[1] + " " + LocaleController.getString(R.string.AttachSticker);
message1 = args[1] + " " + getString(R.string.AttachSticker);
} else {
messageText = LocaleController.formatString("ChannelMessageSticker", R.string.ChannelMessageSticker, args[0]);
message1 = LocaleController.getString(R.string.AttachSticker);
message1 = getString(R.string.AttachSticker);
}
break;
}
case "CHANNEL_MESSAGE_AUDIO": {
messageText = LocaleController.formatString("ChannelMessageAudio", R.string.ChannelMessageAudio, args[0]);
message1 = LocaleController.getString(R.string.AttachAudio);
message1 = getString(R.string.AttachAudio);
break;
}
case "CHANNEL_MESSAGE_CONTACT": {
messageText = LocaleController.formatString("ChannelMessageContact2", R.string.ChannelMessageContact2, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachContact);
message1 = getString(R.string.AttachContact);
break;
}
case "CHANNEL_MESSAGE_QUIZ": {
messageText = LocaleController.formatString("ChannelMessageQuiz2", R.string.ChannelMessageQuiz2, args[0], args[1]);
message1 = LocaleController.getString(R.string.QuizPoll);
message1 = getString(R.string.QuizPoll);
break;
}
case "CHANNEL_MESSAGE_POLL": {
messageText = LocaleController.formatString("ChannelMessagePoll2", R.string.ChannelMessagePoll2, args[0], args[1]);
message1 = LocaleController.getString(R.string.Poll);
message1 = getString(R.string.Poll);
break;
}
case "CHANNEL_MESSAGE_GEO": {
messageText = LocaleController.formatString("ChannelMessageMap", R.string.ChannelMessageMap, args[0]);
message1 = LocaleController.getString(R.string.AttachLocation);
message1 = getString(R.string.AttachLocation);
break;
}
case "CHANNEL_MESSAGE_GEOLIVE": {
messageText = LocaleController.formatString("ChannelMessageLiveLocation", R.string.ChannelMessageLiveLocation, args[0]);
message1 = LocaleController.getString(R.string.AttachLiveLocation);
message1 = getString(R.string.AttachLiveLocation);
break;
}
case "CHANNEL_MESSAGE_GIF": {
messageText = LocaleController.formatString("ChannelMessageGIF", R.string.ChannelMessageGIF, args[0]);
message1 = LocaleController.getString(R.string.AttachGif);
message1 = getString(R.string.AttachGif);
break;
}
case "CHANNEL_MESSAGE_GAME": {
messageText = LocaleController.formatString("NotificationMessageGame", R.string.NotificationMessageGame, args[0]);
message1 = LocaleController.getString(R.string.AttachGame);
message1 = getString(R.string.AttachGame);
break;
}
case "CHANNEL_MESSAGE_FWDS": {
@ -821,7 +835,7 @@ public class PushListenerController {
}
case "CHAT_MESSAGE_GIVEAWAY": {
messageText = LocaleController.formatString("NotificationMessageChatGiveaway", R.string.NotificationMessageChatGiveaway, args[0], args[1], args[2], args[3]);
message1 = LocaleController.getString(R.string.BoostingGiveaway);
message1 = getString(R.string.BoostingGiveaway);
break;
}
case "CHAT_MESSAGE_GIVEAWAY_STARS": {
@ -830,7 +844,7 @@ public class PushListenerController {
winners = Integer.parseInt(args[2]);
} catch (Exception ignore) {}
messageText = LocaleController.formatString(R.string.NotificationMessageChatStarsGiveaway2, args[0], args[1], LocaleController.formatPluralString("AmongWinners", winners), args[3]);
message1 = LocaleController.getString(R.string.BoostingGiveaway);
message1 = getString(R.string.BoostingGiveaway);
break;
}
case "CHAT_MESSAGE_TEXT": {
@ -840,82 +854,82 @@ public class PushListenerController {
}
case "CHAT_MESSAGE_NOTEXT": {
messageText = LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, args[0], args[1]);
message1 = LocaleController.getString(R.string.Message);
message1 = getString(R.string.Message);
break;
}
case "CHAT_MESSAGE_STORY": {
messageText = LocaleController.formatString("NotificationChatStory", R.string.NotificationChatStory, args[0]);
message1 = LocaleController.getString(R.string.Story);
message1 = getString(R.string.Story);
break;
}
case "CHAT_MESSAGE_PHOTO": {
messageText = LocaleController.formatString("NotificationMessageGroupPhoto", R.string.NotificationMessageGroupPhoto, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachPhoto);
message1 = getString(R.string.AttachPhoto);
break;
}
case "CHAT_MESSAGE_VIDEO": {
messageText = LocaleController.formatString("NotificationMessageGroupVideo", R.string.NotificationMessageGroupVideo, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachVideo);
message1 = getString(R.string.AttachVideo);
break;
}
case "CHAT_MESSAGE_ROUND": {
messageText = LocaleController.formatString("NotificationMessageGroupRound", R.string.NotificationMessageGroupRound, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachRound);
message1 = getString(R.string.AttachRound);
break;
}
case "CHAT_MESSAGE_DOC": {
messageText = LocaleController.formatString("NotificationMessageGroupDocument", R.string.NotificationMessageGroupDocument, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachDocument);
message1 = getString(R.string.AttachDocument);
break;
}
case "CHAT_MESSAGE_STICKER": {
if (args.length > 2 && !TextUtils.isEmpty(args[2])) {
messageText = LocaleController.formatString("NotificationMessageGroupStickerEmoji", R.string.NotificationMessageGroupStickerEmoji, args[0], args[1], args[2]);
message1 = args[2] + " " + LocaleController.getString(R.string.AttachSticker);
message1 = args[2] + " " + getString(R.string.AttachSticker);
} else {
messageText = LocaleController.formatString("NotificationMessageGroupSticker", R.string.NotificationMessageGroupSticker, args[0], args[1]);
message1 = args[1] + " " + LocaleController.getString(R.string.AttachSticker);
message1 = args[1] + " " + getString(R.string.AttachSticker);
}
break;
}
case "CHAT_MESSAGE_AUDIO": {
messageText = LocaleController.formatString("NotificationMessageGroupAudio", R.string.NotificationMessageGroupAudio, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachAudio);
message1 = getString(R.string.AttachAudio);
break;
}
case "CHAT_MESSAGE_CONTACT": {
messageText = LocaleController.formatString("NotificationMessageGroupContact2", R.string.NotificationMessageGroupContact2, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.AttachContact);
message1 = getString(R.string.AttachContact);
break;
}
case "CHAT_MESSAGE_QUIZ": {
messageText = LocaleController.formatString("NotificationMessageGroupQuiz2", R.string.NotificationMessageGroupQuiz2, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.PollQuiz);
message1 = getString(R.string.PollQuiz);
break;
}
case "CHAT_MESSAGE_POLL": {
messageText = LocaleController.formatString("NotificationMessageGroupPoll2", R.string.NotificationMessageGroupPoll2, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.Poll);
message1 = getString(R.string.Poll);
break;
}
case "CHAT_MESSAGE_GEO": {
messageText = LocaleController.formatString("NotificationMessageGroupMap", R.string.NotificationMessageGroupMap, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachLocation);
message1 = getString(R.string.AttachLocation);
break;
}
case "CHAT_MESSAGE_GEOLIVE": {
messageText = LocaleController.formatString("NotificationMessageGroupLiveLocation", R.string.NotificationMessageGroupLiveLocation, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachLiveLocation);
message1 = getString(R.string.AttachLiveLocation);
break;
}
case "CHAT_MESSAGE_GIF": {
messageText = LocaleController.formatString("NotificationMessageGroupGif", R.string.NotificationMessageGroupGif, args[0], args[1]);
message1 = LocaleController.getString(R.string.AttachGif);
message1 = getString(R.string.AttachGif);
break;
}
case "CHAT_MESSAGE_GAME": {
messageText = LocaleController.formatString("NotificationMessageGroupGame", R.string.NotificationMessageGroupGame, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.AttachGame);
message1 = getString(R.string.AttachGame);
break;
}
case "CHAT_MESSAGE_GAME_SCORE": {
@ -924,7 +938,7 @@ public class PushListenerController {
}
case "CHAT_MESSAGE_INVOICE": {
messageText = LocaleController.formatString("NotificationMessageGroupInvoice", R.string.NotificationMessageGroupInvoice, args[0], args[1], args[2]);
message1 = LocaleController.getString(R.string.PaymentInvoice);
message1 = getString(R.string.PaymentInvoice);
break;
}
case "CHAT_CREATED":
@ -1235,8 +1249,8 @@ public class PushListenerController {
break;
}
case "ENCRYPTED_MESSAGE": {
messageText = LocaleController.getString(R.string.YouHaveNewMessage);
name = LocaleController.getString(R.string.SecretChatName);
messageText = getString(R.string.YouHaveNewMessage);
name = getString(R.string.SecretChatName);
localMessage = true;
break;
}
@ -1326,6 +1340,11 @@ public class PushListenerController {
arrayList.add(messageObject);
canRelease = false;
FileLog.d("PushListenerController push notification to NotificationsController of " + messageOwner.dialog_id);
if (!messageObject.isStoryReactionPush && !messageObject.isReactionPush && !messageObject.isStoryMentionPush && !messageObject.isStoryPush && !messageObject.isStoryPushHidden && !mention && !pinned && msg_id > 0) {
final long did = dialogId;
final int mid = msg_id;
AndroidUtilities.runOnUIThread(() -> MessagesController.getInstance(accountFinal).reportMessageDelivery(did, mid, true));
}
NotificationsController.getInstance(currentAccount).processNewMessages(arrayList, true, true, countDownLatch);
}
}

View file

@ -19,7 +19,9 @@ import org.telegram.SQLite.SQLiteCursor;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.TLClassStore;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
@ -43,7 +45,7 @@ public class SecretChatHelper extends BaseController {
public boolean new_key_used;
public int decryptedWithVersion;
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
stream.readInt64(exception);
date = stream.readInt32(exception);
layer = TLRPC.TL_decryptedMessageLayer.TLdeserialize(stream, stream.readInt32(exception), exception);
@ -53,7 +55,7 @@ public class SecretChatHelper extends BaseController {
new_key_used = stream.readBool(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(0);
stream.writeInt32(date);

View file

@ -56,6 +56,7 @@ import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.tgnet.tl.TL_stories;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
@ -87,8 +88,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -589,6 +588,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
public String path;
public String caption;
public String thumbPath;
public String coverPath;
public String paintPath;
public int ttl;
public ArrayList<TLRPC.MessageEntity> entities;
@ -1861,10 +1861,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
public int sendMessage(ArrayList<MessageObject> messages, final long peer, boolean forwardFromMyName, boolean hideCaption, boolean notify, int scheduleDate) {
return sendMessage(messages, peer, forwardFromMyName, hideCaption, notify, scheduleDate, null);
return sendMessage(messages, peer, forwardFromMyName, hideCaption, notify, scheduleDate, null, -1);
}
public int sendMessage(ArrayList<MessageObject> messages, final long peer, boolean forwardFromMyName, boolean hideCaption, boolean notify, int scheduleDate, MessageObject replyToTopMsg) {
public int sendMessage(ArrayList<MessageObject> messages, final long peer, boolean forwardFromMyName, boolean hideCaption, boolean notify, int scheduleDate, MessageObject replyToTopMsg, int video_timestamp) {
if (messages == null || messages.isEmpty()) {
return 0;
}
@ -2291,6 +2291,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
req.drop_author = forwardFromMyName;
req.drop_media_captions = hideCaption;
req.with_my_score = messages.size() == 1 && messages.get(0).messageOwner.with_my_score;
if (video_timestamp >= 0) {
req.flags |= 1048576;
req.video_timestamp = video_timestamp;
}
final ArrayList<TLRPC.Message> newMsgObjArr = arr;
final ArrayList<MessageObject> newMsgArr = new ArrayList<>(objArr);
@ -3409,10 +3413,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
parentFragment.showDialog(builder.create());
} else if ("SRP_ID_INVALID".equals(error.text)) {
TLRPC.TL_account_getPassword getPasswordReq = new TLRPC.TL_account_getPassword();
TL_account.getPassword getPasswordReq = new TL_account.getPassword();
ConnectionsManager.getInstance(currentAccount).sendRequest(getPasswordReq, (response2, error2) -> AndroidUtilities.runOnUIThread(() -> {
if (error2 == null) {
TLRPC.account_Password currentPassword = (TLRPC.account_Password) response2;
TL_account.Password currentPassword = (TL_account.Password) response2;
passwordFragment.setCurrentPasswordInfo(null, currentPassword);
TwoStepVerificationActivity.initPasswordNewAlgo(currentPassword);
sendCallback(cache, messageObject, button, passwordFragment.getNewSrpPassword(), passwordFragment, parentFragment);
@ -8151,6 +8155,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
SendMessagesHelper.SendMessageParams params2 = SendMessagesHelper.SendMessageParams.of(result.send_message.message, dialogId, replyToMsg, replyToTopMsg, webPage, !result.send_message.no_webpage, result.send_message.entities, result.send_message.reply_markup, params, notify, scheduleDate, null, false);
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue) {
TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue();
@ -8166,6 +8171,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
SendMessagesHelper.SendMessageParams params2 = SendMessagesHelper.SendMessageParams.of(venue, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate);
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaGeo) {
SendMessagesHelper.SendMessageParams params2;
@ -8184,6 +8190,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaContact) {
TLRPC.User user = new TLRPC.TL_user();
@ -8198,6 +8205,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
SendMessagesHelper.SendMessageParams params2 = SendMessagesHelper.SendMessageParams.of(user, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate);
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaInvoice) {
if (DialogObject.isEncryptedDialog(dialogId)) {
@ -8219,6 +8227,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
SendMessagesHelper.SendMessageParams params2 = SendMessagesHelper.SendMessageParams.of(messageMediaInvoice, dialogId, replyToMsg, replyToTopMsg, result.send_message.reply_markup, params, notify, scheduleDate);
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
} else if (result.send_message instanceof TLRPC.TL_botInlineMessageMediaWebPage) {
TLRPC.TL_botInlineMessageMediaWebPage request = (TLRPC.TL_botInlineMessageMediaWebPage) result.send_message;
@ -8227,6 +8236,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
SendMessagesHelper.SendMessageParams params2 = SendMessagesHelper.SendMessageParams.of(result.send_message.message, dialogId, replyToMsg, replyToTopMsg, webPage, !result.send_message.no_webpage, result.send_message.entities, result.send_message.reply_markup, params, notify, scheduleDate, null, false);
params2.quick_reply_shortcut = quick_reply_shortcut;
params2.quick_reply_shortcut_id = quick_reply_shortcut_id;
params2.replyQuote = quote;
accountInstance.getSendMessagesHelper().sendMessage(params2);
}
}

View file

@ -670,14 +670,6 @@ public class SharedConfig {
showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true);
configLoaded = true;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && debugWebView) {
WebView.setWebContentsDebuggingEnabled(true);
}
} catch (Exception e) {
FileLog.e(e);
}
}
}

View file

@ -1,16 +1,15 @@
package org.telegram.messenger;
import android.content.Context;
import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.tgnet.tl.TL_account;
import java.util.ArrayList;
import java.util.HashSet;
@ -287,7 +286,7 @@ public class UnconfirmedAuthController {
}
@Override
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
stream.writeInt32(0x7ab6618c);
stream.writeInt64(hash);
stream.writeInt32(date);
@ -304,7 +303,7 @@ public class UnconfirmedAuthController {
}
public void confirm(Utilities.Callback<Boolean> whenDone) {
TLRPC.TL_account_changeAuthorizationSettings req = new TLRPC.TL_account_changeAuthorizationSettings();
TL_account.changeAuthorizationSettings req = new TL_account.changeAuthorizationSettings();
req.hash = hash;
req.confirmed = true;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> {
@ -318,7 +317,7 @@ public class UnconfirmedAuthController {
}
public void deny(Utilities.Callback<Boolean> whenDone) {
TLRPC.TL_account_resetAuthorization req = new TLRPC.TL_account_resetAuthorization();
TL_account.resetAuthorization req = new TL_account.resetAuthorization();
req.hash = hash;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> {
AndroidUtilities.runOnUIThread(() -> {

View file

@ -14,16 +14,11 @@ import android.os.SystemClock;
import android.util.Base64;
import android.util.LongSparseArray;
import com.google.android.exoplayer2.util.Log;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
public class UserConfig extends BaseController {
@ -43,7 +38,7 @@ public class UserConfig extends BaseController {
public int lastHintsSyncTime;
public boolean draftsLoaded;
public boolean unreadDialogsLoaded = true;
public TLRPC.TL_account_tmpPassword tmpPassword;
public TL_account.tmpPassword tmpPassword;
public int ratingLoadTime;
public int botRatingLoadTime;
public int webappRatingLoadTime;
@ -353,7 +348,7 @@ public class UserConfig extends BaseController {
byte[] bytes = Base64.decode(string, Base64.DEFAULT);
if (bytes != null) {
SerializedData data = new SerializedData(bytes);
tmpPassword = TLRPC.TL_account_tmpPassword.TLdeserialize(data, data.readInt32(false), false);
tmpPassword = TL_account.tmpPassword.TLdeserialize(data, data.readInt32(false), false);
data.cleanup();
}
}

View file

@ -27,18 +27,18 @@ public class UserNameResolver {
LruCache<String, CachedPeer> resolvedCache = new LruCache<>(100);
HashMap<String, ArrayList<Consumer<Long>>> resolvingConsumers = new HashMap<>();
public int resolve(String username, Consumer<Long> resolveConsumer) {
public Runnable resolve(String username, Consumer<Long> resolveConsumer) {
return resolve(username, null, resolveConsumer);
}
public int resolve(String username, String referrer, Consumer<Long> resolveConsumer) {
public Runnable resolve(String username, String referrer, Consumer<Long> resolveConsumer) {
if (TextUtils.isEmpty(referrer)) {
CachedPeer cachedPeer = resolvedCache.get(username);
if (cachedPeer != null) {
if (System.currentTimeMillis() - cachedPeer.time < CACHE_TIME) {
resolveConsumer.accept(cachedPeer.peerId);
FileLog.d("resolve username from cache " + username + " " + cachedPeer.peerId);
return -1;
return null;
} else {
resolvedCache.remove(username);
}
@ -48,7 +48,7 @@ public class UserNameResolver {
ArrayList<Consumer<Long>> consumers = resolvingConsumers.get(username);
if (consumers != null) {
consumers.add(resolveConsumer);
return -1;
return null;
}
consumers = new ArrayList<>();
consumers.add(resolveConsumer);
@ -69,7 +69,7 @@ public class UserNameResolver {
}
req = resolveUsername;
}
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
final int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
ArrayList<Consumer<Long>> finalConsumers = resolvingConsumers.remove(username);
if (finalConsumers == null) {
return;
@ -105,6 +105,10 @@ public class UserNameResolver {
finalConsumers.get(i).accept(peerId);
}
}, ConnectionsManager.RequestFlagFailOnServerErrors));
return () -> {
resolvingConsumers.remove(username);
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
};
};
public void update(TLRPC.User oldUser, TLRPC.User user) {

View file

@ -159,13 +159,19 @@ public class UserObject {
if (MessagesController.getInstance(UserConfig.selectedAccount).premiumFeaturesBlocked()) {
return null;
}
if (emojiStatus instanceof TLRPC.TL_emojiStatus)
return ((TLRPC.TL_emojiStatus) emojiStatus).document_id;
if (emojiStatus instanceof TLRPC.TL_emojiStatusUntil) {
TLRPC.TL_emojiStatusUntil untilStatus = (TLRPC.TL_emojiStatusUntil) emojiStatus;
if (untilStatus.until > (int) (System.currentTimeMillis() / 1000)) {
return untilStatus.document_id;
if (emojiStatus instanceof TLRPC.TL_emojiStatus) {
final TLRPC.TL_emojiStatus status = (TLRPC.TL_emojiStatus) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return null;
}
return status.document_id;
}
if (emojiStatus instanceof TLRPC.TL_emojiStatusCollectible) {
final TLRPC.TL_emojiStatusCollectible status = (TLRPC.TL_emojiStatusCollectible) emojiStatus;
if ((status.flags & 1) != 0 && status.until <= (int) (System.currentTimeMillis() / 1000)) {
return null;
}
return status.document_id;
}
return null;
}
@ -199,7 +205,17 @@ public class UserObject {
}
public static long getProfileEmojiId(TLRPC.User user) {
if (user != null && user.emoji_status instanceof TLRPC.TL_emojiStatusCollectible) {
return ((TLRPC.TL_emojiStatusCollectible) user.emoji_status).pattern_document_id;
}
if (user != null && user.profile_color != null && (user.profile_color.flags & 2) != 0) return user.profile_color.background_emoji_id;
return 0;
}
public static long getProfileCollectibleId(TLRPC.User user) {
if (user != null && user.emoji_status instanceof TLRPC.TL_emojiStatusCollectible) {
return ((TLRPC.TL_emojiStatusCollectible) user.emoji_status).collectible_id;
}
return 0;
}
}

View file

@ -19,6 +19,8 @@ import org.telegram.messenger.video.MediaCodecPlayer;
import org.telegram.messenger.video.MediaCodecVideoConvertor;
import org.telegram.messenger.video.VideoPlayerHolderBase;
import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.InputSerializedData;
import org.telegram.tgnet.OutputSerializedData;
import org.telegram.tgnet.SerializedData;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
@ -107,7 +109,7 @@ public class VideoEditedInfo {
public byte subType;
@Override
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
super.readParams(stream, exception);
subType = stream.readByte(exception);
boolean hasPath = stream.readBool(exception);
@ -120,7 +122,7 @@ public class VideoEditedInfo {
}
@Override
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
super.serializeToStream(stream);
stream.writeByte(subType);
stream.writeBool(!TextUtils.isEmpty(documentAbsolutePath));
@ -141,6 +143,7 @@ public class VideoEditedInfo {
public static final byte TYPE_MESSAGE = 6;
public static final byte TYPE_LINK = 7;
public static final byte TYPE_WEATHER = 8;
public static final byte TYPE_VIDEO = 9;
public byte type;
public byte subType;
@ -162,6 +165,7 @@ public class VideoEditedInfo {
public float roundRadius;
public String segmentedPath = "";
public MediaController.CropState crop;
public float scale = 1.0f;
public float textViewWidth;
@ -270,6 +274,11 @@ public class VideoEditedInfo {
roundDuration = data.readInt64(exception);
} else if (type == TYPE_PHOTO) {
segmentedPath = data.readString(exception);
int magic = data.readInt32(exception);
if (magic == MediaController.CropState.constructor) {
crop = new MediaController.CropState();
crop.readParams(data, exception);
}
} else if (type == TYPE_WEATHER) {
int magic = data.readInt32(exception);
if (magic == 0x7EA7539) {
@ -341,6 +350,11 @@ public class VideoEditedInfo {
data.writeInt64(roundDuration);
} else if (type == TYPE_PHOTO) {
data.writeString(segmentedPath);
if (crop != null) {
crop.serializeToStream(data);
} else {
data.writeInt32(TLRPC.TL_null.constructor);
}
} else if (type == TYPE_WEATHER) {
if (weather == null) {
data.writeInt32(0xdeadbeef);
@ -776,7 +790,7 @@ public class VideoEditedInfo {
}
@Override
public void readParams(AbstractSerializedData stream, boolean exception) {
public void readParams(InputSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
isVideo = (flags & 1) != 0;
loop = (flags & 2) != 0;
@ -792,7 +806,7 @@ public class VideoEditedInfo {
}
@Override
public void serializeToStream(AbstractSerializedData stream) {
public void serializeToStream(OutputSerializedData stream) {
flags = isVideo ? flags | 1 : flags &~ 1;
flags = loop ? flags | 2 : flags &~ 2;
flags = muted ? flags | 4 : flags &~ 4;

View file

@ -34,6 +34,7 @@ import org.telegram.messenger.R;
import org.telegram.messenger.ShareBroadcastReceiver;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.support.customtabs.CustomTabsCallback;
import org.telegram.messenger.support.customtabs.CustomTabsClient;
import org.telegram.messenger.support.customtabs.CustomTabsIntent;
@ -44,11 +45,13 @@ import org.telegram.messenger.support.customtabsclient.shared.ServiceConnection;
import org.telegram.messenger.support.customtabsclient.shared.ServiceConnectionCallback;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_account;
import org.telegram.ui.ActionBar.ActionBarLayout;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheetTabs;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.BubbleActivity;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.web.RestrictedDomainsList;
@ -161,6 +164,13 @@ public class Browser {
openUrl(context, Uri.parse(url), true);
}
public static void openUrlInSystemBrowser(Context context, String url) {
if (url == null) {
return;
}
openUrl(context, Uri.parse(url), false, true, false, null, null, false, false, false);
}
public static void openUrl(Context context, Uri uri) {
openUrl(context, uri, true);
}
@ -223,7 +233,26 @@ public class Browser {
}
public static class Progress {
public void init() {}
private Runnable onInitListener;
private Runnable onCancelListener;
private Runnable onEndListener;
public Progress() {
}
public Progress(Runnable init, Runnable end) {
this.onInitListener = init;
this.onEndListener = end;
}
public void init() {
if (onInitListener != null) {
onInitListener.run();
onInitListener = null;
}
}
public void end() {
end(false);
}
@ -243,14 +272,14 @@ public class Browser {
end(replaced);
}
private Runnable onCancelListener;
public void onCancel(Runnable onCancelListener) {
public Progress onCancel(Runnable onCancelListener) {
this.onCancelListener = onCancelListener;
return this;
}
private Runnable onEndListener;
public void onEnd(Runnable onEndListener) {
public Progress onEnd(Runnable onEndListener) {
this.onEndListener = onEndListener;
return this;
}
}
@ -284,7 +313,7 @@ public class Browser {
};
Uri finalUri = uri;
TLRPC.TL_messages_getWebPagePreview req = new TLRPC.TL_messages_getWebPagePreview();
TL_account.getWebPagePreview req = new TL_account.getWebPagePreview();
req.message = uri.toString();
final int reqId = ConnectionsManager.getInstance(UserConfig.selectedAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (inCaseLoading != null) {
@ -297,11 +326,15 @@ public class Browser {
}
boolean ok = false;
if (response instanceof TLRPC.TL_messageMediaWebPage) {
TLRPC.TL_messageMediaWebPage webPage = (TLRPC.TL_messageMediaWebPage) response;
if (webPage.webpage instanceof TLRPC.TL_webPage && webPage.webpage.cached_page != null) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.openArticle, webPage.webpage, finalUri.toString());
ok = true;
if (response instanceof TL_account.webPagePreview) {
final TL_account.webPagePreview preview = (TL_account.webPagePreview) response;
MessagesController.getInstance(currentAccount).putUsers(preview.users, false);
if (preview.media instanceof TLRPC.TL_messageMediaWebPage) {
TLRPC.TL_messageMediaWebPage webPage = (TLRPC.TL_messageMediaWebPage) preview.media;
if (webPage.webpage instanceof TLRPC.TL_webPage && webPage.webpage.cached_page != null) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.openArticle, webPage.webpage, finalUri.toString());
ok = true;
}
}
}
if (!ok) {
@ -387,7 +420,7 @@ public class Browser {
}
try {
final boolean inappBrowser = (
allowInAppBrowser &&
allowInAppBrowser && BubbleActivity.instance == null &&
SharedConfig.inappBrowser &&
TextUtils.isEmpty(browserPackage) &&
!RestrictedDomainsList.getInstance().isRestricted(AndroidUtilities.getHostAuthority(uri, true)) &&
@ -819,7 +852,7 @@ public class Browser {
}
if (newPath != null) {
modifiedUriBuilder.append(newPath);
} else {
} else if (originalUri.getPath() != null) {
modifiedUriBuilder.append(originalUri.getPath());
}
if (originalUri.getQuery() != null) {

View file

@ -16,6 +16,7 @@ import android.hardware.Camera;
import android.media.CamcorderProfile;
import android.media.MediaRecorder;
import android.os.Build;
import android.text.TextUtils;
import android.util.Log;
import android.view.OrientationEventListener;
import android.view.Surface;
@ -160,11 +161,14 @@ public class CameraSession {
public void setTorchEnabled(boolean enabled) {
try {
String beforeFlashMode = currentFlashMode;
currentFlashMode = enabled ? Camera.Parameters.FLASH_MODE_TORCH : Camera.Parameters.FLASH_MODE_OFF;
if (isRound) {
configureRoundCamera(false);
} else {
configurePhotoCamera();