Skip to content

Commit

Permalink
Update to 7.4.0 (2223)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Jan 28, 2021
1 parent 77bbe5b commit eb94e31
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 61 deletions.
2 changes: 1 addition & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ android {
}
}

defaultConfig.versionCode = 2221
defaultConfig.versionCode = 2223

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BuildVars {
public static boolean LOGS_ENABLED = false;
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static int BUILD_VERSION = 2221;
public static int BUILD_VERSION = 2223;
public static String BUILD_VERSION_STRING = "7.4.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4628,14 +4628,15 @@ public void updateChatParticipants(final TLRPC.ChatParticipants participants) {
final TLRPC.ChatFull finalInfo = info;
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, finalInfo, 0, false));

SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_settings_v2 VALUES(?, ?, ?, ?, ?)");
SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_settings_v2 VALUES(?, ?, ?, ?, ?, ?)");
NativeByteBuffer data = new NativeByteBuffer(info.getObjectSize());
info.serializeToStream(data);
state.bindInteger(1, info.id);
state.bindByteBuffer(2, data);
state.bindInteger(3, info.pinned_msg_id);
state.bindInteger(4, info.online_count);
state.bindInteger(5, info.inviterId);
state.bindInteger(6, info.invitesCount);
state.step();
state.dispose();
data.reuse();
Expand Down Expand Up @@ -5180,14 +5181,15 @@ public void updateChatInfo(final int chat_id, final int user_id, final int what,
final TLRPC.ChatFull finalInfo = info;
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, finalInfo, 0, false));

SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_settings_v2 VALUES(?, ?, ?, ?, ?)");
SQLitePreparedStatement state = database.executeFast("REPLACE INTO chat_settings_v2 VALUES(?, ?, ?, ?, ?, ?)");
NativeByteBuffer data = new NativeByteBuffer(info.getObjectSize());
info.serializeToStream(data);
state.bindInteger(1, chat_id);
state.bindByteBuffer(2, data);
state.bindInteger(3, info.pinned_msg_id);
state.bindInteger(4, info.online_count);
state.bindInteger(5, info.inviterId);
state.bindInteger(6, info.invitesCount);
state.step();
state.dispose();
data.reuse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5470,6 +5470,9 @@ public void prepareImportHistory(long dialogId, Uri uri, ArrayList<Uri> mediaUri
}

String path = MediaController.copyFileToCache(mediaUri, "txt");
if (path == null) {
continue;
}
final File f = new File(path);
long size;
if (!f.exists() || (size = f.length()) == 0) {
Expand All @@ -5483,6 +5486,14 @@ public void prepareImportHistory(long dialogId, Uri uri, ArrayList<Uri> mediaUri
}
importingHistory.totalSize += size;
if (a == 0) {
if (size > 32 * 1024 * 1024) {
f.delete();
AndroidUtilities.runOnUIThread(() -> {
Toast.makeText(ApplicationLoader.applicationContext, LocaleController.getString("ImportFileTooLarge", R.string.ImportFileTooLarge), Toast.LENGTH_SHORT).show();
onStartImport.run(0);
});
return;
}
importingHistory.historyPath = path;
} else {
importingHistory.uploadMedia.add(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,9 @@ protected void dispatchDraw(Canvas canvas) {
@Override
public void invalidate() {
super.invalidate();
fragmentView.invalidate();
if (fragmentView != null) {
fragmentView.invalidate();
}
}
};
listView.setLayoutManager(layoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
}
VoIPHelper.startCall(chatActivity.getMessagesController().getChat(call.chatId), false, fragment.getParentActivity());
} else if (currentStyle == 5) {
SendMessagesHelper.ImportingHistory importingHistory = parentFragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) parentFragment).getDialogId());
if (importingHistory == null) {
return;
}
ImportingAlert importingAlert = new ImportingAlert(getContext(), (ChatActivity) fragment);
importingAlert.setOnHideListener(dialog -> checkImport(false));
fragment.showDialog(importingAlert);
Expand Down Expand Up @@ -610,7 +614,7 @@ private void checkVisibility() {
show = true;
} else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) {
show = true;
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing() && !isPlayingVoice()) {
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().call.participants_count > 0 && !GroupCallPip.isShowing() && !isPlayingVoice()) {
show = true;
} else {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
Expand Down Expand Up @@ -881,7 +885,7 @@ protected void onAttachedToWindow() {
checkCall(true);
} else if (fragment instanceof ChatActivity && fragment.getSendMessagesHelper().getImportingHistory(((ChatActivity) fragment).getDialogId()) != null && !isPlayingVoice()) {
checkImport(true);
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing() && !isPlayingVoice()) {
} else if (fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && ((ChatActivity) fragment).getGroupCall().call.participants_count > 0 && !GroupCallPip.isShowing() && !isPlayingVoice()) {
checkCall(true);
} else {
checkPlayer(true);
Expand Down Expand Up @@ -1220,8 +1224,9 @@ private void checkPlayer(boolean create) {
if (messageObject == null || messageObject.getId() == 0 || messageObject.isVideo()) {
lastMessageObject = null;
boolean callAvailable = supportsCalls && VoIPService.getSharedInstance() != null && !VoIPService.getSharedInstance().isHangingUp() && VoIPService.getSharedInstance().getCallState() != VoIPService.STATE_WAITING_INCOMING && !GroupCallPip.isShowing();
if (!isPlayingVoice() && !callAvailable && fragment instanceof ChatActivity && ((ChatActivity) fragment).getGroupCall() != null && !GroupCallPip.isShowing()) {
callAvailable = true;
if (!isPlayingVoice() && !callAvailable && fragment instanceof ChatActivity && !GroupCallPip.isShowing()) {
ChatObject.Call call = ((ChatActivity) fragment).getGroupCall();
callAvailable = call != null && call.call.participants_count > 0;
}
if (callAvailable) {
checkCall(false);
Expand Down Expand Up @@ -1600,7 +1605,7 @@ public void onAnimationEnd(Animator animation) {
});
animatorSet.start();
}
} else if (currentStyle == -1 || currentStyle == 4 || currentStyle == 3 || currentStyle == 1) {
} else if (visible && (currentStyle == -1 || currentStyle == 4 || currentStyle == 3 || currentStyle == 1)) {
visible = false;
setVisibility(GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -64,6 +65,8 @@ public class LinkActionView extends LinearLayout {
private QRCodeBottomSheet qrCodeBottomSheet;
private boolean isPublic;

float[] point = new float[2];

public LinkActionView(Context context, BaseFragment fragment, BottomSheet bottomSheet, int chatId, boolean permanent) {
super(context);
this.fragment = fragment;
Expand Down Expand Up @@ -227,41 +230,29 @@ public LinkActionView(Context context, BaseFragment fragment, BottomSheet bottom
layout.addView(subItem, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));

FrameLayout container;
float y = 0;
if (bottomSheet == null) {
container = fragment.getParentLayout();
} else {
container = bottomSheet.getContainer();
}

View v = frameLayout;
while (v != container) {
y += v.getY();
v = (View) v.getParent();
if (!(v instanceof ViewGroup)) {
return;
}
}


if (container != null) {
FrameLayout finalContainer = container;
float x = 0;
float y;
getPointOnScreen(frameLayout, container, point);
y = point[1];

final FrameLayout finalContainer = container;
View dimView = new View(context) {

@Override
protected void onDraw(Canvas canvas) {
canvas.drawColor(0x33000000);
float x = 0;
float y = 0;
View v = frameLayout;
while (v != finalContainer) {
y += v.getY();
x += v.getX();
v = (View) v.getParent();
if (!(v instanceof ViewGroup)) {
return;
}
}
getPointOnScreen(frameLayout, finalContainer, point);
canvas.save();
canvas.translate(x, y);
canvas.translate(point[0], point[1]);
frameLayout.draw(canvas);
canvas.restore();
}
Expand Down Expand Up @@ -302,7 +293,11 @@ public void onAnimationEnd(Animator animation) {
}
});

actionBarPopupWindow.showAtLocation(container, 0, (int) container.getMeasuredWidth() - layout.getMeasuredWidth() - AndroidUtilities.dp(16), (int) y + frameLayout.getMeasuredHeight());
if (AndroidUtilities.isTablet()) {
y += container.getPaddingTop();
x -= container.getPaddingLeft();
}
actionBarPopupWindow.showAtLocation(container, 0, (int) (container.getMeasuredWidth() - layout.getMeasuredWidth() - AndroidUtilities.dp(16) + container.getX() + x), (int) (y + frameLayout.getMeasuredHeight() + container.getY()));
}

});
Expand All @@ -316,6 +311,27 @@ public void onClick(View view) {
updateColors();
}

private void getPointOnScreen(FrameLayout frameLayout, FrameLayout finalContainer, float[] point) {
float x = 0;
float y = 0;
View v = frameLayout;
while (v != finalContainer) {
y += v.getY();
x += v.getX();
if (v instanceof ScrollView) {
y -= v.getScrollY();
}
v = (View) v.getParent();
if (!(v instanceof ViewGroup)) {
return;
}
}
x -= finalContainer.getPaddingLeft();
y -= finalContainer.getPaddingTop();
point[0] = x;
point[1] = y;
}

private void showQrCode() {
qrCodeBottomSheet = new QRCodeBottomSheet(getContext(), link) {
@Override
Expand Down
22 changes: 19 additions & 3 deletions TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2409,10 +2409,11 @@ private void runImportRequest(final Uri importUri,
Runnable cancelRunnable = null;

String content;
InputStream inputStream = null;
try {
int linesCount = 0;
InputStream in = getContentResolver().openInputStream(importUri);
BufferedReader r = new BufferedReader(new InputStreamReader(in));
inputStream = getContentResolver().openInputStream(importUri);
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder total = new StringBuilder();
for (String line; (line = r.readLine()) != null && linesCount < 100; ) {
total.append(line).append('\n');
Expand All @@ -2422,6 +2423,14 @@ private void runImportRequest(final Uri importUri,
} catch (Exception e) {
FileLog.e(e);
return;
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e2) {
FileLog.e(e2);
}
}
final TLRPC.TL_messages_checkHistoryImport req = new TLRPC.TL_messages_checkHistoryImport();
req.import_head = content;
Expand Down Expand Up @@ -3388,6 +3397,8 @@ public void didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<Long> di
final int account = dialogsFragment != null ? dialogsFragment.getCurrentAccount() : currentAccount;

if (exportingChatUri != null) {
Uri uri = exportingChatUri;
ArrayList<Uri> documentsUris = documentsUrisArray != null ? new ArrayList<>(documentsUrisArray) : null;
final AlertDialog progressDialog = new AlertDialog(this, 3);
SendMessagesHelper.getInstance(account).prepareImportHistory(dids.get(0), exportingChatUri, documentsUrisArray, (result) -> {
if (result != 0) {
Expand All @@ -3405,7 +3416,12 @@ public void didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<Long> di
fragment.setOpenImport();
actionBarLayout.presentFragment(fragment, dialogsFragment != null || param, dialogsFragment == null, true, false);
} else {
dialogsFragment.finishFragment();
documentsUrisArray = documentsUris;
if (documentsUrisArray == null) {
documentsUrisArray = new ArrayList<>();
}
documentsUrisArray.add(0, uri);
openDialogsToSend(true);
}
try {
progressDialog.dismiss();
Expand Down
Loading

0 comments on commit eb94e31

Please sign in to comment.