diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 357507c26..935186593 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -290,7 +290,7 @@ android { } } - defaultConfig.versionCode = 2223 + defaultConfig.versionCode = 2225 applicationVariants.all { variant -> variant.outputs.all { output -> @@ -309,7 +309,7 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 29 - versionName "7.4.0" + versionName "7.4.1" vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index a9119e477..fb39b800e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -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 = 2223; + public static int BUILD_VERSION = 2225; public static String BUILD_VERSION_STRING = "7.4.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index dde8e7923..186807f02 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -4050,24 +4050,32 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } public static String getFileName(Uri uri) { - String result = null; - if (uri.getScheme().equals("content")) { - try (Cursor cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) { - if (cursor.moveToFirst()) { - result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + if (uri == null) { + return ""; + } + try { + String result = null; + if (uri.getScheme().equals("content")) { + try (Cursor cursor = ApplicationLoader.applicationContext.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) { + if (cursor.moveToFirst()) { + result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + } + } catch (Exception e) { + FileLog.e(e); } - } catch (Exception e) { - FileLog.e(e); } - } - if (result == null) { - result = uri.getPath(); - int cut = result.lastIndexOf('/'); - if (cut != -1) { - result = result.substring(cut + 1); + if (result == null) { + result = uri.getPath(); + int cut = result.lastIndexOf('/'); + if (cut != -1) { + result = result.substring(cut + 1); + } } + return result; + } catch (Exception e) { + FileLog.e(e); } - return result; + return ""; } @SuppressLint("DiscouragedPrivateApi") diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index ecb39d483..554b7689f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -730,12 +730,15 @@ public class MessagesController extends BaseController implements NotificationCe pendingSuggestions = new HashSet<>(); } - exportUri = mainPreferences.getStringSet("exportUri", null); + exportUri = mainPreferences.getStringSet("exportUri2", null); if (exportUri != null) { exportUri = new HashSet<>(exportUri); } else { exportUri = new HashSet<>(); - exportUri.add("content://com.whatsapp.provider.media/export_chat/"); + exportUri.add("content://(\\d+@)?com\\.whatsapp\\.provider\\.media/export_chat/"); + exportUri.add("content://(\\d+@)?com\\.whatsapp\\.w4b\\.provider\\.media/export_chat/"); + exportUri.add("content://jp\\.naver\\.line\\.android\\.line\\.common\\.FileProvider/export-chat/"); + exportUri.add(".*WhatsApp.*\\.txt$"); } exportGroupUri = mainPreferences.getStringSet("exportGroupUri", null); @@ -1493,7 +1496,7 @@ public class MessagesController extends BaseController implements NotificationCe } break; } - case "export_urls": { + case "export_regex": { HashSet newExport = new HashSet<>(); if (value.value instanceof TLRPC.TL_jsonArray) { TLRPC.TL_jsonArray array = (TLRPC.TL_jsonArray) value.value; @@ -1507,7 +1510,7 @@ public class MessagesController extends BaseController implements NotificationCe } if (!exportUri.equals(newExport)) { exportUri = newExport; - editor.putStringSet("exportUri", exportUri); + editor.putStringSet("exportUri2", exportUri); changed = true; } break; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index e0920d0c0..0ca3a24d2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -676,7 +676,7 @@ public class NotificationsController extends BaseController { for (int a = 0; a < messageObjects.size(); a++) { MessageObject messageObject = messageObjects.get(a); - if (messageObject.messageOwner != null && messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined)) { + if (messageObject.messageOwner != null && (messageObject.isImportedForward() || messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined))) { continue; } long mid = messageObject.getId(); @@ -991,7 +991,7 @@ public class NotificationsController extends BaseController { if (messages != null) { for (int a = 0; a < messages.size(); a++) { TLRPC.Message message = messages.get(a); - if (message != null && message.silent && (message.action instanceof TLRPC.TL_messageActionContactSignUp || message.action instanceof TLRPC.TL_messageActionUserJoined)) { + if (message != null && (message.fwd_from != null && message.fwd_from.imported || message.silent && (message.action instanceof TLRPC.TL_messageActionContactSignUp || message.action instanceof TLRPC.TL_messageActionUserJoined))) { continue; } long mid = message.id; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index a8233220a..958e8b7c1 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -2909,6 +2909,11 @@ public class SendMessagesHelper extends BaseController implements NotificationCe } } } else { + boolean canSendStickers = true; + if (lower_id < 0) { + TLRPC.Chat chat = getMessagesController().getChat(-lower_id); + canSendStickers = ChatObject.canSendStickers(chat); + } if (message != null) { if (encryptedChat != null) { newMsg = new TLRPC.TL_message_secret(); @@ -2924,7 +2929,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe webPage = null; } } - if (message.length() < 30 && webPage == null && (entities == null || entities.isEmpty()) && getMessagesController().diceEmojies.contains(message.replace("\ufe0f", "")) && encryptedChat == null && scheduleDate == 0) { + if (canSendStickers && message.length() < 30 && webPage == null && (entities == null || entities.isEmpty()) && getMessagesController().diceEmojies.contains(message.replace("\ufe0f", "")) && encryptedChat == null && scheduleDate == 0) { TLRPC.TL_messageMediaDice mediaDice = new TLRPC.TL_messageMediaDice(); mediaDice.emoticon = message; mediaDice.value = -1; @@ -3033,8 +3038,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe newMsg = new TLRPC.TL_message(); } if (lower_id < 0) { - TLRPC.Chat chat = getMessagesController().getChat(-lower_id); - if (chat != null && !ChatObject.canSendStickers(chat)) { + if (!canSendStickers) { for (int a = 0, N = document.attributes.size(); a < N; a++) { if (document.attributes.get(a) instanceof TLRPC.TL_documentAttributeAnimated) { document.attributes.remove(a); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index 8499c40f5..a783782b3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -1391,7 +1391,7 @@ public class DialogCell extends BaseCell { nameLeft += w; } } else if (drawScam != 0) { - int w = AndroidUtilities.dp(6) + (drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth(); + int w = AndroidUtilities.dp(6) + (drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth(); nameWidth -= w; if (LocaleController.isRTL) { nameLeft += w; @@ -1610,7 +1610,7 @@ public class DialogCell extends BaseCell { } else if (drawVerified) { nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - Theme.dialogs_verifiedDrawable.getIntrinsicWidth()); } else if (drawScam != 0) { - nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - (drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth()); + nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - (drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).getIntrinsicWidth()); } if (left == 0) { if (widthpx < nameWidth) { @@ -2508,8 +2508,8 @@ public class DialogCell extends BaseCell { Theme.dialogs_verifiedDrawable.draw(canvas); Theme.dialogs_verifiedCheckDrawable.draw(canvas); } else if (drawScam != 0) { - setDrawableBounds((drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable), nameMuteLeft, AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 12 : 15)); - (drawScam == 0 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).draw(canvas); + setDrawableBounds((drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable), nameMuteLeft, AndroidUtilities.dp(useForceThreeLines || SharedConfig.useThreeLinesLayout ? 12 : 15)); + (drawScam == 1 ? Theme.dialogs_scamDrawable : Theme.dialogs_fakeDrawable).draw(canvas); } if (drawReorder || reorderIconProgress != 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java index 3e2806efe..537b8e4ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java @@ -99,7 +99,7 @@ public class LinkActionView extends LinearLayout { copyView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); copyView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); copyView.setLines(1); - linearLayout.addView(copyView, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, 0, 4, 0, 4, 0)); + linearLayout.addView(copyView, LayoutHelper.createLinear(0, 40, 1f, 0, 4, 0, 4, 0)); shareView = new TextView(context); shareView.setGravity(Gravity.CENTER_HORIZONTAL); @@ -114,7 +114,7 @@ public class LinkActionView extends LinearLayout { shareView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); shareView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); shareView.setLines(1); - linearLayout.addView(shareView, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1f, 4, 0, 4, 0)); + linearLayout.addView(shareView, LayoutHelper.createLinear(0, 40, 1f, 4, 0, 4, 0)); removeView = new TextView(context); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index d3f5574ec..25448c05c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -358,6 +358,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter private float colorChangeProgress; private long lastUpdateTime; private float[] volumeAlphas = new float[3]; + private boolean dragging; public VolumeSlider(Context context, TLRPC.TL_groupCallParticipant participant) { super(context); @@ -446,14 +447,14 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter } else if (thumbX > getMeasuredWidth()) { thumbX = getMeasuredWidth(); } - pressed = true; + dragging = true; } } - if (pressed) { + if (dragging) { if (ev.getAction() == MotionEvent.ACTION_UP) { onSeekBarDrag(thumbX / (double) getMeasuredWidth(), true); } - pressed = false; + dragging = false; invalidate(); return true; } @@ -473,13 +474,13 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter } else if (thumbX > getMeasuredWidth()) { thumbX = getMeasuredWidth(); } - pressed = true; + dragging = true; invalidate(); return true; } } } else { - if (pressed) { + if (dragging) { thumbX = (int) ev.getX(); if (thumbX < 0) { thumbX = 0; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 244085b69..83a46bd03 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -142,6 +142,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; public class LaunchActivity extends Activity implements ActionBarLayout.ActionBarLayoutDelegate, NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate { @@ -1307,11 +1308,20 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } else { String originalPath = uri.toString(); if (dialogId == 0 && originalPath != null) { + if (BuildVars.LOGS_ENABLED) { + FileLog.d("export path = " + originalPath); + } Set exportUris = MessagesController.getInstance(intentAccount[0]).exportUri; + String fileName = FileLoader.fixFileName(MediaController.getFileName(uri)); for (String u : exportUris) { - if (originalPath.startsWith(u)) { - exportingChatUri = uri; - break; + try { + Pattern pattern = Pattern.compile(u); + if (pattern.matcher(originalPath).find() || pattern.matcher(fileName).find()) { + exportingChatUri = uri; + break; + } + } catch (Exception e) { + FileLog.e(e); } } if (exportingChatUri == null) { @@ -1405,13 +1415,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa originalPath = path; } + if (BuildVars.LOGS_ENABLED) { + FileLog.d("export path = " + originalPath); + } if (dialogId == 0 && originalPath != null && exportingChatUri == null) { boolean ok = false; + String fileName = FileLoader.fixFileName(MediaController.getFileName(uri)); for (String u : exportUris) { - if (originalPath.startsWith(u)) { - exportingChatUri = uri; - ok = true; - break; + try { + Pattern pattern = Pattern.compile(u); + if (pattern.matcher(originalPath).find() || pattern.matcher(fileName).find()) { + exportingChatUri = uri; + ok = true; + break; + } + } catch (Exception e) { + FileLog.e(e); } } if (ok) {