Skip to content

Commit 4277c47

Browse files
committed
Upgrade TDLib to tdlib/td@b102c3a
1 parent d45ec2f commit 4277c47

31 files changed

Lines changed: 423 additions & 151 deletions

‎.gitattributes‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
app/jniLibs/*/*.so filter=lfs diff=lfs merge=lfs -text
22
*.zip -delta
3+
* text=auto

‎app/build.gradle.kts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ dependencies {
380380
implementation("androidx.activity:activity:1.8.2") // 1.9.0+ requires minSdkVersion 19
381381
implementation("androidx.palette:palette:1.0.0")
382382
implementation("androidx.recyclerview:recyclerview:1.3.2")
383+
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
383384
implementation("androidx.viewpager:viewpager:1.0.0")
384385
implementation("androidx.work:work-runtime:2.9.0")
385386
implementation("androidx.browser:browser:1.5.0") // 1.7.0+ requires minSdkVersion 19
@@ -398,13 +399,16 @@ dependencies {
398399
implementation("com.google.android.gms:play-services-maps:17.0.1")
399400
implementation("com.google.android.gms:play-services-location:18.0.0")
400401
implementation("com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.1")
402+
implementation("com.google.android.gms:play-services-safetynet:18.0.1")
401403
// Firebase: https://firebase.google.com/support/release-notes/android
402404
implementation("com.google.firebase:firebase-messaging:22.0.0") {
403405
exclude(group = "com.google.firebase", module = "firebase-core")
404406
exclude(group = "com.google.firebase", module = "firebase-analytics")
405407
exclude(group = "com.google.firebase", module = "firebase-measurement-connector")
406408
}
407-
implementation("com.google.firebase:firebase-appcheck-safetynet:16.1.2")
409+
// implementation("com.google.firebase:firebase-appcheck-safetynet:16.1.2")
410+
// Play Integrity: https://developer.android.com/google/play/integrity/reference/com/google/android/play/core/release-notes
411+
implementation("com.google.android.play:integrity:1.3.0")
408412
// Play In-App Updates: https://developer.android.com/reference/com/google/android/play/core/release-notes-in_app_updates
409413
implementation("com.google.android.play:app-update:2.1.0")
410414
// AndroidX/media: https://github.com/androidx/media/blob/release/RELEASENOTES.md

‎app/src/main/java/org/thunderdog/challegram/Log.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,21 @@ public static RuntimeException generateException (int skipCount) {
983983
}
984984
}
985985

986+
public static String toErrorString (Throwable e) {
987+
988+
if (e == null) return "NULL";
989+
String str = "";
990+
if (e.getClass() != null && e.getClass().getSimpleName() != null) {
991+
str = e.getClass().getSimpleName();
992+
if (str == null) str = "";
993+
}
994+
if (e.getMessage() != null) {
995+
if (str.length() > 0) str += ": ";
996+
str += e.getMessage();
997+
}
998+
return str;
999+
}
1000+
9861001
public static String toString (Throwable t) {
9871002
StringBuilder b = new StringBuilder();
9881003
toStringBuilder(t, 10, b);

‎app/src/main/java/org/thunderdog/challegram/TDLib.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ public static void safetyNet (String format, Object... formatArgs) {
9292
i("[safetynet]: %s", format(format, formatArgs));
9393
}
9494

95+
public static void playIntegrity (String format, Object... formatArgs) {
96+
i("[play-integrity]: %s", format(format, formatArgs));
97+
}
98+
99+
public static void integrity (boolean isPlay, String format, Object... formatArgs) {
100+
if (isPlay) {
101+
playIntegrity(format, formatArgs);
102+
} else {
103+
safetyNet(format, formatArgs);
104+
}
105+
}
106+
95107
public static void td_init (String format, Object... formatArgs) {
96108
logModule("td_init", format, formatArgs);
97109
}

‎app/src/main/java/org/thunderdog/challegram/component/attach/MediaBottomGalleryController.java‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ public boolean allowSpoiler () {
248248
return !ChatId.isSecret(getOutputChatId());
249249
}
250250

251+
@Override
252+
public boolean allowShowCaptionAboveMedia () {
253+
return !ChatId.isSecret(getOutputChatId());
254+
}
255+
251256
@Override
252257
protected void onUpdateBottomBarFactor (float bottomBarFactor, float counterFactor, float y) {
253258
float factor = Math.min(bottomBarFactor, 1f - counterFactor);
@@ -541,7 +546,7 @@ public boolean canSendAsFile () {
541546
}
542547

543548
@Override
544-
public boolean sendSelectedItems (View view, ArrayList<ImageFile> images, TdApi.MessageSendOptions options, boolean disableMarkdown, boolean asFiles, boolean hasSpoiler) {
549+
public boolean sendSelectedItems (View view, ArrayList<ImageFile> images, TdApi.MessageSendOptions options, boolean disableMarkdown, boolean asFiles, boolean showCaptionAboveMedia, boolean hasSpoiler) {
545550
// TODO delete other
546551
return mediaLayout.sendPhotosOrVideos(view, images, false, options, disableMarkdown, asFiles, true);
547552
}
@@ -561,6 +566,16 @@ public void onHideMediaStateChanged (boolean hideMedia) {
561566
mediaLayout.setNeedSpoiler(hideMedia);
562567
}
563568

569+
@Override
570+
public boolean showCaptionAboveMedia () {
571+
return mediaLayout.showCaptionAboveMedia();
572+
}
573+
574+
@Override
575+
public void onShowCaptionAboveMediaStateChanged (boolean showCaptionAboveMedia) {
576+
mediaLayout.setShowCaptionAboveMedia(showCaptionAboveMedia);
577+
}
578+
564579
@Override
565580
protected void onCancelMultiSelection () {
566581
adapter.clearSelectedImages((GridLayoutManager) getLayoutManager());

‎app/src/main/java/org/thunderdog/challegram/component/attach/MediaLayout.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,9 @@ public boolean sendPhotosOrVideos (View view, ArrayList<ImageFile> images, boole
12941294
ImageGalleryFile[] result = new ImageGalleryFile[galleryFiles.size()];
12951295
galleryFiles.toArray(result);
12961296
Settings.instance().setNeedGroupMedia(needGroupMedia);
1297-
target.sendPhotosAndVideosCompressed(result, needGroupMedia, options, disableMarkdown, asFiles, allowSpoiler && needSpoiler);
1297+
boolean showCaptionAboveMedia = false;
1298+
boolean hasSpoiler = allowSpoiler && needSpoiler;
1299+
target.sendPhotosAndVideosCompressed(result, needGroupMedia, options, disableMarkdown, asFiles, showCaptionAboveMedia, hasSpoiler);
12981300
}
12991301
}
13001302

@@ -1609,6 +1611,14 @@ public void setNeedSpoiler (boolean needSpoiler) {
16091611
}
16101612
}
16111613

1614+
public boolean showCaptionAboveMedia () {
1615+
return false; // TODO
1616+
}
1617+
1618+
public void setShowCaptionAboveMedia (boolean showCaptionAboveMedia) {
1619+
// TODO
1620+
}
1621+
16121622
private @Nullable TdApi.Chat getTargetChat () {
16131623
MessagesController c = getTarget();
16141624
TdApi.Chat chat = null;

‎app/src/main/java/org/thunderdog/challegram/component/chat/InputView.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,13 +1459,13 @@ protected InputConnection createInputConnection (EditorInfo editorInfo) {
14591459
final boolean isSecretChat = ChatId.isSecret(chatId);
14601460
if (mediaType == MediaType.GIF && isAnimatedGif) {
14611461
TdApi.InputFileGenerated generated = TD.newGeneratedFile(null, path, 0, timestamp);
1462-
content = tdlib.filegen().createThumbnail(new TdApi.InputMessageAnimation(generated, null, null, 0, imageWidth, imageHeight, null, false), isSecretChat);
1462+
content = tdlib.filegen().createThumbnail(new TdApi.InputMessageAnimation(generated, null, null, 0, imageWidth, imageHeight, null, false, false), isSecretChat);
14631463
} else if ((mediaType != MediaType.JPEG && (mediaType == MediaType.WEBP || path.contains("sticker") || Math.max(imageWidth, imageHeight) <= 512))) {
14641464
TdApi.InputFileGenerated generated = PhotoGenerationInfo.newFile(path, 0, timestamp, true, 512);
14651465
content = tdlib.filegen().createThumbnail(new TdApi.InputMessageSticker(generated, null, imageWidth, imageHeight, null), isSecretChat);
14661466
} else {
14671467
TdApi.InputFileGenerated generated = PhotoGenerationInfo.newFile(path, 0, timestamp, false, 0);
1468-
content = tdlib.filegen().createThumbnail(new TdApi.InputMessagePhoto(generated, null, null, imageWidth, imageHeight, null, null, false), isSecretChat);
1468+
content = tdlib.filegen().createThumbnail(new TdApi.InputMessagePhoto(generated, null, null, imageWidth, imageHeight, null, false, null, false), isSecretChat);
14691469
}
14701470

14711471
UI.post(() -> {

‎app/src/main/java/org/thunderdog/challegram/component/chat/MessagesLoader.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ private static boolean parsePreviewMessages (TdlibDelegate context, List<TdApi.M
966966

967967
TdApi.MessageContent content;
968968
if (photo != null)
969-
content = new TdApi.MessagePhoto(photo, text, false, false);
969+
content = new TdApi.MessagePhoto(photo, text, false, false, false);
970970
else if (sticker != null)
971971
content = new TdApi.MessageSticker(sticker, false);
972972
else if (audio != null)
@@ -1224,10 +1224,10 @@ private TdApi.Message newMessage (final long chatId, final boolean isChannel, fi
12241224
false,
12251225
event.date, 0,
12261226
null, null, null, null,
1227-
null, 0, 0,
1227+
null, null, 0, 0,
12281228
null, 0, 0,
12291229
0, 0, 0, null,
1230-
0,
1230+
0, 0,
12311231
null,
12321232
null,
12331233
null

0 commit comments

Comments
 (0)