diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle
index 9edd68934..05d2525a0 100644
--- a/TMessagesProj/build.gradle
+++ b/TMessagesProj/build.gradle
@@ -299,7 +299,7 @@ android {
}
}
- defaultConfig.versionCode = 2493
+ defaultConfig.versionCode = 2495
applicationVariants.all { variant ->
variant.outputs.all { output ->
@@ -318,7 +318,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
- versionName "8.3.0"
+ versionName "8.3.1"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
diff --git a/TMessagesProj/config/debug/AndroidManifest.xml b/TMessagesProj/config/debug/AndroidManifest.xml
index c01d13c3b..3938549e9 100644
--- a/TMessagesProj/config/debug/AndroidManifest.xml
+++ b/TMessagesProj/config/debug/AndroidManifest.xml
@@ -10,12 +10,12 @@
-
+
-
+
-
+
diff --git a/TMessagesProj/config/release/AndroidManifest.xml b/TMessagesProj/config/release/AndroidManifest.xml
index 7bb790100..4f2e1456e 100644
--- a/TMessagesProj/config/release/AndroidManifest.xml
+++ b/TMessagesProj/config/release/AndroidManifest.xml
@@ -10,12 +10,12 @@
-
+
-
+
-
+
@@ -18,7 +18,7 @@
-
+
-
+
@@ -18,7 +18,7 @@
-
+
-
+
@@ -80,6 +80,7 @@
android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity"
android:supportsRtl="false"
android:requestLegacyExternalStorage="true"
+ android:preserveLegacyExternalStorage="true"
android:allowAudioPlaybackCapture="true"
tools:replace="android:supportsRtl">
@@ -448,6 +449,7 @@
+
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
index ae6a40c46..7910f61e9 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
@@ -19,18 +19,14 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
- public static int BUILD_VERSION = 2493;
- public static String BUILD_VERSION_STRING = "8.3.0";
+ public static int BUILD_VERSION = 2495;
+ public static String BUILD_VERSION_STRING = "8.3.1";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
- // PUBLIC
+
public static boolean DEBUG_PRIVATE_VERSION = false;
- // public static String APPCENTER_HASH_DEBUG = "f9726602-67c9-48d2-b5d0-4761f1c1a8f3";
- // PRIVATE
- //public static boolean DEBUG_PRIVATE_VERSION = true;
- //public static String APPCENTER_HASH_DEBUG = DEBUG_PRIVATE_VERSION ? "29d0a6f1-b92f-493a-9fce-445681d767ec" : "f9726602-67c9-48d2-b5d0-4761f1c1a8f3";
- //
+
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
index 239cdd71f..4618a54e3 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
@@ -166,7 +166,7 @@ public class FileLog {
if (!BuildVars.LOGS_ENABLED) {
return;
}
- if (BuildVars.DEBUG_VERSION && needSent(e)) {
+ if (BuildVars.DEBUG_VERSION && needSent(e) && logToAppCenter) {
AndroidUtilities.appCenterLog(e);
}
ensureInitied();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java b/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java
new file mode 100644
index 000000000..9ffa04135
--- /dev/null
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java
@@ -0,0 +1,315 @@
+package org.telegram.messenger;
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Environment;
+import android.os.IBinder;
+import android.text.TextUtils;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.widget.LinearLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+import androidx.core.graphics.ColorUtils;
+
+import com.google.android.exoplayer2.util.Log;
+
+import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.ActionBar.BottomSheet;
+import org.telegram.ui.ActionBar.Theme;
+import org.telegram.ui.Components.LayoutHelper;
+import org.telegram.ui.Components.StickerImageView;
+import org.telegram.ui.DialogsActivity;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.stream.Stream;
+
+@RequiresApi(api = Build.VERSION_CODES.R)
+public class FilesMigrationService extends Service {
+
+ public static boolean hasOldFolder;
+ public static boolean isRunning;
+ public static FilesMigrationBottomSheet filesMigrationBottomSheet;
+ private int totalFilesCount;
+ private int movedFilesCount;
+ private static boolean wasShown = false;
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ public static void start() {
+ Intent intent = new Intent(ApplicationLoader.applicationContext, FilesMigrationService.class);
+ ApplicationLoader.applicationContext.startService(intent);
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ NotificationsController.checkOtherNotificationsChannel();
+ Notification notification = new Notification.Builder(this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
+ .setContentTitle(getText(R.string.MigratingFiles))
+ .setAutoCancel(false)
+ .setSmallIcon(R.drawable.notification)
+ .build();
+
+ isRunning = true;
+ new Thread() {
+ @Override
+ public void run() {
+ migrateOldFolder();
+ AndroidUtilities.runOnUIThread(() -> {
+ isRunning = false;
+ stopForeground(true);
+ stopSelf();
+ });
+ }
+ }.start();
+ startForeground(301, notification);
+
+ return super.onStartCommand(intent, flags, startId);
+ }
+
+ public void migrateOldFolder() {
+ File path = Environment.getExternalStorageDirectory();
+ if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
+ ArrayList dirs = AndroidUtilities.getRootDirs();
+ if (dirs != null) {
+ for (int a = 0, N = dirs.size(); a < N; a++) {
+ File dir = dirs.get(a);
+ if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
+ path = dir;
+ break;
+ }
+ }
+ }
+ }
+
+ File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
+ File telegramPath = new File(newPath, "Telegram");
+ File oldPath = new File(path, "Telegram");
+
+ totalFilesCount = getFilesCount(oldPath);
+
+ long moveStart = System.currentTimeMillis();
+ if (oldPath.canRead() && oldPath.canWrite()) {
+ moveDirectory(oldPath, telegramPath);
+ }
+ long dt = System.currentTimeMillis() - moveStart;
+
+ FileLog.d("move time = " + dt);
+
+ SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
+ sharedPreferences.edit().putBoolean("migration_to_scoped_storage_finished", true).apply();
+ }
+
+ private int getFilesCount(File source) {
+ if (!source.exists()) {
+ return 0;
+ }
+ int count = 0;
+ File[] fileList = source.listFiles();
+ if (fileList != null) {
+ for (int i = 0; i < fileList.length; i++) {
+ if (fileList[i].isDirectory()) {
+ count += getFilesCount(fileList[i]);
+ } else {
+ count++;
+ }
+ }
+ }
+ return count;
+ }
+
+ private void moveDirectory(File source, File target) {
+ if (!source.exists() || (!target.exists() && !target.mkdir())) {
+ return;
+ }
+ try (Stream files = Files.list(source.toPath())) {
+ files.forEach(path -> {
+ File dest = new File(target, path.getFileName().toString());
+ if (Files.isDirectory(path)) {
+ moveDirectory(path.toFile(), dest);
+ } else {
+ try {
+ Files.move(path, dest.toPath());
+ } catch (Exception e) {
+ FileLog.e(e, false);
+ try {
+ path.toFile().delete();
+ } catch (Exception e1) {
+ FileLog.e(e1);
+ }
+ }
+ movedFilesCount++;
+ updateProgress();
+ }
+ });
+ } catch (Exception e) {
+ FileLog.e(e);
+ }
+ try {
+ source.delete();
+ } catch (Exception e) {
+ FileLog.e(e);
+ }
+ }
+
+ long lastUpdateTime;
+ private void updateProgress() {
+ long time = System.currentTimeMillis();
+ if (time - lastUpdateTime > 20 || movedFilesCount >= totalFilesCount - 1) {
+ int currentCount = movedFilesCount;
+ AndroidUtilities.runOnUIThread(() -> {
+ Notification notification = new Notification.Builder(FilesMigrationService.this, NotificationsController.OTHER_NOTIFICATIONS_CHANNEL)
+ .setContentTitle(getText(R.string.MigratingFiles))
+ .setContentText(String.format("%s/%s", currentCount, totalFilesCount))
+ .setSmallIcon(R.drawable.notification)
+ .setAutoCancel(false)
+ .setProgress(totalFilesCount, currentCount, false)
+ .build();
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ mNotificationManager.notify(301, notification);
+ });
+ }
+ }
+
+ public static void checkBottomSheet(BaseFragment fragment) {
+ SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
+ if (!Environment.isExternalStorageLegacy() || sharedPreferences.getBoolean("migration_to_scoped_storage_finished", false) || sharedPreferences.getInt("migration_to_scoped_storage_count", 0) >= 5 || wasShown || filesMigrationBottomSheet != null || isRunning) {
+ return;
+ }
+ if (Build.VERSION.SDK_INT >= 30) {
+ File path = Environment.getExternalStorageDirectory();
+ if (!TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
+ ArrayList dirs = AndroidUtilities.getRootDirs();
+ if (dirs != null) {
+ for (int a = 0, N = dirs.size(); a < N; a++) {
+ File dir = dirs.get(a);
+ if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
+ path = dir;
+ break;
+ }
+ }
+ }
+ }
+ File oldDirectory = new File(path, "Telegram");
+ hasOldFolder = oldDirectory.exists();
+ }
+ if (hasOldFolder) {
+ filesMigrationBottomSheet = new FilesMigrationBottomSheet(fragment);
+ filesMigrationBottomSheet.show();
+ wasShown = true;
+ sharedPreferences.edit().putInt("migration_to_scoped_storage_count", sharedPreferences.getInt("migration_to_scoped_storage_count", 0) + 1).apply();
+ } else {
+ sharedPreferences.edit().putBoolean("migration_to_scoped_storage_finished", true).apply();
+ }
+ }
+
+ public static class FilesMigrationBottomSheet extends BottomSheet {
+
+ BaseFragment fragment;
+
+ @Override
+ protected boolean canDismissWithSwipe() {
+ return false;
+ }
+
+ @Override
+ protected boolean canDismissWithTouchOutside() {
+ return false;
+ }
+
+ public FilesMigrationBottomSheet(BaseFragment fragment) {
+ super(fragment.getParentActivity(), false);
+ this.fragment = fragment;
+ setCanceledOnTouchOutside(false);
+ Context context = fragment.getParentActivity();
+ LinearLayout linearLayout = new LinearLayout(context);
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
+
+ StickerImageView imageView = new StickerImageView(context, currentAccount);
+ imageView.setStickerNum(7);
+ imageView.getImageReceiver().setAutoRepeat(1);
+ linearLayout.addView(imageView, LayoutHelper.createLinear(144, 144, Gravity.CENTER_HORIZONTAL, 0, 16, 0, 0));
+
+ TextView title = new TextView(context);
+ title.setGravity(Gravity.START);
+ title.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
+ title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ title.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ title.setText(LocaleController.getString("MigrateOldFolderTitle", R.string.MigrateOldFolderTitle));
+ linearLayout.addView(title, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 21, 30, 21, 0));
+
+ TextView description = new TextView(context);
+ description.setGravity(Gravity.START);
+ description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ description.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
+ description.setText(AndroidUtilities.replaceTags(LocaleController.getString("MigrateOldFolderDescription", R.string.MigrateOldFolderDescription)));
+ linearLayout.addView(description, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 21, 15, 21, 16));
+
+
+ TextView buttonTextView = new TextView(context);
+ buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
+ buttonTextView.setGravity(Gravity.CENTER);
+ buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ buttonTextView.setText(LocaleController.getString("MigrateOldFolderButton", R.string.MigrateOldFolderButton));
+
+ buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
+ buttonTextView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_featuredStickers_addButton), ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_windowBackgroundWhite), 120)));
+
+ linearLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, 0, 16, 15, 16, 16));
+
+ buttonTextView.setOnClickListener(view -> {
+ migrateOldFolder();
+ });
+
+ ScrollView scrollView = new ScrollView(context);
+ scrollView.addView(linearLayout);
+ setCustomView(scrollView);
+ }
+
+ public void migrateOldFolder() {
+ Activity activity = fragment.getParentActivity();
+ boolean canWrite = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
+ boolean canRead = activity.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
+
+ if (!canRead || !canWrite) {
+ ArrayList permissions = new ArrayList<>();
+ if (!canRead) {
+ permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
+ }
+ if (!canWrite) {
+ permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
+ }
+ String[] string = new String[permissions.size()];
+ activity.requestPermissions(permissions.toArray(string), 4);
+ return;
+ }
+ start();
+ dismiss();
+ }
+
+ @Override
+ public void dismiss() {
+ super.dismiss();
+ filesMigrationBottomSheet = null;
+ }
+ }
+}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
index 3572033d7..457b38b2d 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
@@ -4722,20 +4722,26 @@ public class MessagesController extends BaseController implements NotificationCe
});
}
- public void deleteUserChannelHistory(TLRPC.Chat chat, TLRPC.User user, int offset) {
+ public void deleteUserChannelHistory(TLRPC.Chat currentChat, TLRPC.User fromUser, TLRPC.Chat fromChat, int offset) {
+ long fromId = 0;
+ if (fromUser != null) {
+ fromId = fromUser.id;
+ } else if (fromChat != null){
+ fromId = fromChat.id;
+ }
if (offset == 0) {
- getMessagesStorage().deleteUserChatHistory(-chat.id, user.id);
+ getMessagesStorage().deleteUserChatHistory(-currentChat.id, fromId);
}
TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory();
- req.channel = getInputChannel(chat);
- req.participant = getInputPeer(user);
+ req.channel = getInputChannel(currentChat);
+ req.participant = fromUser != null ? getInputPeer(fromUser) : getInputPeer(fromChat);
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) {
- deleteUserChannelHistory(chat, user, res.offset);
+ deleteUserChannelHistory(currentChat, fromUser, fromChat, res.offset);
}
- processNewChannelDifferenceParams(res.pts, res.pts_count, chat.id);
+ processNewChannelDifferenceParams(res.pts, res.pts_count, currentChat.id);
}
});
}
@@ -14810,10 +14816,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void markSponsoredAsRead(long dialog_id, MessageObject object) {
- ArrayList messages = getSponsoredMessages(dialog_id);
- if (messages != null) {
- messages.remove(object);
- }
+ sponsoredMessages.remove(dialog_id);
}
public void deleteMessagesRange(long dialogId, long channelId, int minDate, int maxDate, boolean forAll, Runnable callback) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
index dc59684e8..80294eb4d 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
@@ -292,7 +292,7 @@ public class MessagesStorage extends BaseController {
shmCacheFile = new File(filesDir, "cache4.db-shm");
boolean createTable = false;
- //cacheFile.delete();
+
if (!cacheFile.exists()) {
createTable = true;
}
@@ -452,6 +452,9 @@ public class MessagesStorage extends BaseController {
}
cursor.dispose();
} catch (Exception e) {
+ if (e.getMessage() != null && e.getMessage().contains("malformed")) {
+ throw new RuntimeException("malformed");
+ }
FileLog.e(e);
try {
database.executeFast("CREATE TABLE IF NOT EXISTS params(id INTEGER PRIMARY KEY, seq INTEGER, pts INTEGER, date INTEGER, qts INTEGER, lsv INTEGER, sg INTEGER, pbytes BLOB)").stepThis().dispose();
@@ -6015,6 +6018,9 @@ public class MessagesStorage extends BaseController {
participant = TLRPC.ChannelParticipant.TLdeserialize(data, data.readInt32(false), false);
data.reuse();
}
+ if (participant != null && participant.user_id == getUserConfig().clientUserId) {
+ user = getUserConfig().getCurrentUser();
+ }
if (user != null && participant != null) {
if (user.status != null) {
user.status.expires = cursor.intValue(1);
@@ -8748,7 +8754,7 @@ public class MessagesStorage extends BaseController {
try {
SQLitePreparedStatement state = database.executeFast("UPDATE messages_v2 SET replies_data = ? WHERE mid = ? AND uid = ?");
TLRPC.MessageReplies currentReplies = null;
- SQLiteCursor cursor = database.queryFinalized(String.format("SELECT replies_data FROM messages_v2 WHERE mid = %d AND uid = %d", mid, -chatId));
+ SQLiteCursor cursor = database.queryFinalized(String.format(Locale.ENGLISH, "SELECT replies_data FROM messages_v2 WHERE mid = %d AND uid = %d", mid, -chatId));
if (cursor.next()) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
index 54d978597..a9b64e0ea 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
@@ -13,6 +13,8 @@ import androidx.annotation.UiThread;
import android.os.SystemClock;
import android.util.SparseArray;
+import com.google.android.exoplayer2.util.Log;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
index 36d12943d..8a62a2595 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
@@ -1025,7 +1025,7 @@ public class ConnectionsManager extends BaseController {
httpConnectionStream.close();
}
} catch (Throwable e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
try {
if (outbuf != null) {
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
index 7e5e3de46..d2d206cc3 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
@@ -49905,29 +49905,29 @@ public class TLRPC {
}
}
- public static class TL_channels_reportSpam extends TLObject {
- public static int constructor = 0xfe087810;
+ public static class TL_channels_reportSpam extends TLObject {
+ public static int constructor = 0xf44a8315;
- public InputChannel channel;
- public InputUser user_id;
- public ArrayList id = new ArrayList<>();
+ public InputChannel channel;
+ public InputPeer participant;
+ public ArrayList id = new ArrayList<>();
- public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
- return Bool.TLdeserialize(stream, constructor, exception);
- }
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Bool.TLdeserialize(stream, constructor, exception);
+ }
- public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- channel.serializeToStream(stream);
- user_id.serializeToStream(stream);
- stream.writeInt32(0x1cb5c415);
- int count = id.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- stream.writeInt32(id.get(a));
- }
- }
- }
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ channel.serializeToStream(stream);
+ participant.serializeToStream(stream);
+ stream.writeInt32(0x1cb5c415);
+ int count = id.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeInt32(id.get(a));
+ }
+ }
+ }
public static class TL_channels_getMessages extends TLObject {
public static int constructor = 0x93d7b347;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
index e3b25c574..f70624ac3 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
@@ -1590,6 +1590,7 @@ public class ActionBarMenuItem extends FrameLayout {
if (view != null && view.getVisibility() != GONE) {
view.setVisibility(GONE);
measurePopup = true;
+ checkHideMenuItem();
}
}
@@ -1618,6 +1619,7 @@ public class ActionBarMenuItem extends FrameLayout {
popupLayout.getItemAt(a).setVisibility(GONE);
}
measurePopup = true;
+ checkHideMenuItem();
}
public boolean isSubItemVisible(int id) {
@@ -1636,6 +1638,7 @@ public class ActionBarMenuItem extends FrameLayout {
if (view != null && view.getVisibility() != VISIBLE) {
view.setVisibility(VISIBLE);
measurePopup = true;
+ checkHideMenuItem();
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
index cca5ae1d6..fcb1a3b7e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
@@ -10,13 +10,11 @@ package org.telegram.ui;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.Intent;
import android.content.SharedPreferences;
-import android.net.Uri;
+import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
-import android.provider.Settings;
import android.text.TextUtils;
import android.transition.ChangeBounds;
import android.transition.Fade;
@@ -25,7 +23,6 @@ import android.transition.TransitionSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -35,18 +32,14 @@ import androidx.core.widget.NestedScrollView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import com.google.android.exoplayer2.util.Log;
-
import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.messenger.AndroidUtilities;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.BuildConfig;
-import org.telegram.messenger.BuildVars;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
+import org.telegram.messenger.FilesMigrationService;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
@@ -79,11 +72,7 @@ import org.telegram.ui.Components.StroageUsageView;
import org.telegram.ui.Components.UndoView;
import java.io.File;
-import java.nio.file.CopyOption;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.stream.Stream;
public class CacheControlActivity extends BaseFragment {
@@ -118,7 +107,6 @@ public class CacheControlActivity extends BaseFragment {
private boolean calculating = true;
private volatile boolean canceled = false;
- private boolean hasOldFolder;
private View bottomSheetView;
private BottomSheet bottomSheet;
@@ -213,24 +201,6 @@ public class CacheControlActivity extends BaseFragment {
});
fragmentCreateTime = System.currentTimeMillis();
-
- if (Build.VERSION.SDK_INT >= 30) {
- File path = Environment.getExternalStorageDirectory();
- if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
- ArrayList dirs = AndroidUtilities.getRootDirs();
- if (dirs != null) {
- for (int a = 0, N = dirs.size(); a < N; a++) {
- File dir = dirs.get(a);
- if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
- path = dir;
- break;
- }
- }
- }
- }
- File oldDirectory = new File(path, "Telegram");
- hasOldFolder = oldDirectory.exists();
- }
updateRows();
return true;
}
@@ -247,21 +217,18 @@ public class CacheControlActivity extends BaseFragment {
cacheInfoRow = rowCount++;
databaseRow = rowCount++;
databaseInfoRow = rowCount++;
-// if (hasOldFolder) {
-// migrateOldFolderRow = rowCount++;
-// }
}
private void updateStorageUsageRow() {
View view = layoutManager.findViewByPosition(storageUsageRow);
if (view instanceof StroageUsageView) {
StroageUsageView stroageUsageView = ((StroageUsageView) view);
- long currentTime = System.currentTimeMillis();
+ long currentTime = System.currentTimeMillis();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && currentTime - fragmentCreateTime > 250) {
TransitionSet transition = new TransitionSet();
ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setDuration(250);
- changeBounds.excludeTarget(stroageUsageView.legendLayout,true);
+ changeBounds.excludeTarget(stroageUsageView.legendLayout, true);
Fade in = new Fade(Fade.IN);
in.setDuration(290);
transition
@@ -569,111 +536,7 @@ public class CacheControlActivity extends BaseFragment {
@RequiresApi(api = Build.VERSION_CODES.R)
private void migrateOldFolder() {
- boolean isExternalStorageManager = Environment.isExternalStorageManager();
-
- if (!BuildVars.NO_SCOPED_STORAGE && !isExternalStorageManager) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("MigrateOldFolder", R.string.MigrateOldFolder));
- builder.setMessage(LocaleController.getString("ManageAllFilesRational2", R.string.ManageAllFilesRational2));
- builder.setPositiveButton(LocaleController.getString("Allow", R.string.Allow), (i1, i2) -> {
- Uri uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID);
- getParentActivity().startActivity(new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri));
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (i1, i2) -> {
-
- });
- builder.show();
- return;
- }
-
- Thread thread = new Thread() {
-
- int totalFilesCount;
- int movedFilesCount;
- @Override
- public void run() {
- super.run();
- File path = Environment.getExternalStorageDirectory();
- if (Build.VERSION.SDK_INT >= 19 && !TextUtils.isEmpty(SharedConfig.storageCacheDir)) {
- ArrayList dirs = AndroidUtilities.getRootDirs();
- if (dirs != null) {
- for (int a = 0, N = dirs.size(); a < N; a++) {
- File dir = dirs.get(a);
- if (dir.getAbsolutePath().startsWith(SharedConfig.storageCacheDir)) {
- path = dir;
- break;
- }
- }
- }
- }
-
- File newPath = ApplicationLoader.applicationContext.getExternalFilesDir(null);
- File telegramPath = new File(newPath, "Telegram");
- File oldPath = new File(path, "Telegram");
-
- totalFilesCount = getFilesCount(oldPath);
-
- long moveStart = System.currentTimeMillis();
- moveDirectory(oldPath, telegramPath);
- long dt = System.currentTimeMillis() - moveStart;
- FileLog.d("move time = " + dt);
- }
-
- private int getFilesCount(File source) {
- if (!source.exists()) {
- return 0;
- }
- int count = 0;
- File[] fileList = source.listFiles();
- for (int i = 0; i < fileList.length; i++) {
- if (fileList[i].isDirectory()) {
- count += getFilesCount(fileList[i]);
- } else {
- count++;
- }
- }
- return count;
- }
-
- private void moveDirectory(File source, File target) {
- if (!source.exists() || (!target.exists() && !target.mkdir())) {
- return;
- }
- try (Stream files = Files.list(source.toPath())) {
- files.forEach(path -> {
- File dest = new File(target, path.getFileName().toString());
- if (Files.isDirectory(path)) {
- moveDirectory(path.toFile(), dest);
- } else {
- try {
- Files.move(path, dest.toPath());
- } catch (Exception e) {
- FileLog.e(e);
- try {
- path.toFile().delete();
- } catch (Exception e1) {
- FileLog.e(e1);
- }
- }
- movedFilesCount++;
- updateProgress();
- }
- });
- } catch (Exception e) {
- FileLog.e(e);
- }
- try {
- source.delete();
- } catch (Exception e) {
- FileLog.e(e);
- }
- }
-
- private void updateProgress() {
- float p = movedFilesCount / (float) totalFilesCount;
- }
- };
- thread.start();
+ FilesMigrationService.checkBottomSheet(this);
}
private void clearDatabase() {
@@ -982,4 +845,21 @@ public class CacheControlActivity extends BaseFragment {
arrayList.add(new ThemeDescription(bottomSheetView, 0, null, null, null, null, Theme.key_statisticChartLine_indigo));
return arrayList;
}
+
+ @Override
+ public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
+ if (requestCode == 4) {
+ boolean allGranted = true;
+ for (int a = 0; a < grantResults.length; a++) {
+ if (grantResults[a] != PackageManager.PERMISSION_GRANTED) {
+ allGranted = false;
+ break;
+ }
+ }
+ if (allGranted && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && FilesMigrationService.filesMigrationBottomSheet != null) {
+ FilesMigrationService.filesMigrationBottomSheet.migrateOldFolder();
+ }
+
+ }
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
index 51c7bdc67..78dd6fcaf 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
@@ -378,7 +378,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
} else if (url.startsWith("http")) {
Browser.openUrl(getContext(), url);
} else {
- delegate.needOpenUserProfile(Integer.parseInt(url));
+ delegate.needOpenUserProfile(Long.parseLong(url));
}
}
result = true;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java
index 61a170e7d..55985d392 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java
@@ -105,6 +105,16 @@ public class SessionCell extends FrameLayout {
linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
}
+ int leftMargin;
+ int rightMargin;
+ if (LocaleController.isRTL) {
+ rightMargin = type == 0 ? 72 : 21;
+ leftMargin = 21;
+ } else {
+ leftMargin = type == 0 ? 72 : 21;
+ rightMargin = 21;
+ }
+
detailTextView = new TextView(context);
detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
@@ -113,7 +123,7 @@ public class SessionCell extends FrameLayout {
detailTextView.setSingleLine(true);
detailTextView.setEllipsize(TextUtils.TruncateAt.END);
detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
- addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, type == 0 ? 72 : 21, 36, 21, 0));
+ addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 36, rightMargin, 0));
detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
@@ -123,7 +133,7 @@ public class SessionCell extends FrameLayout {
detailExTextView.setSingleLine(true);
detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
- addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, type == 0 ? 72 : 21, 59, 21, 0));
+ addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, leftMargin, 59, rightMargin, 0));
}
@Override
@@ -136,11 +146,7 @@ public class SessionCell extends FrameLayout {
if (object instanceof TLRPC.TL_authorization) {
TLRPC.TL_authorization session = (TLRPC.TL_authorization) object;
-
-
imageView.setImageDrawable(createDrawable(session));
- // nameTextView.setText(String.format(Locale.US, "%s %s", session.app_name, session.app_version));
-
StringBuilder stringBuilder = new StringBuilder();
if (session.device_model.length() != 0) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
index 892bc3555..63cddae57 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
@@ -1794,9 +1794,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
* @return Other same chats index difference
*/
public int getOtherSameChatsDiff() {
+ if (parentLayout == null || parentLayout.fragmentsStack == null) {
+ return 0;
+ }
int cur = parentLayout.fragmentsStack.indexOf(this);
- if (cur == -1)
+ if (cur == -1) {
cur = parentLayout.fragmentsStack.size();
+ }
int i = cur;
for (int a = 0; a < parentLayout.fragmentsStack.size(); a++) {
BaseFragment fragment = parentLayout.fragmentsStack.get(a);
@@ -2344,6 +2348,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
}
});
+ } else {
+ actionBar.setSubtitle(LocaleController.getString("NoMessagesForThisDay", R.string.NoMessagesForThisDay));
}
}
});
@@ -2388,7 +2394,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AndroidUtilities.updateViewVisibilityAnimated(avatarContainer, true, 0.95f, true);
if (editTextItem != null && editTextItem.getTag() != null) {
if (headerItem != null) {
- Log.d("kek", "2");
headerItem.setVisibility(View.GONE);
}
if (editTextItem != null) {
@@ -2405,7 +2410,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else if (chatActivityEnterView.hasText() && TextUtils.isEmpty(chatActivityEnterView.getSlowModeTimer()) && (currentChat == null || ChatObject.canSendMessages(currentChat))) {
if (headerItem != null) {
- Log.d("kek", "3");
headerItem.setVisibility(View.GONE);
}
if (editTextItem != null) {
@@ -2516,7 +2520,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
searchItemVisible = false;
}
- if (chatMode == 0 && threadMessageId == 0 && !UserObject.isReplyUser(currentUser) && reportType < 0) {
+ if (chatMode == 0 && threadMessageId == 0 && !UserObject.isReplyUser(currentUser) && reportType < 0 && !inMenuMode) {
TLRPC.UserFull userFull = null;
if (currentUser != null) {
audioCallIconItem = menu.addItem(call, R.drawable.ic_call, themeDelegate);
@@ -6972,7 +6976,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (editTextItem.getTag() == null) {
editTextItem.setTag(1);
editTextItem.setVisibility(View.VISIBLE);
- Log.d("kek", "4");
headerItem.setVisibility(View.GONE);
attachItem.setVisibility(View.GONE);
}
@@ -6983,7 +6986,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
editTextItem.setTag(null);
editTextItem.setVisibility(View.GONE);
if (chatActivityEnterView.hasText() && TextUtils.isEmpty(chatActivityEnterView.getSlowModeTimer())) {
- Log.d("kek", "5");
headerItem.setVisibility(View.GONE);
attachItem.setVisibility(View.VISIBLE);
} else {
@@ -7045,7 +7047,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (TextUtils.isEmpty(chatActivityEnterView.getSlowModeTimer())) {
if (headerItem != null) {
- Log.d("kek", "6");
headerItem.setVisibility(View.GONE);
}
if (attachItem != null) {
@@ -14171,14 +14172,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (startLoadFromDate != 0) {
int dateObjectIndex = -1;
+ int closeDateObjectIndex = -1;
+ int closeDateDiff = 0;
for (int i = 0; i < messages.size(); i++) {
if (messages.get(i).isDateObject && Math.abs(startLoadFromDate - messages.get(i).messageOwner.date) <= 100) {
dateObjectIndex = i;
break;
}
+ if (messages.get(i).isDateObject) {
+ int timeDiff = Math.abs(startLoadFromDate - messages.get(i).messageOwner.date);
+ if (closeDateObjectIndex == -1 || timeDiff < closeDateDiff) {
+ closeDateDiff = timeDiff;
+ closeDateObjectIndex = i;
+ }
+ }
}
- if (dateObjectIndex > 0) {
+ if (dateObjectIndex >= 0) {
chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + dateObjectIndex, (int) (AndroidUtilities.dp(4)), false);
+ } else if (closeDateObjectIndex >= 0) {
+ chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + closeDateObjectIndex, chatListView.getMeasuredHeight() / 2 - AndroidUtilities.dp(24), false);
}
}
}
@@ -21901,7 +21913,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!actionBar.isSearchFieldVisible()) {
AndroidUtilities.updateViewVisibilityAnimated(avatarContainer, false, 0.95f, true);
if (headerItem != null) {
- Log.d("kek", "1");
headerItem.setVisibility(View.GONE);
}
if (attachItem != null) {
@@ -22964,681 +22975,675 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
view = new ChatMessageCell(mContext, true, themeDelegate);
}
ChatMessageCell chatMessageCell = (ChatMessageCell) view;
- if (!inPreviewMode) {
- chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {
+ chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {
- @Override
- public void didPressHint(ChatMessageCell cell, int type) {
- if (type == 0) {
- TLRPC.TL_messageMediaPoll media = (TLRPC.TL_messageMediaPoll) cell.getMessageObject().messageOwner.media;
- showPollSolution(cell.getMessageObject(), media.results);
- } else if (type == 1) {
- MessageObject messageObject = cell.getMessageObject();
- if (messageObject.messageOwner.fwd_from == null || TextUtils.isEmpty(messageObject.messageOwner.fwd_from.psa_type)) {
- return;
- }
- CharSequence text = LocaleController.getString("PsaMessageInfo_" + messageObject.messageOwner.fwd_from.psa_type);
- if (TextUtils.isEmpty(text)) {
- text = LocaleController.getString("PsaMessageInfoDefault", R.string.PsaMessageInfoDefault);
- }
- SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
- MessageObject.addLinks(false, stringBuilder);
- MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
- if (group != null) {
- for (int a = 0, N = group.posArray.size(); a < N; a++) {
- MessageObject.GroupedMessagePosition pos = group.posArray.get(a);
- if ((pos.flags & MessageObject.POSITION_FLAG_LEFT) != 0) {
- MessageObject m = group.messages.get(a);
- if (m != messageObject) {
- messageObject = m;
- int count = chatListView.getChildCount();
- for (int b = 0; b < count; b++) {
- View view = chatListView.getChildAt(b);
- if (!(view instanceof ChatMessageCell)) {
- continue;
- }
- ChatMessageCell c = (ChatMessageCell) view;
- if (messageObject.equals(c.getMessageObject())) {
- cell = c;
- }
+ @Override
+ public void didPressHint(ChatMessageCell cell, int type) {
+ if (type == 0) {
+ TLRPC.TL_messageMediaPoll media = (TLRPC.TL_messageMediaPoll) cell.getMessageObject().messageOwner.media;
+ showPollSolution(cell.getMessageObject(), media.results);
+ } else if (type == 1) {
+ MessageObject messageObject = cell.getMessageObject();
+ if (messageObject.messageOwner.fwd_from == null || TextUtils.isEmpty(messageObject.messageOwner.fwd_from.psa_type)) {
+ return;
+ }
+ CharSequence text = LocaleController.getString("PsaMessageInfo_" + messageObject.messageOwner.fwd_from.psa_type);
+ if (TextUtils.isEmpty(text)) {
+ text = LocaleController.getString("PsaMessageInfoDefault", R.string.PsaMessageInfoDefault);
+ }
+ SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
+ MessageObject.addLinks(false, stringBuilder);
+ MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
+ if (group != null) {
+ for (int a = 0, N = group.posArray.size(); a < N; a++) {
+ MessageObject.GroupedMessagePosition pos = group.posArray.get(a);
+ if ((pos.flags & MessageObject.POSITION_FLAG_LEFT) != 0) {
+ MessageObject m = group.messages.get(a);
+ if (m != messageObject) {
+ messageObject = m;
+ int count = chatListView.getChildCount();
+ for (int b = 0; b < count; b++) {
+ View view = chatListView.getChildAt(b);
+ if (!(view instanceof ChatMessageCell)) {
+ continue;
+ }
+ ChatMessageCell c = (ChatMessageCell) view;
+ if (messageObject.equals(c.getMessageObject())) {
+ cell = c;
}
}
- break;
}
+ break;
}
}
- showInfoHint(messageObject, stringBuilder, 1);
}
- cell.showHintButton(false, true, type);
+ showInfoHint(messageObject, stringBuilder, 1);
}
+ cell.showHintButton(false, true, type);
+ }
- @Override
- public boolean shouldDrawThreadProgress(ChatMessageCell cell) {
- MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
- MessageObject message;
- if (group != null && !group.messages.isEmpty()) {
- message = group.messages.get(0);
+ @Override
+ public boolean shouldDrawThreadProgress(ChatMessageCell cell) {
+ MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
+ MessageObject message;
+ if (group != null && !group.messages.isEmpty()) {
+ message = group.messages.get(0);
+ } else {
+ message = cell.getMessageObject();
+ }
+ if (message == null) {
+ return false;
+ }
+ return message.getId() == commentLoadingMessageId;
+ }
+
+ @Override
+ public void didPressSideButton(ChatMessageCell cell) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ if (chatActivityEnterView != null) {
+ chatActivityEnterView.closeKeyboard();
+ }
+ MessageObject messageObject = cell.getMessageObject();
+ if (chatMode == MODE_PINNED) {
+ chatActivityDelegate.openReplyMessage(messageObject.getId());
+ finishFragment();
+ } else if ((UserObject.isReplyUser(currentUser) || UserObject.isUserSelf(currentUser)) && messageObject.messageOwner.fwd_from.saved_from_peer != null) {
+ if (UserObject.isReplyUser(currentUser) && messageObject.messageOwner.reply_to != null && messageObject.messageOwner.reply_to.reply_to_top_id != 0) {
+ openDiscussionMessageChat(messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id, null, messageObject.messageOwner.reply_to.reply_to_top_id, 0, -1, messageObject.messageOwner.fwd_from.saved_from_msg_id, messageObject);
} else {
- message = cell.getMessageObject();
+ openOriginalReplyChat(messageObject);
}
- if (message == null) {
- return false;
+ } else {
+ ArrayList arrayList = null;
+ if (messageObject.getGroupId() != 0) {
+ MessageObject.GroupedMessages groupedMessages = groupedMessagesMap.get(messageObject.getGroupId());
+ if (groupedMessages != null) {
+ arrayList = groupedMessages.messages;
+ }
}
- return message.getId() == commentLoadingMessageId;
- }
+ if (arrayList == null) {
+ arrayList = new ArrayList<>();
+ arrayList.add(messageObject);
+ }
+ showDialog(new ShareAlert(mContext, ChatActivity.this, arrayList, null, null, ChatObject.isChannel(currentChat), null, null, false, false, themeDelegate) {
+ @Override
+ public void dismissInternal() {
+ super.dismissInternal();
+ AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
+ if (chatActivityEnterView.getVisibility() == View.VISIBLE) {
+ fragmentView.requestLayout();
+ }
+ }
- @Override
- public void didPressSideButton(ChatMessageCell cell) {
+ @Override
+ protected void onSend(LongSparseArray dids, int count) {
+ if (dids.size() == 1) {
+ undoView.showWithAction(dids.valueAt(0).id, UndoView.ACTION_FWD_MESSAGES, count);
+ } else {
+ undoView.showWithAction(0, UndoView.ACTION_FWD_MESSAGES, count, dids.size(), null, null);
+ }
+ }
+ });
+ AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
+ fragmentView.requestLayout();
+ }
+ }
+
+ @Override
+ public boolean needPlayMessage(MessageObject messageObject) {
+ if (messageObject.isVoice() || messageObject.isRoundVideo()) {
+ boolean result = MediaController.getInstance().playMessage(messageObject);
+ MediaController.getInstance().setVoiceMessagesPlaylist(result ? createVoiceMessagesPlaylist(messageObject, false) : null, false);
+ return result;
+ } else if (messageObject.isMusic()) {
+ return MediaController.getInstance().setPlaylist(messages, messageObject, mergeDialogId);
+ }
+ return false;
+ }
+
+ @Override
+ public void videoTimerReached() {
+ showNoSoundHint();
+ }
+
+ @Override
+ public void didPressTime(ChatMessageCell cell) {
+ undoView.showWithAction(dialog_id, UndoView.ACTION_IMPORT_INFO, null);
+ }
+
+ @Override
+ public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
+ if (chat == null) {
+ return;
+ }
+ if (actionBar.isActionModeShowed() || reportType >= 0) {
+ processRowSelect(cell, true, touchX, touchY);
+ return;
+ }
+ openChat(cell, chat, postId);
+ }
+
+ @Override
+ public void didPressHiddenForward(ChatMessageCell cell) {
+ if (cell.getMessageObject().isImportedForward()) {
+ didPressTime(cell);
+ return;
+ }
+ showForwardHint(cell);
+ }
+
+ @Override
+ public void didPressOther(ChatMessageCell cell, float otherX, float otherY) {
+ MessageObject messageObject = cell.getMessageObject();
+ if (messageObject.type == 16) {
+ if (currentUser != null) {
+ VoIPHelper.startCall(currentUser, messageObject.isVideoCall(), userInfo != null && userInfo.video_calls_available, getParentActivity(), getMessagesController().getUserFull(currentUser.id), getAccountInstance());
+ }
+ } else {
+ createMenu(cell, true, false, otherX, otherY, messageObject.isMusic());
+ }
+ }
+
+ @Override
+ public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
+ if (actionBar.isActionModeShowed() || reportType >= 0) {
+ processRowSelect(cell, true, touchX, touchY);
+ return;
+ }
+ openProfile(user);
+ }
+
+ @Override
+ public boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
+ if (isAvatarPreviewerEnabled()) {
+ final boolean enableMention = currentChat != null && (bottomOverlayChat == null || bottomOverlayChat.getVisibility() != View.VISIBLE) && (bottomOverlay == null || bottomOverlay.getVisibility() != View.VISIBLE);
+ final AvatarPreviewer.MenuItem[] menuItems = new AvatarPreviewer.MenuItem[2 + (enableMention ? 1 : 0)];
+ menuItems[0] = AvatarPreviewer.MenuItem.OPEN_PROFILE;
+ menuItems[1] = AvatarPreviewer.MenuItem.SEND_MESSAGE;
+ if (enableMention) {
+ menuItems[2] = AvatarPreviewer.MenuItem.MENTION;
+ }
+ final TLRPC.UserFull userFull = getMessagesController().getUserFull(user.id);
+ final AvatarPreviewer.Data data;
+ if (userFull != null) {
+ data = AvatarPreviewer.Data.of(userFull, menuItems);
+ } else {
+ data = AvatarPreviewer.Data.of(user, classGuid, menuItems);
+ }
+ if (AvatarPreviewer.canPreview(data)) {
+ AvatarPreviewer.getInstance().show((ViewGroup) fragmentView, data, item -> {
+ switch (item) {
+ case SEND_MESSAGE:
+ openDialog(cell, user);
+ break;
+ case OPEN_PROFILE:
+ openProfile(user);
+ break;
+ case MENTION:
+ appendMention(user);
+ break;
+ }
+ });
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void appendMention(TLRPC.User user) {
+ if (chatActivityEnterView != null) {
+ final SpannableStringBuilder sb = new SpannableStringBuilder();
+ final CharSequence text = chatActivityEnterView.getFieldText();
+ if (text != null) {
+ sb.append(text);
+ }
+ if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') {
+ sb.append(' ');
+ }
+ if (user.username != null) {
+ sb.append("@").append(user.username).append(" ");
+ } else {
+ String name = UserObject.getFirstName(user, false);
+ Spannable spannable = new SpannableString(name + " ");
+ spannable.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ sb.append(spannable);
+ }
+ chatActivityEnterView.setFieldText(sb);
+ AndroidUtilities.runOnUIThread(() -> chatActivityEnterView.openKeyboard(), 200);
+ }
+ }
+
+ @Override
+ public boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
+ if (isAvatarPreviewerEnabled()) {
+ AvatarPreviewer.MenuItem[] menuItems = {AvatarPreviewer.MenuItem.OPEN_PROFILE};
+ if (currentChat == null || currentChat.id != chat.id || isThreadChat()) {
+ menuItems = Arrays.copyOf(menuItems, 2);
+ menuItems[1] = chat.broadcast ? AvatarPreviewer.MenuItem.OPEN_CHANNEL : AvatarPreviewer.MenuItem.OPEN_GROUP;
+ }
+ final TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chat.id);
+ final AvatarPreviewer.Data data;
+ if (chatFull != null) {
+ data = AvatarPreviewer.Data.of(chat, chatFull, menuItems);
+ } else {
+ data = AvatarPreviewer.Data.of(chat, classGuid, menuItems);
+ }
+ if (AvatarPreviewer.canPreview(data)) {
+ AvatarPreviewer.getInstance().show((ViewGroup) fragmentView, data, item -> {
+ switch (item) {
+ case OPEN_PROFILE:
+ openProfile(chat);
+ break;
+ case OPEN_GROUP:
+ case OPEN_CHANNEL:
+ openChat(cell, chat, 0);
+ break;
+ }
+ });
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void openProfile(TLRPC.User user) {
+ if (user != null && user.id != getUserConfig().getClientUserId()) {
+ Bundle args = new Bundle();
+ args.putLong("user_id", user.id);
+ ProfileActivity fragment = new ProfileActivity(args);
+ fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id ? 1 : 0);
+ AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
+ presentFragment(fragment);
+ }
+ }
+
+ private void openProfile(TLRPC.Chat chat) {
+ if (chat != null) {
+ Bundle args = new Bundle();
+ args.putLong("chat_id", chat.id);
+ presentFragment(new ProfileActivity(args));
+ }
+ }
+
+ private void openDialog(ChatMessageCell cell, TLRPC.User user) {
+ if (user != null) {
+ Bundle args = new Bundle();
+ args.putLong("user_id", user.id);
+ if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject())) {
+ presentFragment(new ChatActivity(args));
+ }
+ }
+ }
+
+ private void openChat(ChatMessageCell cell, TLRPC.Chat chat, int postId) {
+ if (currentChat != null && chat.id == currentChat.id) {
+ scrollToMessageId(postId, cell.getMessageObject().getId(), true, 0, true, 0);
+ } else if (currentChat == null || chat.id != currentChat.id || isThreadChat()) {
+ Bundle args = new Bundle();
+ args.putLong("chat_id", chat.id);
+ if (postId != 0) {
+ args.putInt("message_id", postId);
+ }
+ if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject())) {
+ presentFragment(new ChatActivity(args));
+ }
+ }
+ }
+
+ private boolean isAvatarPreviewerEnabled() {
+ return UserObject.isUserSelf(currentUser) || (currentChat != null && (!ChatObject.isChannel(currentChat) || currentChat.megagroup));
+ }
+
+ @Override
+ public void didPressBotButton(ChatMessageCell cell, TLRPC.KeyboardButton button) {
+ if (getParentActivity() == null || bottomOverlayChat.getVisibility() == View.VISIBLE &&
+ !(button instanceof TLRPC.TL_keyboardButtonSwitchInline) && !(button instanceof TLRPC.TL_keyboardButtonCallback) &&
+ !(button instanceof TLRPC.TL_keyboardButtonGame) && !(button instanceof TLRPC.TL_keyboardButtonUrl) &&
+ !(button instanceof TLRPC.TL_keyboardButtonBuy) && !(button instanceof TLRPC.TL_keyboardButtonUrlAuth)) {
+ return;
+ }
+ chatActivityEnterView.didPressedBotButton(button, cell.getMessageObject(), cell.getMessageObject());
+ }
+
+ @Override
+ public void didPressReaction(ChatMessageCell cell, TLRPC.TL_reactionCount reaction) {
+ getSendMessagesHelper().sendReaction(cell.getMessageObject(), reaction.reaction, ChatActivity.this);
+ }
+
+ @Override
+ public void didPressVoteButtons(ChatMessageCell cell, ArrayList buttons, int showCount, int x, int y) {
+ if (showCount >= 0 || buttons.isEmpty()) {
if (getParentActivity() == null) {
return;
}
- if (chatActivityEnterView != null) {
- chatActivityEnterView.closeKeyboard();
- }
- MessageObject messageObject = cell.getMessageObject();
- if (chatMode == MODE_PINNED) {
- chatActivityDelegate.openReplyMessage(messageObject.getId());
- finishFragment();
- } else if ((UserObject.isReplyUser(currentUser) || UserObject.isUserSelf(currentUser)) && messageObject.messageOwner.fwd_from.saved_from_peer != null) {
- if (UserObject.isReplyUser(currentUser) && messageObject.messageOwner.reply_to != null && messageObject.messageOwner.reply_to.reply_to_top_id != 0) {
- openDiscussionMessageChat(messageObject.messageOwner.reply_to.reply_to_peer_id.channel_id, null, messageObject.messageOwner.reply_to.reply_to_top_id, 0, -1, messageObject.messageOwner.fwd_from.saved_from_msg_id, messageObject);
- } else {
- openOriginalReplyChat(messageObject);
- }
- } else {
- ArrayList arrayList = null;
- if (messageObject.getGroupId() != 0) {
- MessageObject.GroupedMessages groupedMessages = groupedMessagesMap.get(messageObject.getGroupId());
- if (groupedMessages != null) {
- arrayList = groupedMessages.messages;
- }
- }
- if (arrayList == null) {
- arrayList = new ArrayList<>();
- arrayList.add(messageObject);
- }
- showDialog(new ShareAlert(mContext, ChatActivity.this, arrayList, null, null, ChatObject.isChannel(currentChat), null, null, false, false, themeDelegate) {
- @Override
- public void dismissInternal() {
- super.dismissInternal();
- AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
- if (chatActivityEnterView.getVisibility() == View.VISIBLE) {
- fragmentView.requestLayout();
- }
- }
-
- @Override
- protected void onSend(LongSparseArray dids, int count) {
- if (dids.size() == 1) {
- undoView.showWithAction(dids.valueAt(0).id, UndoView.ACTION_FWD_MESSAGES, count);
- } else {
- undoView.showWithAction(0, UndoView.ACTION_FWD_MESSAGES, count, dids.size(), null, null);
- }
- }
- });
- AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
- fragmentView.requestLayout();
- }
- }
-
- @Override
- public boolean needPlayMessage(MessageObject messageObject) {
- if (messageObject.isVoice() || messageObject.isRoundVideo()) {
- boolean result = MediaController.getInstance().playMessage(messageObject);
- MediaController.getInstance().setVoiceMessagesPlaylist(result ? createVoiceMessagesPlaylist(messageObject, false) : null, false);
- return result;
- } else if (messageObject.isMusic()) {
- return MediaController.getInstance().setPlaylist(messages, messageObject, mergeDialogId);
- }
- return false;
- }
-
- @Override
- public void videoTimerReached() {
- showNoSoundHint();
- }
-
- @Override
- public void didPressTime(ChatMessageCell cell) {
- undoView.showWithAction(dialog_id, UndoView.ACTION_IMPORT_INFO, null);
- }
-
- @Override
- public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
- if (chat == null) {
- return;
- }
- if (actionBar.isActionModeShowed() || reportType >= 0) {
- processRowSelect(cell, true, touchX, touchY);
- return;
- }
- openChat(cell, chat, postId);
- }
-
- @Override
- public void didPressHiddenForward(ChatMessageCell cell) {
- if (cell.getMessageObject().isImportedForward()) {
- didPressTime(cell);
- return;
- }
- showForwardHint(cell);
- }
-
- @Override
- public void didPressOther(ChatMessageCell cell, float otherX, float otherY) {
- MessageObject messageObject = cell.getMessageObject();
- if (messageObject.type == 16) {
- if (currentUser != null) {
- VoIPHelper.startCall(currentUser, messageObject.isVideoCall(), userInfo != null && userInfo.video_calls_available, getParentActivity(), getMessagesController().getUserFull(currentUser.id), getAccountInstance());
- }
- } else {
- createMenu(cell, true, false, otherX, otherY, messageObject.isMusic());
- }
- }
-
- @Override
- public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
- if (actionBar.isActionModeShowed() || reportType >= 0) {
- processRowSelect(cell, true, touchX, touchY);
- return;
- }
- openProfile(user);
- }
-
- @Override
- public boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
- if (isAvatarPreviewerEnabled()) {
- final boolean enableMention = currentChat != null && (bottomOverlayChat == null || bottomOverlayChat.getVisibility() != View.VISIBLE) && (bottomOverlay == null || bottomOverlay.getVisibility() != View.VISIBLE);
- final AvatarPreviewer.MenuItem[] menuItems = new AvatarPreviewer.MenuItem[2 + (enableMention ? 1 : 0)];
- menuItems[0] = AvatarPreviewer.MenuItem.OPEN_PROFILE;
- menuItems[1] = AvatarPreviewer.MenuItem.SEND_MESSAGE;
- if (enableMention) {
- menuItems[2] = AvatarPreviewer.MenuItem.MENTION;
- }
- final TLRPC.UserFull userFull = getMessagesController().getUserFull(user.id);
- final AvatarPreviewer.Data data;
- if (userFull != null) {
- data = AvatarPreviewer.Data.of(userFull, menuItems);
- } else {
- data = AvatarPreviewer.Data.of(user, classGuid, menuItems);
- }
- if (AvatarPreviewer.canPreview(data)) {
- AvatarPreviewer.getInstance().show((ViewGroup) fragmentView, data, item -> {
- switch (item) {
- case SEND_MESSAGE:
- openDialog(cell, user);
- break;
- case OPEN_PROFILE:
- openProfile(user);
- break;
- case MENTION:
- appendMention(user);
- break;
- }
- });
- return true;
- }
- }
- return false;
- }
-
- private void appendMention(TLRPC.User user) {
- if (chatActivityEnterView != null) {
- final SpannableStringBuilder sb = new SpannableStringBuilder();
- final CharSequence text = chatActivityEnterView.getFieldText();
- if (text != null) {
- sb.append(text);
- }
- if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') {
- sb.append(' ');
- }
- if (user.username != null) {
- sb.append("@").append(user.username).append(" ");
- } else {
- String name = UserObject.getFirstName(user, false);
- Spannable spannable = new SpannableString(name + " ");
- spannable.setSpan(new URLSpanUserMention("" + user.id, 3), 0, spannable.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- sb.append(spannable);
- }
- chatActivityEnterView.setFieldText(sb);
- AndroidUtilities.runOnUIThread(() -> chatActivityEnterView.openKeyboard(), 200);
- }
- }
-
- @Override
- public boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
- if (isAvatarPreviewerEnabled()) {
- AvatarPreviewer.MenuItem[] menuItems = {AvatarPreviewer.MenuItem.OPEN_PROFILE};
- if (currentChat == null || currentChat.id != chat.id || isThreadChat()) {
- menuItems = Arrays.copyOf(menuItems, 2);
- menuItems[1] = chat.broadcast ? AvatarPreviewer.MenuItem.OPEN_CHANNEL : AvatarPreviewer.MenuItem.OPEN_GROUP;
- }
- final TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chat.id);
- final AvatarPreviewer.Data data;
- if (chatFull != null) {
- data = AvatarPreviewer.Data.of(chat, chatFull, menuItems);
- } else {
- data = AvatarPreviewer.Data.of(chat, classGuid, menuItems);
- }
- if (AvatarPreviewer.canPreview(data)) {
- AvatarPreviewer.getInstance().show((ViewGroup) fragmentView, data, item -> {
- switch (item) {
- case OPEN_PROFILE:
- openProfile(chat);
- break;
- case OPEN_GROUP:
- case OPEN_CHANNEL:
- openChat(cell, chat, 0);
- break;
- }
- });
- return true;
- }
- }
- return false;
- }
-
- private void openProfile(TLRPC.User user) {
- if (user != null && user.id != getUserConfig().getClientUserId()) {
- Bundle args = new Bundle();
- args.putLong("user_id", user.id);
- ProfileActivity fragment = new ProfileActivity(args);
- fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id ? 1 : 0);
- AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
- presentFragment(fragment);
- }
- }
-
- private void openProfile(TLRPC.Chat chat) {
- if (chat != null) {
- Bundle args = new Bundle();
- args.putLong("chat_id", chat.id);
- presentFragment(new ProfileActivity(args));
- }
- }
-
- private void openDialog(ChatMessageCell cell, TLRPC.User user) {
- if (user != null) {
- Bundle args = new Bundle();
- args.putLong("user_id", user.id);
- if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject())) {
- presentFragment(new ChatActivity(args));
- }
- }
- }
-
- private void openChat(ChatMessageCell cell, TLRPC.Chat chat, int postId) {
- if (currentChat != null && chat.id == currentChat.id) {
- scrollToMessageId(postId, cell.getMessageObject().getId(), true, 0, true, 0);
- } else if (currentChat == null || chat.id != currentChat.id || isThreadChat()) {
- Bundle args = new Bundle();
- args.putLong("chat_id", chat.id);
- if (postId != 0) {
- args.putInt("message_id", postId);
- }
- if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject())) {
- presentFragment(new ChatActivity(args));
- }
- }
- }
-
- private boolean isAvatarPreviewerEnabled() {
- return UserObject.isUserSelf(currentUser) || (currentChat != null && (!ChatObject.isChannel(currentChat) || currentChat.megagroup));
- }
-
- @Override
- public void didPressBotButton(ChatMessageCell cell, TLRPC.KeyboardButton button) {
- if (getParentActivity() == null || bottomOverlayChat.getVisibility() == View.VISIBLE &&
- !(button instanceof TLRPC.TL_keyboardButtonSwitchInline) && !(button instanceof TLRPC.TL_keyboardButtonCallback) &&
- !(button instanceof TLRPC.TL_keyboardButtonGame) && !(button instanceof TLRPC.TL_keyboardButtonUrl) &&
- !(button instanceof TLRPC.TL_keyboardButtonBuy) && !(button instanceof TLRPC.TL_keyboardButtonUrlAuth)) {
- return;
- }
- chatActivityEnterView.didPressedBotButton(button, cell.getMessageObject(), cell.getMessageObject());
- }
-
- @Override
- public void didPressReaction(ChatMessageCell cell, TLRPC.TL_reactionCount reaction) {
- getSendMessagesHelper().sendReaction(cell.getMessageObject(), reaction.reaction, ChatActivity.this);
- }
-
- @Override
- public void didPressVoteButtons(ChatMessageCell cell, ArrayList buttons, int showCount, int x, int y) {
- if (showCount >= 0 || buttons.isEmpty()) {
- if (getParentActivity() == null) {
+ if (pollHintView == null) {
+ pollHintView = new HintView(getParentActivity(), HintView.TYPE_POLL_VOTE, themeDelegate);
+ pollHintView.setAlpha(0.0f);
+ pollHintView.setVisibility(View.INVISIBLE);
+ int index = contentView.indexOfChild(chatActivityEnterView);
+ if (index == -1) {
return;
}
- if (pollHintView == null) {
- pollHintView = new HintView(getParentActivity(), HintView.TYPE_POLL_VOTE, themeDelegate);
- pollHintView.setAlpha(0.0f);
- pollHintView.setVisibility(View.INVISIBLE);
- int index = contentView.indexOfChild(chatActivityEnterView);
- if (index == -1) {
- return;
- }
- contentView.addView(pollHintView, index + 1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
- }
- if (buttons.isEmpty() && showCount < 0) {
- ArrayList pollButtons = cell.getPollButtons();
- float lastDiff = 0;
- for (int a = 0, N = pollButtons.size(); a < N; a++) {
- ChatMessageCell.PollButton button = pollButtons.get(a);
- lastDiff = cell.getY() + button.y - AndroidUtilities.dp(4) - chatListViewPaddingTop;
- pollHintX = button.x + AndroidUtilities.dp(13.3f);
- pollHintY = button.y - AndroidUtilities.dp(6) + y;
- if (lastDiff > 0) {
- lastDiff = 0;
- x = pollHintX;
- y = pollHintY;
- break;
- }
- }
- if (lastDiff != 0) {
- chatListView.smoothScrollBy(0, (int) lastDiff);
- pollHintCell = cell;
- return;
+ contentView.addView(pollHintView, index + 1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
+ }
+ if (buttons.isEmpty() && showCount < 0) {
+ ArrayList pollButtons = cell.getPollButtons();
+ float lastDiff = 0;
+ for (int a = 0, N = pollButtons.size(); a < N; a++) {
+ ChatMessageCell.PollButton button = pollButtons.get(a);
+ lastDiff = cell.getY() + button.y - AndroidUtilities.dp(4) - chatListViewPaddingTop;
+ pollHintX = button.x + AndroidUtilities.dp(13.3f);
+ pollHintY = button.y - AndroidUtilities.dp(6) + y;
+ if (lastDiff > 0) {
+ lastDiff = 0;
+ x = pollHintX;
+ y = pollHintY;
+ break;
}
}
- pollHintView.showForMessageCell(cell, showCount, x, y, true);
- } else {
- getSendMessagesHelper().sendVote(cell.getMessageObject(), buttons, null);
+ if (lastDiff != 0) {
+ chatListView.smoothScrollBy(0, (int) lastDiff);
+ pollHintCell = cell;
+ return;
+ }
}
+ pollHintView.showForMessageCell(cell, showCount, x, y, true);
+ } else {
+ getSendMessagesHelper().sendVote(cell.getMessageObject(), buttons, null);
}
+ }
- @Override
- public void didPressCancelSendButton(ChatMessageCell cell) {
- MessageObject message = cell.getMessageObject();
- if (message.messageOwner.send_state != 0) {
- getSendMessagesHelper().cancelSendingMessage(message);
- }
+ @Override
+ public void didPressCancelSendButton(ChatMessageCell cell) {
+ MessageObject message = cell.getMessageObject();
+ if (message.messageOwner.send_state != 0) {
+ getSendMessagesHelper().cancelSendingMessage(message);
}
+ }
- @Override
- public void didLongPress(ChatMessageCell cell, float x, float y) {
+ @Override
+ public void didLongPress(ChatMessageCell cell, float x, float y) {
+ createMenu(cell, false, false, x, y);
+ startMultiselect(chatListView.getChildAdapterPosition(cell));
+ }
+
+ @Override
+ public boolean canPerformActions() {
+ return actionBar != null && !actionBar.isActionModeShowed() && reportType < 0 || inPreviewMode;
+ }
+
+ @Override
+ public void didPressUrl(ChatMessageCell cell, final CharacterStyle url, boolean longPress) {
+ didPressMessageUrl(url, longPress, cell.getMessageObject(), cell);
+ }
+
+ @Override
+ public void needOpenWebView(MessageObject message, String url, String title, String description, String originalUrl, int w, int h) {
+ try {
+ EmbedBottomSheet.show(getParentActivity(), message, photoViewerProvider, title, description, originalUrl, url, w, h, isKeyboardVisible());
+ } catch (Throwable e) {
+ FileLog.e(e);
+ }
+ }
+
+ @Override
+ public void didPressReplyMessage(ChatMessageCell cell, int id) {
+ if (UserObject.isReplyUser(currentUser)) {
+ didPressSideButton(cell);
+ return;
+ }
+ MessageObject messageObject = cell.getMessageObject();
+ if (chatMode == MODE_PINNED || chatMode == MODE_SCHEDULED) {
+ chatActivityDelegate.openReplyMessage(id);
+ finishFragment();
+ } else {
+ scrollToMessageId(id, messageObject.getId(), true, messageObject.getDialogId() == mergeDialogId ? 1 : 0, true, 0);
+ }
+ }
+
+ @Override
+ public void didPressViaBot(ChatMessageCell cell, String username) {
+ if (bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE || bottomOverlay != null && bottomOverlay.getVisibility() == View.VISIBLE) {
+ return;
+ }
+ if (chatActivityEnterView != null && username != null && username.length() > 0) {
+ chatActivityEnterView.setFieldText("@" + username + " ");
+ chatActivityEnterView.openKeyboard();
+ }
+ }
+
+ @Override
+ public void didStartVideoStream(MessageObject message) {
+ if (message.isVideo()) {
+ sendSecretMessageRead(message, true);
+ }
+ }
+
+ @Override
+ public void needReloadPolls() {
+ invalidateMessagesVisiblePart();
+ }
+
+ @Override
+ public void didPressImage(ChatMessageCell cell, float x, float y) {
+ MessageObject message = cell.getMessageObject();
+ if (message.isSendError()) {
createMenu(cell, false, false, x, y);
- startMultiselect(chatListView.getChildAdapterPosition(cell));
+ return;
+ } else if (message.isSending()) {
+ return;
}
-
- @Override
- public boolean canPerformActions() {
- return actionBar != null && !actionBar.isActionModeShowed() && reportType < 0;
- }
-
- @Override
- public void didPressUrl(ChatMessageCell cell, final CharacterStyle url, boolean longPress) {
- didPressMessageUrl(url, longPress, cell.getMessageObject(), cell);
- }
-
- @Override
- public void needOpenWebView(MessageObject message, String url, String title, String description, String originalUrl, int w, int h) {
+ if (message.isDice()) {
+ undoView.showWithAction(0, chatActivityEnterView.getVisibility() == View.VISIBLE && bottomOverlay.getVisibility() != View.VISIBLE ? UndoView.ACTION_DICE_INFO : UndoView.ACTION_DICE_NO_SEND_INFO, message.getDiceEmoji(), null, () -> getSendMessagesHelper().sendMessage(message.getDiceEmoji(), dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0, null));
+ } else if (message.isAnimatedEmoji()) {
+ restartSticker(cell);
+ emojiAnimationsOverlay.onTapItem(cell, ChatActivity.this);
+ chatListView.cancelClickRunnables(false);
+ } else if (message.needDrawBluredPreview()) {
+ Runnable action = sendSecretMessageRead(message, false);
+ cell.invalidate();
+ SecretMediaViewer.getInstance().setParentActivity(getParentActivity());
+ SecretMediaViewer.getInstance().openMedia(message, photoViewerProvider, action);
+ } else if (message.getInputStickerSet() != null) {
+ StickersAlert alert = new StickersAlert(getParentActivity(), ChatActivity.this, message.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE && (currentChat == null || ChatObject.canSendStickers(currentChat)) ? chatActivityEnterView : null, themeDelegate);
+ alert.setCalcMandatoryInsets(isKeyboardVisible());
+ showDialog(alert);
+ } else if (message.isVideo() || message.type == 1 || message.type == 0 && !message.isWebpageDocument() || message.isGif()) {
+ openPhotoViewerForMessage(cell, message);
+ } else if (message.type == 3) {
+ sendSecretMessageRead(message, true);
try {
- EmbedBottomSheet.show(getParentActivity(), message, photoViewerProvider, title, description, originalUrl, url, w, h, isKeyboardVisible());
- } catch (Throwable e) {
+ File f = null;
+ if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
+ f = new File(message.messageOwner.attachPath);
+ }
+ if (f == null || !f.exists()) {
+ f = FileLoader.getPathToMessage(message.messageOwner);
+ }
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ if (Build.VERSION.SDK_INT >= 24) {
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ intent.setDataAndType(FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", f), "video/mp4");
+ } else {
+ intent.setDataAndType(Uri.fromFile(f), "video/mp4");
+ }
+ getParentActivity().startActivityForResult(intent, 500);
+ } catch (Exception e) {
FileLog.e(e);
+ alertUserOpenError(message);
}
- }
-
- @Override
- public void didPressReplyMessage(ChatMessageCell cell, int id) {
- if (UserObject.isReplyUser(currentUser)) {
- didPressSideButton(cell);
+ } else if (message.type == 4) {
+ if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) {
return;
}
- MessageObject messageObject = cell.getMessageObject();
- if (chatMode == MODE_PINNED || chatMode == MODE_SCHEDULED) {
- chatActivityDelegate.openReplyMessage(id);
- finishFragment();
+ if (message.isLiveLocation()) {
+ LocationActivity fragment = new LocationActivity(currentChat == null || ChatObject.canSendMessages(currentChat) || currentChat.megagroup ? 2 : LocationActivity.LOCATION_TYPE_LIVE_VIEW);
+ fragment.setDelegate(ChatActivity.this);
+ fragment.setMessageObject(message);
+ presentFragment(fragment);
} else {
- scrollToMessageId(id, messageObject.getId(), true, messageObject.getDialogId() == mergeDialogId ? 1 : 0, true, 0);
+ LocationActivity fragment = new LocationActivity(currentEncryptedChat == null ? 3 : 0);
+ fragment.setDelegate(ChatActivity.this);
+ fragment.setMessageObject(message);
+ presentFragment(fragment);
}
- }
-
- @Override
- public void didPressViaBot(ChatMessageCell cell, String username) {
- if (bottomOverlayChat != null && bottomOverlayChat.getVisibility() == View.VISIBLE || bottomOverlay != null && bottomOverlay.getVisibility() == View.VISIBLE) {
- return;
+ } else if (message.type == 9 || message.type == 0) {
+ if (message.getDocumentName().toLowerCase().endsWith("attheme")) {
+ File locFile = null;
+ if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
+ File f = new File(message.messageOwner.attachPath);
+ if (f.exists()) {
+ locFile = f;
+ }
+ }
+ if (locFile == null) {
+ File f = FileLoader.getPathToMessage(message.messageOwner);
+ if (f.exists()) {
+ locFile = f;
+ }
+ }
+ Theme.ThemeInfo themeInfo = Theme.applyThemeFile(locFile, message.getDocumentName(), null, true);
+ if (themeInfo != null) {
+ presentFragment(new ThemePreviewActivity(themeInfo));
+ return;
+ } else {
+ scrollToPositionOnRecreate = -1;
+ }
}
- if (chatActivityEnterView != null && username != null && username.length() > 0) {
- chatActivityEnterView.setFieldText("@" + username + " ");
- chatActivityEnterView.openKeyboard();
+ boolean handled = false;
+ if (message.canPreviewDocument()) {
+ PhotoViewer.getInstance().setParentActivity(getParentActivity(), themeDelegate);
+ PhotoViewer.getInstance().openPhoto(message, ChatActivity.this, message.type != 0 ? dialog_id : 0, message.type != 0 ? mergeDialogId : 0, photoViewerProvider);
+ handled = true;
}
- }
-
- @Override
- public void didStartVideoStream(MessageObject message) {
- if (message.isVideo()) {
- sendSecretMessageRead(message, true);
- }
- }
-
- @Override
- public void needReloadPolls() {
- invalidateMessagesVisiblePart();
- }
-
- @Override
- public void didPressImage(ChatMessageCell cell, float x, float y) {
- MessageObject message = cell.getMessageObject();
- if (message.isSendError()) {
- createMenu(cell, false, false, x, y);
- return;
- } else if (message.isSending()) {
- return;
- }
- if (message.isDice()) {
- undoView.showWithAction(0, chatActivityEnterView.getVisibility() == View.VISIBLE && bottomOverlay.getVisibility() != View.VISIBLE ? UndoView.ACTION_DICE_INFO : UndoView.ACTION_DICE_NO_SEND_INFO, message.getDiceEmoji(), null, () -> getSendMessagesHelper().sendMessage(message.getDiceEmoji(), dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0, null));
- } else if (message.isAnimatedEmoji()) {
- restartSticker(cell);
- emojiAnimationsOverlay.onTapItem(cell, ChatActivity.this);
- chatListView.cancelClickRunnables(false);
- } else if (message.needDrawBluredPreview()) {
- Runnable action = sendSecretMessageRead(message, false);
- cell.invalidate();
- SecretMediaViewer.getInstance().setParentActivity(getParentActivity());
- SecretMediaViewer.getInstance().openMedia(message, photoViewerProvider, action);
- } else if (message.getInputStickerSet() != null) {
- StickersAlert alert = new StickersAlert(getParentActivity(), ChatActivity.this, message.getInputStickerSet(), null, bottomOverlayChat.getVisibility() != View.VISIBLE && (currentChat == null || ChatObject.canSendStickers(currentChat)) ? chatActivityEnterView : null, themeDelegate);
- alert.setCalcMandatoryInsets(isKeyboardVisible());
- showDialog(alert);
- } else if (message.isVideo() || message.type == 1 || message.type == 0 && !message.isWebpageDocument() || message.isGif()) {
- openPhotoViewerForMessage(cell, message);
- } else if (message.type == 3) {
- sendSecretMessageRead(message, true);
+ if (!handled) {
try {
- File f = null;
- if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
- f = new File(message.messageOwner.attachPath);
- }
- if (f == null || !f.exists()) {
- f = FileLoader.getPathToMessage(message.messageOwner);
- }
- Intent intent = new Intent(Intent.ACTION_VIEW);
- if (Build.VERSION.SDK_INT >= 24) {
- intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- intent.setDataAndType(FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", f), "video/mp4");
- } else {
- intent.setDataAndType(Uri.fromFile(f), "video/mp4");
- }
- getParentActivity().startActivityForResult(intent, 500);
+ AndroidUtilities.openForView(message, getParentActivity(), themeDelegate);
} catch (Exception e) {
FileLog.e(e);
alertUserOpenError(message);
}
- } else if (message.type == 4) {
- if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) {
- return;
- }
- if (message.isLiveLocation()) {
- LocationActivity fragment = new LocationActivity(currentChat == null || ChatObject.canSendMessages(currentChat) || currentChat.megagroup ? 2 : LocationActivity.LOCATION_TYPE_LIVE_VIEW);
- fragment.setDelegate(ChatActivity.this);
- fragment.setMessageObject(message);
- presentFragment(fragment);
+ }
+ }
+ }
+
+ @Override
+ public void didPressInstantButton(ChatMessageCell cell, int type) {
+ MessageObject messageObject = cell.getMessageObject();
+ if (type == 8) {
+ PollVotesAlert.showForPoll(ChatActivity.this, messageObject);
+ } else if (type == 0) {
+ if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.webpage != null && messageObject.messageOwner.media.webpage.cached_page != null) {
+ ArticleViewer.getInstance().setParentActivity(getParentActivity(), ChatActivity.this);
+ ArticleViewer.getInstance().open(messageObject);
+ }
+ } else if (type == 5) {
+ long uid = messageObject.messageOwner.media.user_id;
+ TLRPC.User user = null;
+ if (uid != 0) {
+ user = MessagesController.getInstance(currentAccount).getUser(uid);
+ }
+ openVCard(user, messageObject.messageOwner.media.vcard, messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name);
+ } else {
+ if (messageObject.isSponsored()) {
+ Bundle args = new Bundle();
+ long peerId = MessageObject.getPeerId(messageObject.messageOwner.from_id);
+ if (peerId < 0) {
+ args.putLong("chat_id", -peerId);
} else {
- LocationActivity fragment = new LocationActivity(currentEncryptedChat == null ? 3 : 0);
- fragment.setDelegate(ChatActivity.this);
- fragment.setMessageObject(message);
- presentFragment(fragment);
+ args.putLong("user_id", peerId);
}
- } else if (message.type == 9 || message.type == 0) {
- if (message.getDocumentName().toLowerCase().endsWith("attheme")) {
- File locFile = null;
- if (message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
- File f = new File(message.messageOwner.attachPath);
- if (f.exists()) {
- locFile = f;
- }
- }
- if (locFile == null) {
- File f = FileLoader.getPathToMessage(message.messageOwner);
- if (f.exists()) {
- locFile = f;
- }
- }
- Theme.ThemeInfo themeInfo = Theme.applyThemeFile(locFile, message.getDocumentName(), null, true);
- if (themeInfo != null) {
- presentFragment(new ThemePreviewActivity(themeInfo));
- return;
- } else {
- scrollToPositionOnRecreate = -1;
- }
+ if (messageObject.sponsoredChannelPost != 0) {
+ args.putInt("message_id", messageObject.sponsoredChannelPost);
}
- boolean handled = false;
- if (message.canPreviewDocument()) {
- PhotoViewer.getInstance().setParentActivity(getParentActivity(), themeDelegate);
- PhotoViewer.getInstance().openPhoto(message, ChatActivity.this, message.type != 0 ? dialog_id : 0, message.type != 0 ? mergeDialogId : 0, photoViewerProvider);
- handled = true;
+ if (messageObject.botStartParam != null) {
+ args.putString("inline_query", messageObject.botStartParam);
}
- if (!handled) {
- try {
- AndroidUtilities.openForView(message, getParentActivity(), themeDelegate);
- } catch (Exception e) {
- FileLog.e(e);
- alertUserOpenError(message);
- }
+ if (getMessagesController().checkCanOpenChat(args, ChatActivity.this)) {
+ presentFragment(new ChatActivity(args));
+ }
+ } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.webpage != null) {
+ if (!openLinkInternally(messageObject.messageOwner.media.webpage.url, messageObject.getId())) {
+ Browser.openUrl(getParentActivity(), messageObject.messageOwner.media.webpage.url);
}
}
}
+ }
- @Override
- public void didPressInstantButton(ChatMessageCell cell, int type) {
- MessageObject messageObject = cell.getMessageObject();
- if (type == 8) {
- PollVotesAlert.showForPoll(ChatActivity.this, messageObject);
- } else if (type == 0) {
- if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.webpage != null && messageObject.messageOwner.media.webpage.cached_page != null) {
- ArticleViewer.getInstance().setParentActivity(getParentActivity(), ChatActivity.this);
- ArticleViewer.getInstance().open(messageObject);
- }
- } else if (type == 5) {
- long uid = messageObject.messageOwner.media.user_id;
- TLRPC.User user = null;
- if (uid != 0) {
- user = MessagesController.getInstance(currentAccount).getUser(uid);
- }
- openVCard(user, messageObject.messageOwner.media.vcard, messageObject.messageOwner.media.first_name, messageObject.messageOwner.media.last_name);
- } else {
- if (messageObject.isSponsored()) {
- Bundle args = new Bundle();
- long peerId = MessageObject.getPeerId(messageObject.messageOwner.from_id);
- if (peerId < 0) {
- args.putLong("chat_id", -peerId);
- } else {
- args.putLong("user_id", peerId);
- }
- if (messageObject.sponsoredChannelPost != 0) {
- args.putInt("message_id", messageObject.sponsoredChannelPost);
- }
- if (messageObject.botStartParam != null) {
- args.putString("inline_query", messageObject.botStartParam);
- }
- if (getMessagesController().checkCanOpenChat(args, ChatActivity.this)) {
- presentFragment(new ChatActivity(args));
- }
- } else if (messageObject.messageOwner.media != null && messageObject.messageOwner.media.webpage != null) {
- if (!openLinkInternally(messageObject.messageOwner.media.webpage.url, messageObject.getId())) {
- Browser.openUrl(getParentActivity(), messageObject.messageOwner.media.webpage.url);
- }
- }
- }
+ @Override
+ public void didPressCommentButton(ChatMessageCell cell) {
+ MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
+ MessageObject message;
+ if (group != null && !group.messages.isEmpty()) {
+ message = group.messages.get(0);
+ } else {
+ message = cell.getMessageObject();
}
-
- @Override
- public void didPressCommentButton(ChatMessageCell cell) {
- MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
- MessageObject message;
- if (group != null && !group.messages.isEmpty()) {
- message = group.messages.get(0);
- } else {
- message = cell.getMessageObject();
- }
- int maxReadId;
- long linkedChatId;
- if (message.messageOwner.replies != null) {
- maxReadId = message.messageOwner.replies.read_max_id;
- linkedChatId = message.messageOwner.replies.channel_id;
- } else {
- maxReadId = -1;
- linkedChatId = 0;
- }
- openDiscussionMessageChat(currentChat.id, message, message.getId(), linkedChatId, maxReadId, 0, null);
+ int maxReadId;
+ long linkedChatId;
+ if (message.messageOwner.replies != null) {
+ maxReadId = message.messageOwner.replies.read_max_id;
+ linkedChatId = message.messageOwner.replies.channel_id;
+ } else {
+ maxReadId = -1;
+ linkedChatId = 0;
}
+ openDiscussionMessageChat(currentChat.id, message, message.getId(), linkedChatId, maxReadId, 0, null);
+ }
- @Override
- public String getAdminRank(long uid) {
- if (ChatObject.isChannel(currentChat) && currentChat.megagroup) {
- return getMessagesController().getAdminRank(currentChat.id, uid);
- }
- return null;
+ @Override
+ public String getAdminRank(long uid) {
+ if (ChatObject.isChannel(currentChat) && currentChat.megagroup) {
+ return getMessagesController().getAdminRank(currentChat.id, uid);
}
+ return null;
+ }
- @Override
- public boolean shouldRepeatSticker(MessageObject message) {
- return !alreadyPlayedStickers.containsKey(message);
+ @Override
+ public boolean shouldRepeatSticker(MessageObject message) {
+ return !alreadyPlayedStickers.containsKey(message);
+ }
+
+ @Override
+ public void setShouldNotRepeatSticker(MessageObject message) {
+ alreadyPlayedStickers.put(message, true);
+ }
+
+ @Override
+ public TextSelectionHelper.ChatListTextSelectionHelper getTextSelectionHelper() {
+ return textSelectionHelper;
+ }
+
+ @Override
+ public boolean hasSelectedMessages() {
+ return selectedMessagesIds[0].size() + selectedMessagesIds[1].size() > 0;
+ }
+
+ @Override
+ public void onDiceFinished() {
+ if (fireworksOverlay.isStarted()) {
+ return;
}
+ fireworksOverlay.start();
+ fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
+ }
- @Override
- public void setShouldNotRepeatSticker(MessageObject message) {
- alreadyPlayedStickers.put(message, true);
- }
+ @Override
+ public PinchToZoomHelper getPinchToZoomHelper() {
+ return pinchToZoomHelper;
+ }
- @Override
- public TextSelectionHelper.ChatListTextSelectionHelper getTextSelectionHelper() {
- return textSelectionHelper;
- }
+ @Override
+ public boolean keyboardIsOpened() {
+ return contentView.getKeyboardHeight() + chatEmojiViewPadding >= AndroidUtilities.dp(20);
+ }
- @Override
- public boolean hasSelectedMessages() {
- return selectedMessagesIds[0].size() + selectedMessagesIds[1].size() > 0;
- }
-
- @Override
- public void onDiceFinished() {
- if (fireworksOverlay.isStarted()) {
- return;
- }
- fireworksOverlay.start();
- fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
- }
-
- @Override
- public PinchToZoomHelper getPinchToZoomHelper() {
- return pinchToZoomHelper;
- }
-
- @Override
- public boolean keyboardIsOpened() {
- return contentView.getKeyboardHeight() + chatEmojiViewPadding >= AndroidUtilities.dp(20);
- }
-
- public boolean isLandscape() {
- return contentView.getMeasuredWidth() > contentView.getMeasuredHeight();
- }
- });
- } else {
- chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {
-
- });
- }
+ public boolean isLandscape() {
+ return contentView.getMeasuredWidth() > contentView.getMeasuredHeight();
+ }
+ });
if (currentEncryptedChat == null) {
chatMessageCell.setAllowAssistant(true);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
index bb5ae288c..91f3afe1d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
@@ -142,7 +142,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
}
isPrivate = !isForcePublic && TextUtils.isEmpty(currentChat.username);
isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
- isSaveRestricted = isPrivate && currentChat.noforwards;
+ isSaveRestricted = currentChat.noforwards;
if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) {
TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
req.username = "1";
@@ -470,7 +470,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
}
private void processDone() {
- if (isPrivate && currentChat.noforwards != isSaveRestricted) {
+ if (currentChat.noforwards != isSaveRestricted) {
getMessagesController().toggleChatNoForwards(chatId, currentChat.noforwards = isSaveRestricted);
}
if (trySetUsername()) {
@@ -616,7 +616,7 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
}
publicContainer.setVisibility(isPrivate ? View.GONE : View.VISIBLE);
privateContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
- saveContainer.setVisibility(isPrivate ? View.VISIBLE : View.GONE);
+ saveContainer.setVisibility(View.VISIBLE);
manageLinksTextView.setVisibility(View.VISIBLE);
manageLinksInfoCell.setVisibility(View.VISIBLE);
linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
index c1c4edc23..facb40b26 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
@@ -4130,6 +4130,7 @@ public class AlertsCreator {
final boolean[] checks = new boolean[3];
final boolean[] deleteForAll = new boolean[1];
TLRPC.User actionUser = null;
+ TLRPC.Chat actionChat = null;
boolean canRevokeInbox = user != null && MessagesController.getInstance(currentAccount).canRevokePmInbox;
int revokeTimeLimit;
if (user != null) {
@@ -4148,7 +4149,13 @@ public class AlertsCreator {
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser ||
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink ||
selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
- actionUser = MessagesController.getInstance(currentAccount).getUser(selectedMessage.messageOwner.from_id.user_id);
+ if (selectedMessage.messageOwner.from_id.user_id != 0) {
+ actionUser = MessagesController.getInstance(currentAccount).getUser(selectedMessage.messageOwner.from_id.user_id);
+ } else if (selectedMessage.messageOwner.from_id.channel_id != 0) {
+ actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.channel_id);
+ } else if (selectedMessage.messageOwner.from_id.chat_id != 0) {
+ actionChat = MessagesController.getInstance(currentAccount).getChat(selectedMessage.messageOwner.from_id.chat_id);
+ }
}
boolean hasOutgoing = !selectedMessage.isSendError() && selectedMessage.getDialogId() == mergeDialogId && (selectedMessage.messageOwner.action == null || selectedMessage.messageOwner.action instanceof TLRPC.TL_messageActionEmpty) && selectedMessage.isOut() && (currentDate - selectedMessage.messageOwner.date) <= revokeTimeLimit;
if (hasOutgoing) {
@@ -4188,8 +4195,8 @@ public class AlertsCreator {
actionUser = MessagesController.getInstance(currentAccount).getUser(from_id);
}
}
- if (actionUser != null && actionUser.id != UserConfig.getInstance(currentAccount).getClientUserId()) {
- if (loadParticipant == 1 && !chat.creator) {
+ if ((actionUser != null && actionUser.id != UserConfig.getInstance(currentAccount).getClientUserId()) || (actionChat != null && !ChatObject.hasAdminRights(actionChat))) {
+ if (loadParticipant == 1 && !chat.creator && actionUser != null) {
final AlertDialog[] progressDialog = new AlertDialog[]{new AlertDialog(activity, 3)};
TLRPC.TL_channels_getParticipant req = new TLRPC.TL_channels_getParticipant();
@@ -4224,6 +4231,7 @@ public class AlertsCreator {
}
FrameLayout frameLayout = new FrameLayout(activity);
int num = 0;
+ String name = actionUser != null ? ContactsController.formatName(actionUser.first_name, actionUser.last_name) : actionChat.title;
for (int a = 0; a < 3; a++) {
if ((loadParticipant == 2 || !canBan) && a == 0) {
continue;
@@ -4236,7 +4244,7 @@ public class AlertsCreator {
} else if (a == 1) {
cell.setText(LocaleController.getString("DeleteReportSpam", R.string.DeleteReportSpam), "", false, false);
} else {
- cell.setText(LocaleController.formatString("DeleteAllFrom", R.string.DeleteAllFrom, ContactsController.formatName(actionUser.first_name, actionUser.last_name)), "", false, false);
+ cell.setText(LocaleController.formatString("DeleteAllFrom", R.string.DeleteAllFrom, name), "", false, false);
}
cell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
frameLayout.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.TOP | Gravity.LEFT, 0, 48 * num, 0, 0));
@@ -4335,6 +4343,7 @@ public class AlertsCreator {
}
}
final TLRPC.User userFinal = actionUser;
+ final TLRPC.Chat chatFinal = actionChat;
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
ArrayList ids = null;
if (selectedMessage != null) {
@@ -4386,21 +4395,25 @@ public class AlertsCreator {
selectedMessages[a].clear();
}
}
- if (userFinal != null) {
+ if (userFinal != null || chatFinal != null) {
if (checks[0]) {
- MessagesController.getInstance(currentAccount).deleteParticipantFromChat(chat.id, userFinal, chatInfo);
+ MessagesController.getInstance(currentAccount).deleteParticipantFromChat(chat.id, userFinal, chatFinal, chatInfo, false, false);
}
if (checks[1]) {
TLRPC.TL_channels_reportSpam req = new TLRPC.TL_channels_reportSpam();
req.channel = MessagesController.getInputChannel(chat);
- req.user_id = MessagesController.getInstance(currentAccount).getInputUser(userFinal);
+ if (userFinal != null) {
+ req.participant = MessagesController.getInputPeer(userFinal);
+ } else {
+ req.participant = MessagesController.getInputPeer(chatFinal);
+ }
req.id = ids;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
});
}
if (checks[2]) {
- MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, 0);
+ MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, chatFinal, 0);
}
}
if (onDelete != null) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
index 82eccf8c0..b2d2b9c5d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
@@ -4659,7 +4659,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
messageEditText.setAlpha(1f);
messageEditText.setTranslationX(0);
messageEditText.requestFocus();
- updateSendAsButton();
}
});
@@ -6816,7 +6815,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
}
boolean wasVisible = senderSelectView.getVisibility() == View.VISIBLE;
- boolean isVisible = delegate.getSendAsPeers() != null && defPeer != null && delegate.getSendAsPeers().peers.size() > 1 && !isEditingMessage() && !isRecordingAudioVideo() && (recordedAudioPanel == null || recordedAudioPanel.getVisibility() == View.GONE);
+ boolean isVisible = delegate.getSendAsPeers() != null && defPeer != null && delegate.getSendAsPeers().peers.size() > 1 && !isEditingMessage() && !isRecordingAudioVideo();
int pad = AndroidUtilities.dp(2);
MarginLayoutParams params = (MarginLayoutParams) senderSelectView.getLayoutParams();
float sA = isVisible ? 0 : 1;
@@ -6832,8 +6831,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
if (parentFragment.getOtherSameChatsDiff() == 0 && parentFragment.fragmentOpened) {
- ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(220);
- anim.setInterpolator(CubicBezierInterpolator.DEFAULT);
+ ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
anim.addUpdateListener(animation -> {
float val = (float) animation.getAnimatedValue();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java
index 6c6f4bdcf..2dcd18693 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java
@@ -336,13 +336,13 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
ListItem item = (ListItem) object;
File file = item.file;
boolean isExternalStorageManager = false;
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
-// isExternalStorageManager = Environment.isExternalStorageManager();
-// }
- if (!BuildVars.NO_SCOPED_STORAGE && (item.icon == R.drawable.files_storage || item.icon == R.drawable.files_internal)) {
- //if (SharedConfig.dontAskManageStorage) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ isExternalStorageManager = Environment.isExternalStorageManager();
+ }
+ if (!BuildVars.NO_SCOPED_STORAGE && (item.icon == R.drawable.files_storage || item.icon == R.drawable.files_internal) && !isExternalStorageManager) {
+ if (SharedConfig.dontAskManageStorage) {
delegate.startDocumentSelectActivity();
- /*} else {
+ } else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTopImage(R.drawable.doc_big, Theme.getColor(Theme.key_dialogTopBackground));
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("ManageAllFilesRational", R.string.ManageAllFilesRational)));
@@ -368,7 +368,7 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
delegate.startDocumentSelectActivity();
});
builder.show();
- }*/
+ }
} else if (file == null) {
if (item.icon == R.drawable.files_gallery) {
HashMap