Skip to content

Commit

Permalink
update to 9.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix authored and 030 committed Nov 22, 2023
1 parent 1cde88c commit b10c996
Show file tree
Hide file tree
Showing 300 changed files with 17,458 additions and 5,082 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
path = TMessagesProj/jni/ffmpeg
url = https://github.com/FFmpeg/FFmpeg
ignore = dirty
branch = n4.4.3
[submodule "TMessagesProj/jni/boringssl"]
path = TMessagesProj/jni/boringssl
url = https://github.com/google/boringssl
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ target_include_directories(breakpad PUBLIC
#voip
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)

set(NATIVE_LIB "tmessages.44")
set(NATIVE_LIB "tmessages.45")

#tmessages
add_library(${NATIVE_LIB} SHARED
Expand Down
49 changes: 47 additions & 2 deletions TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static const std::string av_make_error_str(int errnum) {
jclass jclass_AnimatedFileDrawableStream;
jmethodID jclass_AnimatedFileDrawableStream_read;
jmethodID jclass_AnimatedFileDrawableStream_cancel;
jmethodID jclass_AnimatedFileDrawableStream_isCanceled;
jmethodID jclass_AnimatedFileDrawableStream_isFinishedLoadingFile;
jmethodID jclass_AnimatedFileDrawableStream_getFinishedFilePath;

Expand Down Expand Up @@ -792,7 +793,7 @@ int readCallback(void *opaque, uint8_t *buf, int buf_size) {
javaVm->DetachCurrentThread();
}
if (buf_size == 0) {
return AVERROR_EOF;
return AVERROR_EXIT;
}
int ret = (int) read(info->fd, buf, (size_t) buf_size);
if (ret <= 0) {
Expand Down Expand Up @@ -1102,7 +1103,7 @@ extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
return;
}
int got_frame = 0;
int32_t tries = 1000;
int32_t tries = 100;
while (tries > 0) {
if (info->pkt.size == 0) {
ret = av_read_frame(info->fmt_ctx, &info->pkt);
Expand Down Expand Up @@ -1235,6 +1236,26 @@ extern "C" JNIEXPORT int JNICALL Java_org_telegram_ui_Components_AnimatedFileDra
int32_t tries = 1000;
bool readNextPacket = true;
while (tries > 0) {
if (info->stream != nullptr) {
JNIEnv *jniEnv = nullptr;
JavaVMAttachArgs jvmArgs;
jvmArgs.version = JNI_VERSION_1_6;

bool attached;
if (JNI_EDETACHED == javaVm->GetEnv((void **) &jniEnv, JNI_VERSION_1_6)) {
javaVm->AttachCurrentThread(&jniEnv, &jvmArgs);
attached = true;
} else {
attached = false;
}
jboolean canceled = jniEnv->CallBooleanMethod(info->stream, jclass_AnimatedFileDrawableStream_isCanceled);
if (attached) {
javaVm->DetachCurrentThread();
}
if (canceled) {
return 0;
}
}
if (info->pkt.size == 0 && readNextPacket) {
ret = av_read_frame(info->fmt_ctx, &info->pkt);
if (ret >= 0) {
Expand Down Expand Up @@ -1309,6 +1330,26 @@ extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
int32_t triesCount = preview ? 50 : 6;
//info->has_decoded_frames = false;
while (!info->stopped && triesCount != 0) {
if (info->stream != nullptr) {
JNIEnv *jniEnv = nullptr;
JavaVMAttachArgs jvmArgs;
jvmArgs.version = JNI_VERSION_1_6;

bool attached;
if (JNI_EDETACHED == javaVm->GetEnv((void **) &jniEnv, JNI_VERSION_1_6)) {
javaVm->AttachCurrentThread(&jniEnv, &jvmArgs);
attached = true;
} else {
attached = false;
}
jboolean canceled = jniEnv->CallBooleanMethod(info->stream, jclass_AnimatedFileDrawableStream_isCanceled);
if (attached) {
javaVm->DetachCurrentThread();
}
if (canceled) {
return 0;
}
}
if (info->pkt.size == 0) {
ret = av_read_frame(info->fmt_ctx, &info->pkt);
if (ret >= 0) {
Expand Down Expand Up @@ -1400,6 +1441,10 @@ extern "C" jint videoOnJNILoad(JavaVM *vm, JNIEnv *env) {
if (jclass_AnimatedFileDrawableStream_isFinishedLoadingFile == 0) {
return JNI_FALSE;
}
jclass_AnimatedFileDrawableStream_isCanceled = env->GetMethodID(jclass_AnimatedFileDrawableStream, "isCanceled", "()Z");
if (jclass_AnimatedFileDrawableStream_isCanceled == 0) {
return JNI_FALSE;
}
jclass_AnimatedFileDrawableStream_getFinishedFilePath = env->GetMethodID(jclass_AnimatedFileDrawableStream, "getFinishedFilePath", "()Ljava/lang/String;");
if (jclass_AnimatedFileDrawableStream_getFinishedFilePath == 0) {
return JNI_FALSE;
Expand Down
6 changes: 6 additions & 0 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,12 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
request->serverFailureCount++;
}
discardResponse = true;
} else if (error->error_code == -504) {
discardResponse = (request->requestFlags & RequestFlagIgnoreFloodWait) == 0;
request->failedByFloodWait = 2;
request->startTime = 0;
request->startTimeMillis = 0;
request->minStartTime = (int32_t) (getCurrentTimeMonotonicMillis() / 1000 + 2);
} else if (error->error_code == 420) {
int32_t waitTime = 2;
static std::string floodWait = "FLOOD_WAIT_";
Expand Down
3 changes: 1 addition & 2 deletions TMessagesProj/src/main/assets/arctic.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ avatar_actionBarSelectorGreen=-8684677
chat_inLoaderSelected=-13394195
chat_outLocationIcon=-452984833
avatar_actionBarIconViolet=-8684677
dialogTextRed=-1682082
text_RedBold=-1682082
chat_inBubbleShadow=1981626195
chat_outAudioProgress=-10907938
dialogProgressCircle=-12281108
Expand Down Expand Up @@ -308,7 +308,6 @@ chat_outMenu=-1862270977
statisticChartActiveLine=335544320
chats_secretName=-16734706
chat_outReplyMediaMessageSelectedText=-1056964609
chat_reportSpam=-704436
avatar_subtitleInProfileCyan=-16777216
chat_serviceText=-1
chats_attachMessage=-13268780
Expand Down
7 changes: 2 additions & 5 deletions TMessagesProj/src/main/assets/darkblue.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ avatar_actionBarSelectorGreen=-12758164
chat_outLocationIcon=-1
chat_inLoaderSelected=-10445358
location_liveLocationProgress=-9919529
dialogTextRed=-1152913
text_RedBold=-1152913
chat_inBubbleShadow=838860800
chat_outAudioProgress=-1
dialogProgressCircle=-10177041
Expand All @@ -132,9 +132,8 @@ dialogLineProgressBackground=-13548718
chat_inReplyNameText=-8796932
chat_outAudioPerfomerSelectedText=-4268038
actionBarActionModeDefaultIcon=-1
windowBackgroundWhiteRedText4=-3187617
chat_goDownButtonIcon=-1
windowBackgroundWhiteRedText5=-1152913
text_RedRegular=-1152913
chat_outAudioSelectedProgress=-1
chat_messageTextOut=-328966
chat_inInstant=-8796932
Expand Down Expand Up @@ -446,9 +445,7 @@ chats_secretName=-9316522
chat_inMenu=2039722445
chat_recordVoiceCancel=-9192978
chat_outReplyMediaMessageSelectedText=-1
chat_reportSpam=-1481631
chat_messageTextIn=-328966
dialogRedIcon=-554801041
avatar_subtitleInProfileCyan=-7628894
chats_attachMessage=-8548712
chat_topPanelBackground=-14602949
Expand Down
3 changes: 1 addition & 2 deletions TMessagesProj/src/main/assets/day.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ avatar_actionBarSelectorGreen=-8684677
chat_inLoaderSelected=-13394195
chat_outLocationIcon=-452984833
avatar_actionBarIconViolet=-8684677
dialogTextRed=-1682082
text_RedBold=-1682082
chat_inBubbleShadow=1914707
chat_outAudioProgress=-12155183
dialogProgressCircle=-12281108
Expand Down Expand Up @@ -334,7 +334,6 @@ chat_outMenu=-6500865
statisticChartActiveLine=335544320
chats_secretName=-16734706
chat_outReplyMediaMessageSelectedText=-3676417
chat_reportSpam=-704436
avatar_subtitleInProfileCyan=-16777216
chat_serviceText=-13092808
chats_attachMessage=-14321214
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions TMessagesProj/src/main/assets/night.attheme
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,11 @@ listSelector=771751936
chat_outPreviewInstantText=-1
chat_inMenuSelected=-1517440301
avatar_backgroundOrange=-869276
avatar_background2Orange=-1734333
avatar_actionBarSelectorGreen=-12758164
chat_outLocationIcon=-1
chat_inLoaderSelected=-11297295
location_liveLocationProgress=-9919529
dialogTextRed=-1152913
text_RedBold=-1152913
chat_inBubbleShadow=838860800
chat_outAudioProgress=-1
dialogProgressCircle=-10177041
Expand All @@ -136,9 +135,8 @@ dialogLineProgressBackground=-12303292
chat_inReplyNameText=-8796932
chat_outAudioPerfomerSelectedText=-7023626
actionBarActionModeDefaultIcon=-1
windowBackgroundWhiteRedText4=-3187617
chat_goDownButtonIcon=-1
windowBackgroundWhiteRedText5=-1152913
text_RedRegular=-1152913
chats_onlineCircle=-13130503
chat_outAudioSelectedProgress=-1
chat_messageTextOut=-328966
Expand Down Expand Up @@ -185,7 +183,6 @@ calls_callReceivedGreenIcon=-12001930
chats_pinnedOverlay=201326591
windowBackgroundWhiteInputField=-11513776
avatar_backgroundRed=-2326437
avatar_background2Red=-2863816
chat_emojiPanelBadgeBackground=-11291403
chat_inForwardedNameText=-8930052
chats_actionBackground=-10575653
Expand Down Expand Up @@ -473,9 +470,7 @@ chats_secretName=-9316522
chat_inMenu=-10656924
chat_recordVoiceCancel=-10638868
chat_outReplyMediaMessageSelectedText=-7023626
chat_reportSpam=-1481631
chat_messageTextIn=-328966
dialogRedIcon=-554801041
avatar_subtitleInProfileCyan=-7628894
chats_attachMessage=-8224126
chat_topPanelBackground=-15066597
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.ChatBackgroundDrawable;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.BackgroundGradientDrawable;
import org.telegram.ui.Components.Bulletin;
Expand Down Expand Up @@ -227,6 +228,7 @@ public class AndroidUtilities {
public static float density = 1;
public static Point displaySize = new Point();
public static float screenRefreshRate = 60;
public static float screenRefreshTime = 1000 / screenRefreshRate;
public static int roundMessageSize;
public static int roundPlayingMessageSize;
public static int roundMessageInset;
Expand Down Expand Up @@ -855,6 +857,10 @@ public static int calcBitmapColor(Bitmap bitmap) {
}

public static int[] calcDrawableColor(Drawable drawable) {
if (drawable instanceof ChatBackgroundDrawable) {
ChatBackgroundDrawable chatBackgroundDrawable = (ChatBackgroundDrawable) drawable;
return calcDrawableColor(chatBackgroundDrawable.getDrawable());
}
int bitmapColor = 0xff000000;
int[] result = new int[4];
try {
Expand Down Expand Up @@ -2023,6 +2029,7 @@ public static void checkDisplaySize(Context context, Configuration newConfigurat
display.getMetrics(displayMetrics);
display.getSize(displaySize);
screenRefreshRate = display.getRefreshRate();
screenRefreshTime = 1000 / screenRefreshRate;
}
}
if (configuration.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
Expand Down Expand Up @@ -3749,15 +3756,15 @@ protected void onDetachedFromWindow() {
ConnectionsManager.getInstance(UserConfig.selectedAccount).checkProxy(address, Integer.parseInt(port), user, password, secret, time -> AndroidUtilities.runOnUIThread(() -> {
if (time == -1) {
cell.getTextView().setText(LocaleController.getString(R.string.Unavailable));
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
cell.getTextView().setTextColor(Theme.getColor(Theme.key_text_RedRegular));
} else {
cell.getTextView().setText(LocaleController.getString(R.string.Available) + ", " + LocaleController.formatString(R.string.Ping, time));
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGreenText));
}
}));
} catch (NumberFormatException ignored) {
cell.getTextView().setText(LocaleController.getString(R.string.Unavailable));
cell.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText4));
cell.getTextView().setTextColor(Theme.getColor(Theme.key_text_RedRegular));
}
}
}
Expand Down Expand Up @@ -4534,6 +4541,9 @@ public static void setNavigationBarColor(Window window, int color, boolean anima
}

public static void setNavigationBarColor(Window window, int color, boolean animated, IntColorCallback onUpdate) {
if (window == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (navigationBarColorAnimators != null) {
ValueAnimator animator = navigationBarColorAnimators.get(window);
Expand Down Expand Up @@ -4703,10 +4713,14 @@ public static void updateImageViewImageAnimated(ImageView imageView, Drawable ne
}

public static void updateViewVisibilityAnimated(View view, boolean show) {
updateViewVisibilityAnimated(view, show, 1f, true);
updateViewVisibilityAnimated(view, show, 1f, true, true);
}

public static void updateViewVisibilityAnimated(View view, boolean show, float scaleFactor, boolean animated) {
updateViewVisibilityAnimated(view, show, scaleFactor, true, animated);
}

public static void updateViewVisibilityAnimated(View view, boolean show, float scaleFactor, boolean goneOnHide, boolean animated) {
if (view == null) {
return;
}
Expand All @@ -4716,7 +4730,7 @@ public static void updateViewVisibilityAnimated(View view, boolean show, float s

if (!animated) {
view.animate().setListener(null).cancel();
view.setVisibility(show ? View.VISIBLE : View.GONE);
view.setVisibility(show ? View.VISIBLE : (goneOnHide ? View.GONE : View.INVISIBLE));
view.setTag(show ? 1 : null);
view.setAlpha(1f);
view.setScaleX(1f);
Expand All @@ -4733,7 +4747,7 @@ public static void updateViewVisibilityAnimated(View view, boolean show, float s
view.setTag(1);
} else if (!show && view.getTag() != null) {
view.animate().setListener(null).cancel();
view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new HideViewAfterAnimation(view)).setDuration(150).start();
view.animate().alpha(0).scaleY(scaleFactor).scaleX(scaleFactor).setListener(new HideViewAfterAnimation(view, goneOnHide)).setDuration(150).start();
view.setTag(null);
}
}
Expand Down Expand Up @@ -5185,4 +5199,16 @@ public static Long getSysInfoLong(String path) {
}
return null;
}

public static boolean isActivityRunning(Activity activity) {
if (activity == null) {
return false;
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return !activity.isDestroyed() && !activity.isFinishing();
} else {
return !activity.isFinishing();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public int read(int offset, int readLength) {
synchronized (sync) {
if (canceled) {
debugCanceledCount++;
if (!debugReportSend && debugCanceledCount > 100) {
if (!debugReportSend && debugCanceledCount > 200) {
debugReportSend = true;
if (BuildVars.DEBUG_PRIVATE_VERSION) {
throw new RuntimeException("infinity stream reading!!!");
Expand Down Expand Up @@ -167,4 +167,8 @@ public void newDataAvailable() {
countDownLatch.countDown();
}
}

public boolean isCanceled() {
return canceled;
}
}
Loading

0 comments on commit b10c996

Please sign in to comment.