diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index 0d40f1db6..ffa573f55 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -67,9 +67,7 @@
-
-
-
+
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
index 4d236416d..fa1c171c6 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
@@ -38,7 +38,6 @@ import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
-import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
@@ -48,12 +47,6 @@ import android.provider.CallLog;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.provider.Settings;
-
-import androidx.core.content.FileProvider;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.viewpager.widget.ViewPager;
-
import android.telephony.TelephonyManager;
import android.text.Layout;
import android.text.Selection;
@@ -72,8 +65,8 @@ import android.util.StateSet;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.Display;
-import android.view.MotionEvent;
import android.view.Gravity;
+import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -95,8 +88,12 @@ import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
+import androidx.core.content.FileProvider;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.viewpager.widget.ViewPager;
+
import com.android.internal.telephony.ITelephony;
-import com.google.android.exoplayer2.util.Log;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.auth.api.phone.SmsRetrieverClient;
import com.google.android.gms.tasks.Task;
@@ -2254,6 +2251,10 @@ public class AndroidUtilities {
}
+ public static void appCenterLog(Throwable e) {
+
+ }
+
public static void addToClipboard(CharSequence str) {
try {
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
index 524e5ef94..ae6a40c46 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
@@ -15,16 +15,22 @@ import android.os.Build;
public class BuildVars {
public static boolean DEBUG_VERSION = false;
- public static boolean DEBUG_PRIVATE_VERSION = false;
public static boolean LOGS_ENABLED = false;
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 = 2470;
- public static String BUILD_VERSION_STRING = "8.2.7";
+ public static int BUILD_VERSION = 2493;
+ public static String BUILD_VERSION_STRING = "8.3.0";
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/ChatObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
index 8455dc42b..60b0a33e1 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
@@ -1478,6 +1478,10 @@ public class ChatObject {
return chat == null || chat instanceof TLRPC.TL_chatEmpty || chat instanceof TLRPC.TL_chatForbidden || chat instanceof TLRPC.TL_channelForbidden || chat.left || chat.kicked || chat.deactivated;
}
+ public static boolean canSendAsPeers(TLRPC.Chat chat) {
+ return ChatObject.isChannel(chat) && chat.megagroup && (!TextUtils.isEmpty(chat.username) || chat.has_geo || chat.has_link);
+ }
+
public static boolean isChannel(TLRPC.Chat chat) {
return chat instanceof TLRPC.TL_channel || chat instanceof TLRPC.TL_channelForbidden;
}
@@ -1551,6 +1555,21 @@ public class ChatObject {
return chat != null && chat.admin_rights != null && chat.admin_rights.anonymous;
}
+ public static long getSendAsPeerId(TLRPC.Chat chat, TLRPC.ChatFull chatFull) {
+ return getSendAsPeerId(chat, chatFull, false);
+ }
+
+ public static long getSendAsPeerId(TLRPC.Chat chat, TLRPC.ChatFull chatFull, boolean invertChannel) {
+ if (chat != null && chatFull != null && chatFull.default_send_as != null) {
+ TLRPC.Peer p = chatFull.default_send_as;
+ return p.user_id != 0 ? p.user_id : invertChannel ? -p.channel_id : p.channel_id;
+ }
+ if (chat != null && chat.admin_rights != null && chat.admin_rights.anonymous) {
+ return invertChannel ? -chat.id : chat.id;
+ }
+ return UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId();
+ }
+
public static boolean canAddBotsToChat(TLRPC.Chat chat) {
if (isChannel(chat)) {
if (chat.megagroup && (chat.admin_rights != null && (chat.admin_rights.post_messages || chat.admin_rights.add_admins) || chat.creator)) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java
index 42a2f774b..9a5d37123 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatThemeController.java
@@ -25,7 +25,6 @@ public class ChatThemeController extends BaseController {
private static final long reloadTimeoutMs = 2 * 60 * 60 * 1000;
public static volatile DispatchQueue chatThemeQueue = new DispatchQueue("chatThemeQueue");
- //private static final HashMap themeIdWallpaperMap = new HashMap<>();
private static final HashMap themeIdWallpaperThumbMap = new HashMap<>();
private static List allChatThemes;
private static volatile long themesHash;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
index d91a002fe..239cdd71f 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java
@@ -11,6 +11,7 @@ package org.telegram.messenger;
import android.util.Log;
import org.telegram.messenger.time.FastDateFormat;
+import org.telegram.messenger.video.MediaCodecVideoConvertor;
import java.io.File;
import java.io.FileOutputStream;
@@ -158,9 +159,16 @@ public class FileLog {
}
public static void e(final Throwable e) {
+ e(e, true);
+ }
+
+ public static void e(final Throwable e, boolean logToAppCenter) {
if (!BuildVars.LOGS_ENABLED) {
return;
}
+ if (BuildVars.DEBUG_VERSION && needSent(e)) {
+ AndroidUtilities.appCenterLog(e);
+ }
ensureInitied();
e.printStackTrace();
if (getInstance().streamWriter != null) {
@@ -181,6 +189,13 @@ public class FileLog {
}
}
+ private static boolean needSent(Throwable e) {
+ if (e instanceof InterruptedException || e instanceof MediaCodecVideoConvertor.ConversionCanceledException) {
+ return false;
+ }
+ return true;
+ }
+
public static void d(final String message) {
if (!BuildVars.LOGS_ENABLED) {
return;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
index fdbaca2a2..5d041f190 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
@@ -407,7 +407,7 @@ public class ImageLoader {
} else if (e instanceof FileNotFoundException) {
canRetry = false;
}
- FileLog.e(e);
+ FileLog.e(e, false);
} finally {
try {
if (httpConnection != null) {
@@ -521,20 +521,25 @@ public class ImageLoader {
fileOutputStream = new RandomAccessFile(cacheImage.tempFilePath, "rws");
}
} catch (Throwable e) {
+ boolean sentLogs = true;
if (e instanceof SocketTimeoutException) {
if (ApplicationLoader.isNetworkOnline()) {
canRetry = false;
}
+ sentLogs = false;
} else if (e instanceof UnknownHostException) {
canRetry = false;
+ sentLogs = false;
} else if (e instanceof SocketException) {
if (e.getMessage() != null && e.getMessage().contains("ECONNRESET")) {
canRetry = false;
}
+ sentLogs = false;
} else if (e instanceof FileNotFoundException) {
canRetry = false;
+ sentLogs = false;
}
- FileLog.e(e);
+ FileLog.e(e, sentLogs);
}
}
@@ -840,6 +845,7 @@ public class ImageLoader {
int autoRepeat = 1;
int[] colors = null;
String diceEmoji = null;
+ int fitzModifier = 0;
if (cacheImage.filter != null) {
String[] args = cacheImage.filter.split("_");
if (args.length >= 2) {
@@ -871,15 +877,15 @@ public class ImageLoader {
}
if (args.length >= 5) {
if ("c1".equals(args[4])) {
- colors = new int[]{0xf77e41, 0xcb7b55, 0xffb139, 0xf6b689, 0xffd140, 0xffcda7, 0xffdf79, 0xffdfc5};
+ fitzModifier = 12;
} else if ("c2".equals(args[4])) {
- colors = new int[]{0xf77e41, 0xa45a38, 0xffb139, 0xdf986b, 0xffd140, 0xedb183, 0xffdf79, 0xf4c3a0};
+ fitzModifier = 3;
} else if ("c3".equals(args[4])) {
- colors = new int[]{0xf77e41, 0x703a17, 0xffb139, 0xab673d, 0xffd140, 0xc37f4e, 0xffdf79, 0xd89667};
+ fitzModifier = 4;
} else if ("c4".equals(args[4])) {
- colors = new int[]{0xf77e41, 0x4a2409, 0xffb139, 0x7d3e0e, 0xffd140, 0x965529, 0xffdf79, 0xa96337};
+ fitzModifier = 5;
} else if ("c5".equals(args[4])) {
- colors = new int[]{0xf77e41, 0x200f0a, 0xffb139, 0x412924, 0xffd140, 0x593d37, 0xffdf79, 0x63453f};
+ fitzModifier = 6;
}
}
}
@@ -918,9 +924,9 @@ public class ImageLoader {
}
}
if (compressed) {
- lottieDrawable = new RLottieDrawable(cacheImage.finalFilePath, decompressGzip(cacheImage.finalFilePath), w, h, precache, limitFps, colors);
+ lottieDrawable = new RLottieDrawable(cacheImage.finalFilePath, decompressGzip(cacheImage.finalFilePath), w, h, precache, limitFps, null, fitzModifier);
} else {
- lottieDrawable = new RLottieDrawable(cacheImage.finalFilePath, w, h, precache, limitFps, colors);
+ lottieDrawable = new RLottieDrawable(cacheImage.finalFilePath, w, h, precache, limitFps, null, fitzModifier);
}
}
lottieDrawable.setAutoRepeat(autoRepeat);
@@ -1153,7 +1159,11 @@ public class ImageLoader {
}
}
} catch (Throwable e) {
- FileLog.e(e);
+ boolean sentLog = true;
+ if (e instanceof FileNotFoundException) {
+ sentLog = false;
+ }
+ FileLog.e(e, sentLog);
}
if (cacheImage.type == ImageReceiver.TYPE_THUMB) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
index e46091c38..05768b8d6 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
@@ -915,7 +915,7 @@ public class LocationController extends BaseController implements NotificationCe
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, fusedLocationListener);
googleApiClient.disconnect();
} catch (Throwable e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
}
locationManager.removeUpdates(gpsLocationListener);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
index 4a9cdd5da..0507a0f75 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
@@ -61,6 +61,7 @@ import android.widget.FrameLayout;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
+import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.audioinfo.AudioInfo;
import org.telegram.messenger.video.MediaCodecVideoConvertor;
@@ -3923,6 +3924,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
new Thread(() -> {
try {
+
boolean result = true;
if (Build.VERSION.SDK_INT >= 29) {
try {
@@ -3944,10 +3946,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
if (selectedType == 0) {
uriToInsert = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
- File dirDest = new File(Environment.DIRECTORY_PICTURES, "Telegram");
- contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
- }
+ File dirDest = new File(Environment.DIRECTORY_PICTURES, "Telegram");
+ contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, dirDest + File.separator);
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, AndroidUtilities.generateFileName(0, extension));
contentValues.put(MediaStore.Images.Media.MIME_TYPE, mimeType);
} else if (selectedType == 1) {
@@ -4823,6 +4823,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
MediaCodecVideoConvertor videoConvertor = new MediaCodecVideoConvertor();
boolean error = videoConvertor.convertVideo(videoPath, cacheFile,
rotationValue, isSecret,
+ originalWidth, originalHeight,
resultWidth, resultHeight,
framerate, bitrate, originalBitrate,
startTime, endTime, avatarStartTime,
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
index 043f319f0..cf06cdaa0 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
@@ -140,6 +140,8 @@ public class MediaDataController extends BaseController {
//igonre
}
}
+
+ loadStickersByEmojiOrName(AndroidUtilities.STICKERS_PLACEHOLDER_PACK_NAME, false, true);
}
public static final int TYPE_IMAGE = 0;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
index 4c8361665..90839e32b 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
@@ -1784,6 +1784,22 @@ public class MessageObject {
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite) {
TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite action = (TLRPC.TL_channelAdminLogEventActionParticipantJoinByInvite) event.action;
messageText = replaceWithLink(LocaleController.getString("ActionInviteUser", R.string.ActionInviteUser), "un1", fromUser);
+ } else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionToggleNoForwards) {
+ TLRPC.TL_channelAdminLogEventActionToggleNoForwards action = (TLRPC.TL_channelAdminLogEventActionToggleNoForwards) event.action;
+ boolean isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
+ if (action.new_value) {
+ if (isChannel) {
+ messageText = replaceWithLink(LocaleController.getString("ActionForwardsRestrictedChannel", R.string.ActionForwardsRestrictedChannel), "un1", fromUser);
+ } else {
+ messageText = replaceWithLink(LocaleController.getString("ActionForwardsRestrictedGroup", R.string.ActionForwardsRestrictedGroup), "un1", fromUser);
+ }
+ } else {
+ if (isChannel) {
+ messageText = replaceWithLink(LocaleController.getString("ActionForwardsEnabledChannel", R.string.ActionForwardsEnabledChannel), "un1", fromUser);
+ } else {
+ messageText = replaceWithLink(LocaleController.getString("ActionForwardsEnabledGroup", R.string.ActionForwardsEnabledGroup), "un1", fromUser);
+ }
+ }
} else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionExportedInviteDelete) {
TLRPC.TL_channelAdminLogEventActionExportedInviteDelete action = (TLRPC.TL_channelAdminLogEventActionExportedInviteDelete) event.action;
messageText = replaceWithLink(LocaleController.formatString("ActionDeletedInviteLinkClickable", R.string.ActionDeletedInviteLinkClickable), "un1", fromUser);
@@ -1841,6 +1857,9 @@ public class MessageObject {
messageText = replaceWithLink(LocaleController.getString("JoinedViaInviteLinkApproved", R.string.JoinedViaInviteLinkApproved), "un1", fromUser);
messageText = replaceWithLink(messageText, "un2", action.invite);
messageText = replaceWithLink(messageText, "un3", MessagesController.getInstance(currentAccount).getUser(action.approved_by));
+ } else if (event.action instanceof TLRPC.TL_channelAdminLogEventActionSendMessage) {
+ message = ((TLRPC.TL_channelAdminLogEventActionSendMessage) event.action).message;
+ messageText = replaceWithLink(LocaleController.getString("EventLogSendMessages", R.string.EventLogSendMessages), "un1", fromUser);
} else {
messageText = "unsupported " + event.action;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
index a1b7595da..3572033d7 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
@@ -21,7 +21,6 @@ import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
-import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
@@ -29,6 +28,8 @@ import android.util.SparseIntArray;
import androidx.collection.LongSparseArray;
import androidx.core.app.NotificationManagerCompat;
+import com.google.android.exoplayer2.util.Log;
+
import org.telegram.SQLite.SQLiteCursor;
import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.messenger.support.LongSparseLongArray;
@@ -41,6 +42,7 @@ import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.ActionBar.EmojiThemes;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.AlertsCreator;
@@ -54,6 +56,7 @@ import org.telegram.ui.ProfileActivity;
import org.telegram.ui.Components.SwipeGestureSettingsView;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -174,6 +177,7 @@ public class MessagesController extends BaseController implements NotificationCe
private SparseIntArray migratedChats = new SparseIntArray();
private LongSparseArray sponsoredMessages = new LongSparseArray<>();
+ private LongSparseArray sendAsPeers = new LongSparseArray<>();
private HashMap> reloadingWebpages = new HashMap<>();
private LongSparseArray> reloadingWebpagesPending = new LongSparseArray<>();
@@ -332,6 +336,12 @@ public class MessagesController extends BaseController implements NotificationCe
private boolean loading;
}
+ private class SendAsPeersInfo {
+ private TLRPC.TL_channels_sendAsPeers sendAsPeers;
+ private long loadTime;
+ private boolean loading;
+ }
+
public static class FaqSearchResult {
public String title;
@@ -469,16 +479,16 @@ public class MessagesController extends BaseController implements NotificationCe
public TLRPC.SendMessageAction action;
}
- public static int DIALOG_FILTER_FLAG_CONTACTS = 0x00000001;
- public static int DIALOG_FILTER_FLAG_NON_CONTACTS = 0x00000002;
- public static int DIALOG_FILTER_FLAG_GROUPS = 0x00000004;
- public static int DIALOG_FILTER_FLAG_CHANNELS = 0x00000008;
- public static int DIALOG_FILTER_FLAG_BOTS = 0x00000010;
- public static int DIALOG_FILTER_FLAG_EXCLUDE_MUTED = 0x00000020;
- public static int DIALOG_FILTER_FLAG_EXCLUDE_READ = 0x00000040;
- public static int DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED = 0x00000080;
- public static int DIALOG_FILTER_FLAG_ONLY_ARCHIVED = 0x00000100;
- public static int DIALOG_FILTER_FLAG_ALL_CHATS = DIALOG_FILTER_FLAG_CONTACTS | DIALOG_FILTER_FLAG_NON_CONTACTS | DIALOG_FILTER_FLAG_GROUPS | DIALOG_FILTER_FLAG_CHANNELS | DIALOG_FILTER_FLAG_BOTS;
+ public static int DIALOG_FILTER_FLAG_CONTACTS = 0x00000001;
+ public static int DIALOG_FILTER_FLAG_NON_CONTACTS = 0x00000002;
+ public static int DIALOG_FILTER_FLAG_GROUPS = 0x00000004;
+ public static int DIALOG_FILTER_FLAG_CHANNELS = 0x00000008;
+ public static int DIALOG_FILTER_FLAG_BOTS = 0x00000010;
+ public static int DIALOG_FILTER_FLAG_EXCLUDE_MUTED = 0x00000020;
+ public static int DIALOG_FILTER_FLAG_EXCLUDE_READ = 0x00000040;
+ public static int DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED = 0x00000080;
+ public static int DIALOG_FILTER_FLAG_ONLY_ARCHIVED = 0x00000100;
+ public static int DIALOG_FILTER_FLAG_ALL_CHATS = DIALOG_FILTER_FLAG_CONTACTS | DIALOG_FILTER_FLAG_NON_CONTACTS | DIALOG_FILTER_FLAG_GROUPS | DIALOG_FILTER_FLAG_CHANNELS | DIALOG_FILTER_FLAG_BOTS;
public static class DialogFilter {
public int id;
@@ -658,6 +668,7 @@ public class MessagesController extends BaseController implements NotificationCe
};
private static volatile MessagesController[] Instance = new MessagesController[UserConfig.MAX_ACCOUNT_COUNT];
+
public static MessagesController getInstance(int num) {
MessagesController localInstance = Instance[num];
if (localInstance == null) {
@@ -1284,11 +1295,11 @@ public class MessagesController extends BaseController implements NotificationCe
}
TLRPC.TL_messages_getDialogFilters req = new TLRPC.TL_messages_getDialogFilters();
getConnectionsManager().sendRequest(req, (response, error) -> {
- if (response instanceof TLRPC.Vector) {
- getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response);
- } else {
- AndroidUtilities.runOnUIThread(() -> loadingRemoteFilters = false);
- }
+ if (response instanceof TLRPC.Vector) {
+ getMessagesStorage().checkLoadedRemoteFilters((TLRPC.Vector) response);
+ } else {
+ AndroidUtilities.runOnUIThread(() -> loadingRemoteFilters = false);
+ }
});
}
@@ -1473,7 +1484,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
- case "autologin_domains" : {
+ case "autologin_domains": {
HashSet newDomains = new HashSet<>();
if (value.value instanceof TLRPC.TL_jsonArray) {
TLRPC.TL_jsonArray array = (TLRPC.TL_jsonArray) value.value;
@@ -1492,7 +1503,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
- case "autologin_token" : {
+ case "autologin_token": {
if (value.value instanceof TLRPC.TL_jsonString) {
TLRPC.TL_jsonString string = (TLRPC.TL_jsonString) value.value;
if (!string.value.equals(autologinToken)) {
@@ -2553,6 +2564,7 @@ public class MessagesController extends BaseController implements NotificationCe
reloadingScheduledWebpages.clear();
reloadingScheduledWebpagesPending.clear();
sponsoredMessages.clear();
+ sendAsPeers.clear();
dialogs_dict.clear();
dialogs_read_inbox_max.clear();
loadingPinnedDialogs.clear();
@@ -2702,6 +2714,20 @@ public class MessagesController extends BaseController implements NotificationCe
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
}
+ public boolean isChatNoForwards(TLRPC.Chat chat) {
+ if (chat == null) return false;
+ if (chat.migrated_to != null) {
+ TLRPC.Chat migratedTo = getChat(chat.migrated_to.channel_id);
+ if (migratedTo != null)
+ return migratedTo.noforwards;
+ }
+ return chat.noforwards;
+ }
+
+ public boolean isChatNoForwards(long chatId) {
+ return isChatNoForwards(getChat(chatId));
+ }
+
public TLRPC.User getUser(Long id) {
if (id == 0) {
return UserConfig.getInstance(currentAccount).getCurrentUser();
@@ -2940,7 +2966,7 @@ public class MessagesController extends BaseController implements NotificationCe
oldChat.username = chat.username;
oldChat.flags |= 64;
} else {
- oldChat.flags = oldChat.flags &~ 64;
+ oldChat.flags = oldChat.flags & ~64;
oldChat.username = null;
}
if (chat.participants_count != 0) {
@@ -2969,19 +2995,19 @@ public class MessagesController extends BaseController implements NotificationCe
int newFlags2 = chat.default_banned_rights != null ? chat.default_banned_rights.flags : 0;
oldChat.default_banned_rights = chat.default_banned_rights;
if (oldChat.default_banned_rights == null) {
- oldChat.flags &=~ 262144;
+ oldChat.flags &= ~262144;
} else {
oldChat.flags |= 262144;
}
oldChat.banned_rights = chat.banned_rights;
if (oldChat.banned_rights == null) {
- oldChat.flags &=~ 32768;
+ oldChat.flags &= ~32768;
} else {
oldChat.flags |= 32768;
}
oldChat.admin_rights = chat.admin_rights;
if (oldChat.admin_rights == null) {
- oldChat.flags &=~ 16384;
+ oldChat.flags &= ~16384;
} else {
oldChat.flags |= 16384;
}
@@ -3015,7 +3041,7 @@ public class MessagesController extends BaseController implements NotificationCe
chat.username = oldChat.username;
chat.flags |= 64;
} else {
- chat.flags = chat.flags &~ 64;
+ chat.flags = chat.flags & ~64;
chat.username = null;
}
if (oldChat.participants_count != 0 && chat.participants_count == 0) {
@@ -3445,7 +3471,11 @@ public class MessagesController extends BaseController implements NotificationCe
}
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
- TLRPC.UserFull userFull = (TLRPC.UserFull) response;
+ TLRPC.TL_users_userFull res = (TLRPC.TL_users_userFull) response;
+ TLRPC.UserFull userFull = res.full_user;
+ putUsers(res.users, false);
+ putChats(res.chats, false);
+ res.full_user.user = getUser(res.full_user.id);
getMessagesStorage().updateUserInfo(userFull, false);
AndroidUtilities.runOnUIThread(() -> {
@@ -3681,7 +3711,7 @@ public class MessagesController extends BaseController implements NotificationCe
SharedPreferences.Editor editor = notificationsPreferences.edit();
boolean bar_hidden = !settings.report_spam && !settings.add_contact && !settings.block_contact && !settings.share_contact && !settings.report_geo && !settings.invite_members;
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden + " distance = " + settings.geo_distance + " invite = " + settings.invite_members);
+ FileLog.d("peer settings loaded for " + dialogId + " add = " + settings.add_contact + " block = " + settings.block_contact + " spam = " + settings.report_spam + " share = " + settings.share_contact + " geo = " + settings.report_geo + " hide = " + bar_hidden + " distance = " + settings.geo_distance + " invite = " + settings.invite_members);
}
editor.putInt("dialog_bar_vis3" + dialogId, bar_hidden ? 1 : 2);
editor.putBoolean("dialog_bar_share" + dialogId, settings.share_contact);
@@ -3692,6 +3722,9 @@ public class MessagesController extends BaseController implements NotificationCe
editor.putBoolean("dialog_bar_location" + dialogId, settings.report_geo);
editor.putBoolean("dialog_bar_archived" + dialogId, settings.autoarchived);
editor.putBoolean("dialog_bar_invite" + dialogId, settings.invite_members);
+ editor.putString("dialog_bar_chat_with_admin_title" + dialogId, settings.request_chat_title);
+ editor.putBoolean("dialog_bar_chat_with_channel" + dialogId, settings.request_chat_broadcast);
+ editor.putInt("dialog_bar_chat_with_date" + dialogId, settings.request_chat_date);
if (notificationsPreferences.getInt("dialog_bar_distance" + dialogId, -1) != -2) {
if ((settings.flags & 64) != 0) {
editor.putInt("dialog_bar_distance" + dialogId, settings.geo_distance);
@@ -3736,7 +3769,12 @@ public class MessagesController extends BaseController implements NotificationCe
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
loadingPeerSettings.remove(dialogId);
if (response != null) {
- savePeerSettings(dialogId, (TLRPC.TL_peerSettings) response, false);
+ TLRPC.TL_messages_peerSettings res = (TLRPC.TL_messages_peerSettings) response;
+ TLRPC.TL_peerSettings settings = res.settings;
+ putUsers(res.users, false);
+ putChats(res.chats, false);
+
+ savePeerSettings(dialogId, settings, false);
}
}));
}
@@ -4688,9 +4726,9 @@ public class MessagesController extends BaseController implements NotificationCe
if (offset == 0) {
getMessagesStorage().deleteUserChatHistory(-chat.id, user.id);
}
- TLRPC.TL_channels_deleteUserHistory req = new TLRPC.TL_channels_deleteUserHistory();
+ TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory();
req.channel = getInputChannel(chat);
- req.user_id = getInputUser(user);
+ req.participant = getInputPeer(user);
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
@@ -4891,6 +4929,24 @@ public class MessagesController extends BaseController implements NotificationCe
getMessagesStorage().deleteDialog(did, onlyHistory);
return;
}
+ for (int i = 0; i < sendAsPeers.size(); i++) {
+ SendAsPeersInfo sendAsInfo = sendAsPeers.valueAt(i);
+ if (sendAsInfo.sendAsPeers != null) {
+ for (int j = 0; j < sendAsInfo.sendAsPeers.chats.size(); j++) {
+ if (sendAsInfo.sendAsPeers.chats.get(j).id == -did) {
+ sendAsInfo.sendAsPeers.chats.remove(j);
+ break;
+ }
+ }
+ for (int j = 0; j < sendAsInfo.sendAsPeers.peers.size(); j++) {
+ if (sendAsInfo.sendAsPeers.peers.get(j).channel_id == -did || sendAsInfo.sendAsPeers.peers.get(j).chat_id == -did) {
+ sendAsInfo.sendAsPeers.peers.remove(j);
+ break;
+ }
+ }
+ }
+ }
+ sendAsPeers.remove(did);
if (first == 1 && max_id == 0) {
TLRPC.InputPeer peerFinal = peer;
getMessagesStorage().getDialogMaxMessageId(did, (param) -> {
@@ -5956,7 +6012,7 @@ public class MessagesController extends BaseController implements NotificationCe
String emoji = ((TLRPC.TL_sendMessageEmojiInteractionSeen) pu.action).emoticon;
String printingString;
if (key < 0 && !isEncryptedChat) {
- printingString= LocaleController.formatString("IsEnjoyngAnimations", R.string.IsEnjoyngAnimations, getUserNameForTyping(user), emoji);
+ printingString = LocaleController.formatString("IsEnjoyngAnimations", R.string.IsEnjoyngAnimations, getUserNameForTyping(user), emoji);
} else {
printingString = LocaleController.formatString("EnjoyngAnimations", R.string.EnjoyngAnimations, emoji);
}
@@ -6040,12 +6096,13 @@ public class MessagesController extends BaseController implements NotificationCe
public boolean sendTyping(long dialogId, int threadMsgId, int action, int classGuid) {
return sendTyping(dialogId, threadMsgId, action, null, classGuid);
}
+
public boolean sendTyping(long dialogId, int threadMsgId, int action, String emojicon, int classGuid) {
if (action < 0 || action >= sendingTypings.length || dialogId == 0) {
return false;
}
if (dialogId < 0) {
- if (ChatObject.shouldSendAnonymously(getChat(-dialogId))) {
+ if (ChatObject.getSendAsPeerId(getChat(-dialogId), getChatFull(-dialogId)) != UserConfig.getInstance(UserConfig.selectedAccount).getClientUserId()) {
return false;
}
} else {
@@ -6390,7 +6447,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void processLoadedMessages(TLRPC.messages_Messages messagesRes, int resCount, long dialogId, long mergeDialogId, int count, int max_id, int offset_date, boolean isCache, int classGuid,
- int first_unread, int last_message_id, int unread_count, int last_date, int load_type, boolean isEnd, int mode, int threadMessageId, int loadIndex, boolean queryFromServer, int mentionsCount, boolean needProcess) {
+ int first_unread, int last_message_id, int unread_count, int last_date, int load_type, boolean isEnd, int mode, int threadMessageId, int loadIndex, boolean queryFromServer, int mentionsCount, boolean needProcess) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("processLoadedMessages size " + messagesRes.messages.size() + " in chat " + dialogId + " count " + count + " max_id " + max_id + " cache " + isCache + " guid " + classGuid + " load_type " + load_type + " last_message_id " + last_message_id + " index " + loadIndex + " firstUnread " + first_unread + " unread_count " + unread_count + " last_date " + last_date + " queryFromServer " + queryFromServer);
}
@@ -7879,7 +7936,7 @@ public class MessagesController extends BaseController implements NotificationCe
allDialogs.add(dialog);
}
sortDialogs(migrate ? chatsDict : null);
-
+
putAllNeededDraftDialogs();
if (loadType != DIALOGS_LOAD_TYPE_CHANNEL && loadType != DIALOGS_LOAD_TYPE_UNKNOWN) {
@@ -9090,6 +9147,39 @@ public class MessagesController extends BaseController implements NotificationCe
});
}
+ public void setDefaultSendAs(long chatId, long newPeer) {
+ TLRPC.ChatFull cachedFull = getChatFull(-chatId);
+ if (cachedFull != null) {
+ cachedFull.default_send_as = getPeer(newPeer);
+ getMessagesStorage().updateChatInfo(cachedFull, false);
+ getNotificationCenter().postNotificationName(NotificationCenter.updateDefaultSendAsPeer, chatId, cachedFull.default_send_as);
+ }
+
+ TLRPC.TL_messages_saveDefaultSendAs req = new TLRPC.TL_messages_saveDefaultSendAs();
+ req.peer = getInputPeer(chatId);
+ req.send_as = getInputPeer(newPeer);
+ getConnectionsManager().sendRequest(req, (response, error) -> {
+ if (response instanceof TLRPC.TL_boolTrue) {
+ TLRPC.ChatFull full = getChatFull(-chatId);
+ if (full == null) loadFullChat(-chatId, 0, true);
+ } else if (error != null && error.code == 400) {
+ loadFullChat(-chatId, 0, true);
+ }
+ }, ConnectionsManager.RequestFlagInvokeAfter);
+ }
+
+ public void toggleChatNoForwards(long chatId, boolean enabled) {
+ TLRPC.TL_messages_toggleNoForwards req = new TLRPC.TL_messages_toggleNoForwards();
+ req.peer = getInputPeer(-chatId);
+ req.enabled = enabled;
+ getConnectionsManager().sendRequest(req, (response, error) -> {
+ if (response != null) {
+ processUpdates((TLRPC.Updates) response, false);
+ AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT));
+ }
+ }, ConnectionsManager.RequestFlagInvokeAfter);
+ }
+
public void toogleChannelSignatures(long chatId, boolean enabled) {
TLRPC.TL_channels_toggleSignatures req = new TLRPC.TL_channels_toggleSignatures();
req.channel = getInputChannel(chatId);
@@ -9468,7 +9558,21 @@ public class MessagesController extends BaseController implements NotificationCe
if (type == 1) {
unregistedPush();
TLRPC.TL_auth_logOut req = new TLRPC.TL_auth_logOut();
- getConnectionsManager().sendRequest(req, (response, error) -> getConnectionsManager().cleanup(false));
+ getConnectionsManager().sendRequest(req, (response, error) -> {
+ getConnectionsManager().cleanup(false);
+ AndroidUtilities.runOnUIThread(() -> {
+ if (response instanceof TLRPC.TL_auth_loggedOut) {
+ TLRPC.TL_auth_loggedOut res = (TLRPC.TL_auth_loggedOut) response;
+ if (((TLRPC.TL_auth_loggedOut) response).future_auth_token != null) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("saved_tokens", Context.MODE_PRIVATE);
+ int count = preferences.getInt("count", 0);
+ SerializedData data = new SerializedData(response.getObjectSize());
+ res.serializeToStream(data);
+ preferences.edit().putString("log_out_token_" + count, Utilities.bytesToHex(data.toByteArray())).putInt("count", count + 1).apply();
+ }
+ }
+ });
+ });
} else {
getConnectionsManager().cleanup(type == 2);
}
@@ -9506,7 +9610,51 @@ public class MessagesController extends BaseController implements NotificationCe
getContactsController().deleteUnknownAppAccounts();
}
+ public static ArrayList getSavedLogOutTokens() {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("saved_tokens", Context.MODE_PRIVATE);
+ int count = preferences.getInt("count", 0);
+ if (count == 0) {
+ return null;
+ }
+
+ ArrayList tokens = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ String value = preferences.getString("log_out_token_" + i, "");
+ SerializedData serializedData = new SerializedData(Utilities.hexToBytes(value));
+ // try {
+ TLRPC.TL_auth_loggedOut token = TLRPC.TL_auth_loggedOut.TLdeserialize(serializedData, serializedData.readInt32(true), true);
+ if (token != null) {
+ tokens.add(token);
+ }
+// } catch (Throwable e) {
+// FileLog.e(e);
+// }
+ }
+ return tokens;
+ }
+
+ public static void saveLogOutTokens(ArrayList tokens) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("saved_tokens", Context.MODE_PRIVATE);
+ ArrayList activeTokens = new ArrayList<>();
+ preferences.edit().clear().apply();
+ int date = (int) (System.currentTimeMillis() / 1000L);
+ for (int i = 0; i < Math.min(20, tokens.size()); i++) {
+ activeTokens.add(tokens.get(i));
+ }
+ if (activeTokens.size() > 0) {
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putInt("count", activeTokens.size());
+ for (int i = 0; i < activeTokens.size(); i++) {
+ SerializedData data = new SerializedData(activeTokens.get(i).getObjectSize());
+ activeTokens.get(i).serializeToStream(data);
+ editor.putString("log_out_token_" + i, Utilities.bytesToHex(data.toByteArray()));
+ }
+ editor.apply();
+ }
+ }
+
private boolean gettingAppChangelog;
+
public void generateUpdateMessage() {
if (gettingAppChangelog || BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
return;
@@ -13139,7 +13287,7 @@ public class MessagesController extends BaseController implements NotificationCe
chat.default_banned_rights = update.default_banned_rights;
AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat));
}
- } else if (baseUpdate instanceof TLRPC.TL_updateBotCommands) {
+ } else if (baseUpdate instanceof TLRPC.TL_updateBotCommands) {
TLRPC.TL_updateBotCommands update = (TLRPC.TL_updateBotCommands) baseUpdate;
getMediaDataController().updateBotInfo(MessageObject.getPeerId(update.peer), update);
} else if (baseUpdate instanceof TLRPC.TL_updateStickerSets) {
@@ -13371,7 +13519,7 @@ public class MessagesController extends BaseController implements NotificationCe
if (userFull != null) {
userFull.ttl_period = updatePeerHistoryTTL.ttl_period;
if (userFull.ttl_period == 0) {
- userFull.flags &=~ 16384;
+ userFull.flags &= ~16384;
} else {
userFull.flags |= 16384;
}
@@ -13852,6 +14000,61 @@ public class MessagesController extends BaseController implements NotificationCe
return null;
}
+ public TLRPC.TL_channels_sendAsPeers getSendAsPeers(long dialogId) {
+ SendAsPeersInfo info = sendAsPeers.get(dialogId);
+ if (info != null && (info.loading || Math.abs(SystemClock.elapsedRealtime() - info.loadTime) <= 5 * 60 * 1000)) {
+ return info.sendAsPeers;
+ }
+ TLRPC.Chat chat = getChat(-dialogId);
+ if (chat == null || !ChatObject.canSendAsPeers(chat)) {
+ return null;
+ }
+ info = new SendAsPeersInfo();
+ info.loading = true;
+ sendAsPeers.put(dialogId, info);
+ SendAsPeersInfo infoFinal = info;
+ TLRPC.TL_channels_getSendAs req = new TLRPC.TL_channels_getSendAs();
+ req.peer = getInputPeer(dialogId);
+ getConnectionsManager().sendRequest(req, (response, error) -> {
+ TLRPC.TL_channels_sendAsPeers result;
+ if (response != null) {
+ TLRPC.TL_channels_sendAsPeers res = (TLRPC.TL_channels_sendAsPeers) response;
+ if (res.peers.isEmpty()) {
+ result = null;
+ } else {
+ result = res;
+ AndroidUtilities.runOnUIThread(() -> {
+ putUsers(res.users, false);
+ putChats(res.chats, false);
+ });
+ final LongSparseArray usersDict = new LongSparseArray<>();
+ final LongSparseArray chatsDict = new LongSparseArray<>();
+
+ for (int a = 0; a < res.users.size(); a++) {
+ TLRPC.User u = res.users.get(a);
+ usersDict.put(u.id, u);
+ }
+ for (int a = 0; a < res.chats.size(); a++) {
+ TLRPC.Chat c = res.chats.get(a);
+ chatsDict.put(c.id, c);
+ }
+ }
+ } else {
+ result = null;
+ }
+ AndroidUtilities.runOnUIThread(() -> {
+ if (result == null) {
+ sendAsPeers.remove(dialogId);
+ } else {
+ infoFinal.loadTime = SystemClock.elapsedRealtime();
+ infoFinal.sendAsPeers = result;
+ getNotificationCenter().postNotificationName(NotificationCenter.didLoadSendAsPeers, dialogId, result);
+ }
+ });
+ });
+ return null;
+ }
+
public CharSequence getPrintingString(long dialogId, int threadId, boolean isDialog) {
if (isDialog && DialogObject.isUserDialog(dialogId)) {
TLRPC.User user = getUser(dialogId);
@@ -14613,8 +14816,38 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
+ public void deleteMessagesRange(long dialogId, long channelId, int minDate, int maxDate, boolean forAll, Runnable callback) {
+ TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
+ req.peer = getInputPeer(dialogId);
+ req.flags = (1 << 2) | (1 << 3);
+ req.min_date = minDate;
+ req.max_date = maxDate;
+ req.revoke = forAll;
+
+ getConnectionsManager().sendRequest(req, (response, error) -> {
+ if (error == null) {
+ TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
+ processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
+ getMessagesStorage().getStorageQueue().postRunnable(() -> {
+ ArrayList dbMessages = getMessagesStorage().getCachedMessagesInRange(dialogId, minDate, maxDate);
+ getMessagesStorage().markMessagesAsDeleted(dialogId, dbMessages, false, true, false);
+ getMessagesStorage().updateDialogsWithDeletedMessages(dialogId, 0, dbMessages, null, false);
+ AndroidUtilities.runOnUIThread(() -> {
+ getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, dbMessages, channelId, false);
+ callback.run();
+ });
+ });
+ } else {
+ AndroidUtilities.runOnUIThread(() -> {
+ callback.run();
+ });
+ }
+ });
+ }
+
public interface MessagesLoadedCallback {
void onMessagesLoaded(boolean fromCache);
+
void onError();
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
index 0e8fbda65..dc59684e8 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
@@ -50,6 +50,25 @@ import androidx.collection.LongSparseArray;
public class MessagesStorage extends BaseController {
+ public ArrayList getCachedMessagesInRange(long dialogId, int minDate, int maxDate) {
+ ArrayList messageIds = new ArrayList<>();
+ try {
+ SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid FROM messages_v2 WHERE uid = %d AND date >= %d AND date <= %d", dialogId, minDate, maxDate));
+ try {
+ while (cursor.next()) {
+ int mid = cursor.intValue(0);
+ messageIds.add(mid);
+ }
+ } catch (Exception e) {
+ FileLog.e(e);
+ }
+ cursor.dispose();
+ } catch (Exception e) {
+ FileLog.e(e);
+ }
+ return messageIds;
+ }
+
public interface IntCallback {
void run(int param);
}
@@ -10571,7 +10590,7 @@ public class MessagesStorage extends BaseController {
try {
database.executeFast(String.format(Locale.US, "UPDATE media_holes_v2 SET end = %d WHERE uid = %d AND type = %d AND start = %d AND end = %d", minId, did, hole.type, hole.start, hole.end)).stepThis().dispose();
} catch (Exception e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
}
} else if (minId <= hole.start + 1) {
@@ -10579,7 +10598,7 @@ public class MessagesStorage extends BaseController {
try {
database.executeFast(String.format(Locale.US, "UPDATE media_holes_v2 SET start = %d WHERE uid = %d AND type = %d AND start = %d AND end = %d", maxId, did, hole.type, hole.start, hole.end)).stepThis().dispose();
} catch (Exception e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
}
} else {
@@ -10633,7 +10652,7 @@ public class MessagesStorage extends BaseController {
try {
database.executeFast(String.format(Locale.US, "UPDATE " + table + " SET end = %d WHERE uid = %d AND start = %d AND end = %d", minId, did, hole.start, hole.end)).stepThis().dispose();
} catch (Exception e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
}
} else if (minId <= hole.start + 1) {
@@ -10641,7 +10660,7 @@ public class MessagesStorage extends BaseController {
try {
database.executeFast(String.format(Locale.US, "UPDATE " + table + " SET start = %d WHERE uid = %d AND start = %d AND end = %d", maxId, did, hole.start, hole.end)).stepThis().dispose();
} catch (Exception e) {
- FileLog.e(e);
+ FileLog.e(e, false);
}
}
} else {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
index 31491f40a..54d978597 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
@@ -33,6 +33,8 @@ public class NotificationCenter {
public static final int changeRepliesCounter = totalEvents++;
public static final int messagesDidLoad = totalEvents++;
public static final int didLoadSponsoredMessages = totalEvents++;
+ public static final int didLoadSendAsPeers = totalEvents++;
+ public static final int updateDefaultSendAsPeer = totalEvents++;
public static final int messagesDidLoadWithoutProcess = totalEvents++;
public static final int loadingMessagesFailed = totalEvents++;
public static final int messageReceivedByAck = totalEvents++;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
index 94d5c394b..0f87754db 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
@@ -1221,13 +1221,13 @@ public class NotificationsController extends BaseController {
try {
for (int i = 0, N = MessagesController.getInstance(a).allDialogs.size(); i < N; i++) {
TLRPC.Dialog dialog = MessagesController.getInstance(a).allDialogs.get(i);
- if (DialogObject.isChatDialog(dialog.id)) {
+ if (dialog != null && DialogObject.isChatDialog(dialog.id)) {
TLRPC.Chat chat = getMessagesController().getChat(-dialog.id);
if (ChatObject.isNotInChat(chat)) {
continue;
}
}
- if (dialog.unread_count != 0) {
+ if (dialog != null && dialog.unread_count != 0) {
count += dialog.unread_count;
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
index 9d06b00ab..be0277a12 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
@@ -1881,16 +1881,20 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
newMsg.from_id = peer_id;
}
newMsg.post = true;
- } else if (ChatObject.shouldSendAnonymously(chat)) {
- newMsg.from_id = peer_id;
- if (rank != null) {
- newMsg.post_author = rank;
- newMsg.flags |= 65536;
- }
} else {
- newMsg.from_id = new TLRPC.TL_peerUser();
- newMsg.from_id.user_id = myId;
- newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
+ long fromPeerId = ChatObject.getSendAsPeerId(chat, getMessagesController().getChatFull(-peer), true);
+
+ if (fromPeerId == myId) {
+ newMsg.from_id = new TLRPC.TL_peerUser();
+ newMsg.from_id.user_id = myId;
+ newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
+ } else {
+ newMsg.from_id = getMessagesController().getPeer(fromPeerId);
+ if (rank != null) {
+ newMsg.post_author = rank;
+ newMsg.flags |= 65536;
+ }
+ }
}
if (newMsg.random_id == 0) {
newMsg.random_id = getNextRandomId();
@@ -3016,6 +3020,10 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
request.random_id = random_id != 0 ? random_id : getNextRandomId();
request.message = "";
request.media = game;
+ long fromId = ChatObject.getSendAsPeerId(getMessagesController().getChat(peer.chat_id), getMessagesController().getChatFull(peer.chat_id));
+ if (fromId != UserConfig.getInstance(currentAccount).getClientUserId()) {
+ request.send_as = getMessagesController().getInputPeer(fromId);
+ }
final long newTaskId;
if (taskId == 0) {
NativeByteBuffer data = null;
@@ -3100,7 +3108,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
int type = -1;
boolean isChannel = false;
boolean forceNoSoundVideo = false;
- boolean anonymously = false;
+ TLRPC.Peer fromPeer = null;
String rank = null;
long linkedToGroup = 0;
TLRPC.EncryptedChat encryptedChat = null;
@@ -3119,14 +3127,12 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
}
} else if (sendToPeer instanceof TLRPC.TL_inputPeerChannel) {
TLRPC.Chat chat = getMessagesController().getChat(sendToPeer.channel_id);
+ TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chat.id);
isChannel = chat != null && !chat.megagroup;
- if (isChannel && chat.has_link) {
- TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chat.id);
- if (chatFull != null) {
- linkedToGroup = chatFull.linked_chat_id;
- }
+ if (isChannel && chat.has_link && chatFull != null) {
+ linkedToGroup = chatFull.linked_chat_id;
}
- anonymously = ChatObject.shouldSendAnonymously(chat);
+ fromPeer = getMessagesController().getPeer(ChatObject.getSendAsPeerId(chat, chatFull, true));
}
try {
@@ -3426,8 +3432,8 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
if (isChannel && sendToPeer != null) {
newMsg.from_id = new TLRPC.TL_peerChannel();
newMsg.from_id.channel_id = sendToPeer.channel_id;
- } else if (anonymously) {
- newMsg.from_id = getMessagesController().getPeer(peer);
+ } else if (fromPeer != null) {
+ newMsg.from_id = fromPeer;
if (rank != null) {
newMsg.post_author = rank;
newMsg.flags |= 65536;
@@ -3637,6 +3643,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
reqSend.silent = newMsg.silent;
reqSend.peer = sendToPeer;
reqSend.random_id = newMsg.random_id;
+ if (newMsg.from_id != null) {
+ reqSend.send_as = getMessagesController().getInputPeer(newMsg.from_id);
+ }
if (newMsg.reply_to != null && newMsg.reply_to.reply_to_msg_id != 0) {
reqSend.flags |= 1;
reqSend.reply_to_msg_id = newMsg.reply_to.reply_to_msg_id;
@@ -3996,6 +4005,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
request.reply_to_msg_id = newMsg.reply_to.reply_to_msg_id;
}
request.random_id = newMsg.random_id;
+ if (newMsg.from_id != null) {
+ request.send_as = getMessagesController().getInputPeer(newMsg.from_id);
+ }
request.media = inputMedia;
request.message = caption;
if (entities != null && !entities.isEmpty()) {
@@ -4371,6 +4383,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
TLRPC.TL_messages_sendInlineBotResult reqSend = new TLRPC.TL_messages_sendInlineBotResult();
reqSend.peer = sendToPeer;
reqSend.random_id = newMsg.random_id;
+ if (newMsg.from_id != null) {
+ reqSend.send_as = getMessagesController().getInputPeer(newMsg.from_id);
+ }
reqSend.hide_via = !params.containsKey("bot");
if (newMsg.reply_to != null && newMsg.reply_to.reply_to_msg_id != 0) {
reqSend.flags |= 1;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
index 323f9933f..11ccbd1a8 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
@@ -136,6 +136,7 @@ public class SharedConfig {
public static int distanceSystemType;
public static int mediaColumnsCount = 3;
public static int fastScrollHintCount = 3;
+ public static boolean dontAskManageStorage;
static {
loadConfig();
@@ -375,6 +376,7 @@ public class SharedConfig {
dayNightThemeSwitchHintCount = preferences.getInt("dayNightThemeSwitchHintCount", 3);
mediaColumnsCount = preferences.getInt("mediaColumnsCount", 3);
fastScrollHintCount = preferences.getInt("fastScrollHintCount", 3);
+ dontAskManageStorage = preferences.getBoolean("dontAskManageStorage", false);
preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true);
@@ -1161,4 +1163,9 @@ public class SharedConfig {
ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit().putInt("fastScrollHintCount", fastScrollHintCount).apply();
}
}
+
+ public static void setDontAskManageStorage(boolean b) {
+ dontAskManageStorage = b;
+ ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit().putBoolean("dontAskManageStorage", dontAskManageStorage).apply();
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java
index a01bb348e..65f2aa53d 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/SvgHelper.java
@@ -142,7 +142,6 @@ public class SvgHelper {
height = h;
}
-
@Override
public void draw(Canvas canvas) {
if (currentColorKey != null) {
@@ -287,11 +286,15 @@ public class SvgHelper {
}
public static Bitmap getBitmap(int res, int width, int height, int color) {
+ return getBitmap(res, width, height, color, 1f);
+ }
+
+ public static Bitmap getBitmap(int res, int width, int height, int color, float scale) {
try (InputStream stream = ApplicationLoader.applicationContext.getResources().openRawResource(res)) {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
- SVGHandler handler = new SVGHandler(width, height, color, false);
+ SVGHandler handler = new SVGHandler(width, height, color, false, scale);
xr.setContentHandler(handler);
xr.parse(new InputSource(stream));
return handler.getBitmap();
@@ -306,7 +309,7 @@ public class SvgHelper {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
- SVGHandler handler = new SVGHandler(width, height, white ? 0xffffffff : null, false);
+ SVGHandler handler = new SVGHandler(width, height, white ? 0xffffffff : null, false, 1f);
xr.setContentHandler(handler);
xr.parse(new InputSource(stream));
return handler.getBitmap();
@@ -321,7 +324,7 @@ public class SvgHelper {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
- SVGHandler handler = new SVGHandler(width, height, white ? 0xffffffff : null, false);
+ SVGHandler handler = new SVGHandler(width, height, white ? 0xffffffff : null, false, 1f);
xr.setContentHandler(handler);
xr.parse(new InputSource(new StringReader(xml)));
return handler.getBitmap();
@@ -336,7 +339,7 @@ public class SvgHelper {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
- SVGHandler handler = new SVGHandler(0, 0, null, true);
+ SVGHandler handler = new SVGHandler(0, 0, null, true, 1f);
xr.setContentHandler(handler);
xr.parse(new InputSource(new StringReader(xml)));
return handler.getDrawable();
@@ -351,7 +354,7 @@ public class SvgHelper {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
- SVGHandler handler = new SVGHandler(0, 0, color, true);
+ SVGHandler handler = new SVGHandler(0, 0, color, true, 1f);
xr.setContentHandler(handler);
xr.parse(new InputSource(ApplicationLoader.applicationContext.getResources().openRawResource(resId)));
return handler.getDrawable();
@@ -948,12 +951,14 @@ public class SvgHelper {
private RectF rect = new RectF();
private RectF rectTmp = new RectF();
private Integer paintColor;
+ private float globalScale = 1f;
boolean pushed = false;
private HashMap globalStyles = new HashMap<>();
- private SVGHandler(int dw, int dh, Integer color, boolean asDrawable) {
+ private SVGHandler(int dw, int dh, Integer color, boolean asDrawable, float scale) {
+ globalScale = scale;
desiredWidth = dw;
desiredHeight = dh;
paintColor = color;
@@ -1114,7 +1119,7 @@ public class SvgHelper {
bitmap.eraseColor(0);
canvas = new Canvas(bitmap);
if (scale != 0) {
- canvas.scale(scale, scale);
+ canvas.scale(globalScale * scale, globalScale * scale);
}
} else {
drawable.width = width;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/video/MediaCodecVideoConvertor.java b/TMessagesProj/src/main/java/org/telegram/messenger/video/MediaCodecVideoConvertor.java
index 2a1abfd08..042bca03b 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/video/MediaCodecVideoConvertor.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/video/MediaCodecVideoConvertor.java
@@ -1,11 +1,17 @@
package org.telegram.messenger.video;
import android.annotation.TargetApi;
+import android.graphics.Matrix;
+import android.graphics.SurfaceTexture;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaExtractor;
import android.media.MediaFormat;
+import android.opengl.EGL14;
+import android.opengl.GLES11Ext;
+import android.opengl.GLES20;
import android.os.Build;
+import android.view.Surface;
import com.google.android.exoplayer2.util.Log;
@@ -25,8 +31,16 @@ import org.telegram.ui.LaunchActivity;
import java.io.File;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
import java.util.ArrayList;
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.egl.EGLContext;
+import javax.microedition.khronos.egl.EGLDisplay;
+import javax.microedition.khronos.egl.EGLSurface;
+
public class MediaCodecVideoConvertor {
private MP4Builder mediaMuxer;
@@ -48,6 +62,7 @@ public class MediaCodecVideoConvertor {
public boolean convertVideo(String videoPath, File cacheFile,
int rotationValue, boolean isSecret,
+ int originalWidth, int originalHeight,
int resultWidth, int resultHeight,
int framerate, int bitrate, int originalBitrate,
long startTime, long endTime, long avatarStartTime,
@@ -59,7 +74,7 @@ public class MediaCodecVideoConvertor {
MediaController.CropState cropState,
MediaController.VideoConvertorListener callback) {
this.callback = callback;
- return convertVideoInternal(videoPath, cacheFile, rotationValue, isSecret,
+ return convertVideoInternal(videoPath, cacheFile, rotationValue, isSecret, originalWidth, originalHeight,
resultWidth, resultHeight, framerate, bitrate, originalBitrate, startTime, endTime, avatarStartTime, duration, needCompress, false, savedFilterState, paintPath, mediaEntities, isPhoto, cropState);
}
@@ -70,6 +85,7 @@ public class MediaCodecVideoConvertor {
@TargetApi(18)
private boolean convertVideoInternal(String videoPath, File cacheFile,
int rotationValue, boolean isSecret,
+ int originalWidth, int originalHeight,
int resultWidth, int resultHeight,
int framerate, int bitrate, int originalBitrate,
long startTime, long endTime, long avatarStartTime,
@@ -141,8 +157,8 @@ public class MediaCodecVideoConvertor {
MediaFormat outputFormat = MediaFormat.createVideoFormat(MediaController.VIDEO_MIME_TYPE, resultWidth, resultHeight);
outputFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
outputFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);
- outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate);
- outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 2);
+ outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
+ outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
encoder = MediaCodec.createEncoderByType(MediaController.VIDEO_MIME_TYPE);
encoder.configure(outputFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
@@ -150,7 +166,7 @@ public class MediaCodecVideoConvertor {
inputSurface.makeCurrent();
encoder.start();
- outputSurface = new OutputSurface(savedFilterState, videoPath, paintPath, mediaEntities, null, resultWidth, resultHeight, rotationValue, framerate, true);
+ // outputSurface = new OutputSurface(savedFilterState, videoPath, paintPath, mediaEntities, null, resultWidth, resultHeight, rotationValue, framerate, true);
ByteBuffer[] encoderOutputBuffers = null;
ByteBuffer[] encoderInputBuffers = null;
@@ -406,6 +422,7 @@ public class MediaCodecVideoConvertor {
decoder = MediaCodec.createDecoderByType(videoFormat.getString(MediaFormat.KEY_MIME));
outputSurface = new OutputSurface(savedFilterState, null, paintPath, mediaEntities, cropState, resultWidth, resultHeight, rotationValue, framerate, false);
+ outputSurface.changeFragmentShader(createFragmentShader(originalWidth, originalHeight, resultWidth, resultHeight));
decoder.configure(videoFormat, outputSurface.getSurface(), null, 0);
decoder.start();
@@ -681,7 +698,7 @@ public class MediaCodecVideoConvertor {
inputDone = false;
decoderDone = false;
doRender = false;
- info.flags &=~ MediaCodec.BUFFER_FLAG_END_OF_STREAM;
+ info.flags &= ~MediaCodec.BUFFER_FLAG_END_OF_STREAM;
decoder.flush();
flushed = true;
}
@@ -791,6 +808,7 @@ public class MediaCodecVideoConvertor {
if (repeatWithIncreasedTimeout) {
return convertVideoInternal(videoPath, cacheFile, rotationValue, isSecret,
+ originalWidth, originalHeight,
resultWidth, resultHeight, framerate, bitrate, originalBitrate, startTime, endTime, avatarStartTime, duration,
needCompress, true, savedFilterState, paintPath, mediaEntities,
isPhoto, cropState);
@@ -958,6 +976,52 @@ public class MediaCodecVideoConvertor {
private void checkConversionCanceled() {
if (callback != null && callback.checkConversionCanceled())
- throw new RuntimeException("canceled conversion");
+ throw new ConversionCanceledException();
}
+
+ private static String createFragmentShader(
+ final int srcWidth,
+ final int srcHeight,
+ final int dstWidth,
+ final int dstHeight) {
+ final float kernelSizeX = Math.max(2f, (float) srcWidth / (float) dstWidth);
+ final float kernelSizeY = Math.max(2f, (float) srcHeight / (float) dstHeight);
+
+ final String shader;
+
+ final int kernelRadiusX = (int) Math.ceil(kernelSizeX - .1f) / 2;
+ final int kernelRadiusY = (int) Math.ceil(kernelSizeY - .1f) / 2;
+ final float stepX = kernelSizeX / (1 + 2 * kernelRadiusX) * (1f / srcWidth);
+ final float stepY = kernelSizeY / (1 + 2 * kernelRadiusY) * (1f / srcHeight);
+ final float sum = (1 + 2 * kernelRadiusX) * (1 + 2 * kernelRadiusY);
+ final StringBuilder colorLoop = new StringBuilder();
+ for (int i = -kernelRadiusX; i <= kernelRadiusX; i++) {
+ for (int j = -kernelRadiusY; j <= kernelRadiusY; j++) {
+ if (i != 0 || j != 0) {
+ colorLoop.append(" + texture2D(sTexture, vTextureCoord.xy + vec2(")
+ .append(i * stepX).append(", ").append(j * stepY).append("))\n");
+ }
+ }
+ }
+ shader =
+ "#extension GL_OES_EGL_image_external : require\n" +
+ "precision mediump float;\n" + // highp here doesn't seem to matter
+ "varying vec2 vTextureCoord;\n" +
+ "uniform samplerExternalOES sTexture;\n" +
+ "void main() {\n" +
+ " gl_FragColor = (texture2D(sTexture, vTextureCoord)\n" +
+ colorLoop.toString() +
+ " ) / " + sum + ";\n" +
+ "}\n";
+
+ return shader;
+ }
+
+ public class ConversionCanceledException extends RuntimeException{
+
+ public ConversionCanceledException() {
+ super("canceled conversion");
+ }
+ }
+
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/video/OutputSurface.java b/TMessagesProj/src/main/java/org/telegram/messenger/video/OutputSurface.java
index 96e049124..e7cd82422 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/video/OutputSurface.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/video/OutputSurface.java
@@ -165,4 +165,8 @@ public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {
throw new RuntimeException("EGL error encountered (see log)");
}
}
+
+ public void changeFragmentShader(String fragmentShader) {
+ mTextureRender.changeFragmentShader(fragmentShader);
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java b/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java
index 40ff01b95..aac09a31e 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java
@@ -604,7 +604,7 @@ public class TextureRenderer {
if (entity.type == 0) {
if ((entity.subType & 1) != 0) {
entity.metadata = new int[3];
- entity.ptr = RLottieDrawable.create(entity.text, null, 512, 512, entity.metadata, false, null, false);
+ entity.ptr = RLottieDrawable.create(entity.text, null, 512, 512, entity.metadata, false, null, false, 0);
entity.framesPerDraw = entity.metadata[1] / videoFps;
} else {
if (Build.VERSION.SDK_INT >= 19) {
@@ -714,4 +714,9 @@ public class TextureRenderer {
}
}
}
+
+ public void changeFragmentShader(String fragmentShader) {
+ GLES20.glDeleteProgram(mProgram[0]);
+ mProgram[0] = createProgram(VERTEX_SHADER, fragmentShader);
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java
index bd6cc5346..32c0a86f4 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java
@@ -15,7 +15,7 @@ import java.util.List;
public final class Instance {
- public static final List AVAILABLE_VERSIONS = Build.VERSION.SDK_INT >= 18 ? Arrays.asList(/*"3.0.0", */"2.7.7", "2.4.4") : Arrays.asList("2.4.4");
+ public static final List AVAILABLE_VERSIONS = Build.VERSION.SDK_INT >= 18 ? Arrays.asList("3.0.0", "2.7.7", "2.4.4") : Arrays.asList("2.4.4");
public static final int AUDIO_STATE_MUTED = 0;
public static final int AUDIO_STATE_ACTIVE = 1;
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
index f42520d8f..36d12943d 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
@@ -10,6 +10,7 @@ import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Base64;
+import com.google.android.exoplayer2.util.Log;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import org.json.JSONArray;
@@ -1017,7 +1018,7 @@ public class ConnectionsManager extends BaseController {
buffer.writeBytes(bytes);
return buffer;
} catch (Throwable e) {
- FileLog.e(e);
+ FileLog.e(e, false);
} finally {
try {
if (httpConnectionStream != null) {
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
index bd8e360f0..7e5e3de46 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
@@ -66,7 +66,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800;
public static final int MESSAGE_FLAG_EDITED = 0x00008000;
- public static final int LAYER = 134;
+ public static final int LAYER = 135;
public static class TL_stats_megagroupStats extends TLObject {
public static int constructor = 0xef7ff916;
@@ -2269,7 +2269,7 @@ public class TLRPC {
case 0x44747e9a:
result = new TL_auth_authorizationSignUpRequired();
break;
- case 0xcd050916:
+ case 0x33fb7bb8:
result = new TL_auth_authorization();
break;
}
@@ -2306,14 +2306,20 @@ public class TLRPC {
}
public static class TL_auth_authorization extends auth_Authorization {
- public static int constructor = 0xcd050916;
+ public static int constructor = 0x33fb7bb8;
public int flags;
+ public boolean setup_password_required;
+ public int otherwise_relogin_days;
public int tmp_sessions;
public User user;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
+ setup_password_required = (flags & 2) != 0;
+ if ((flags & 2) != 0) {
+ otherwise_relogin_days = stream.readInt32(exception);
+ }
if ((flags & 1) != 0) {
tmp_sessions = stream.readInt32(exception);
}
@@ -2322,7 +2328,11 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = setup_password_required ? (flags | 2) : (flags &~ 2);
stream.writeInt32(flags);
+ if ((flags & 2) != 0) {
+ stream.writeInt32(otherwise_relogin_days);
+ }
if ((flags & 1) != 0) {
stream.writeInt32(tmp_sessions);
}
@@ -4397,6 +4407,8 @@ public class TLRPC {
public boolean current;
public boolean official_app;
public boolean password_pending;
+ public boolean encrypted_requests_disabled;
+ public boolean call_requests_disabled;
public long hash;
public String device_model;
public String platform;
@@ -4428,6 +4440,8 @@ public class TLRPC {
current = (flags & 1) != 0;
official_app = (flags & 2) != 0;
password_pending = (flags & 4) != 0;
+ encrypted_requests_disabled = (flags & 8) != 0;
+ call_requests_disabled = (flags & 16) != 0;
hash = stream.readInt64(exception);
device_model = stream.readString(exception);
platform = stream.readString(exception);
@@ -4447,6 +4461,8 @@ public class TLRPC {
flags = current ? (flags | 1) : (flags &~ 1);
flags = official_app ? (flags | 2) : (flags &~ 2);
flags = password_pending ? (flags | 4) : (flags &~ 4);
+ flags = encrypted_requests_disabled ? (flags | 8) : (flags &~ 8);
+ flags = call_requests_disabled ? (flags | 16) : (flags &~ 16);
stream.writeInt32(flags);
stream.writeInt64(hash);
stream.writeString(device_model);
@@ -6088,6 +6104,7 @@ public class TLRPC {
public static abstract class auth_SentCodeType extends TLObject {
public int length;
public String pattern;
+ public String prefix;
public static auth_SentCodeType TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
auth_SentCodeType result = null;
@@ -6101,6 +6118,9 @@ public class TLRPC {
case 0xab03c6d9:
result = new TL_auth_sentCodeTypeFlashCall();
break;
+ case 0x82006484:
+ result = new TL_auth_sentCodeTypeMissedCall();
+ break;
case 0xc000bba2:
result = new TL_auth_sentCodeTypeSms();
break;
@@ -6157,6 +6177,21 @@ public class TLRPC {
}
}
+ public static class TL_auth_sentCodeTypeMissedCall extends auth_SentCodeType {
+ public static int constructor = 0x82006484;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ prefix = stream.readString(exception);
+ length = stream.readInt32(exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(prefix);
+ stream.writeInt32(length);
+ }
+ }
+
public static class TL_auth_sentCodeTypeSms extends auth_SentCodeType {
public static int constructor = 0xc000bba2;
@@ -6237,7 +6272,7 @@ public class TLRPC {
}
public static class TL_peerSettings extends TLObject {
- public static int constructor = 0x733f2961;
+ public static int constructor = 0xa518110d;
public int flags;
public boolean report_spam;
@@ -6248,7 +6283,10 @@ public class TLRPC {
public boolean report_geo;
public boolean autoarchived;
public boolean invite_members;
+ public boolean request_chat_broadcast;
public int geo_distance;
+ public String request_chat_title;
+ public int request_chat_date;
public static TL_peerSettings TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_peerSettings.constructor != constructor) {
@@ -6273,9 +6311,16 @@ public class TLRPC {
report_geo = (flags & 32) != 0;
autoarchived = (flags & 128) != 0;
invite_members = (flags & 256) != 0;
+ request_chat_broadcast = (flags & 1024) != 0;
if ((flags & 64) != 0) {
geo_distance = stream.readInt32(exception);
}
+ if ((flags & 512) != 0) {
+ request_chat_title = stream.readString(exception);
+ }
+ if ((flags & 512) != 0) {
+ request_chat_date = stream.readInt32(exception);
+ }
}
public void serializeToStream(AbstractSerializedData stream) {
@@ -6288,10 +6333,17 @@ public class TLRPC {
flags = report_geo ? (flags | 32) : (flags &~ 32);
flags = autoarchived ? (flags | 128) : (flags &~ 128);
flags = invite_members ? (flags | 256) : (flags &~ 256);
+ flags = request_chat_broadcast ? (flags | 1024) : (flags &~ 1024);
stream.writeInt32(flags);
if ((flags & 64) != 0) {
stream.writeInt32(geo_distance);
}
+ if ((flags & 512) != 0) {
+ stream.writeString(request_chat_title);
+ }
+ if ((flags & 512) != 0) {
+ stream.writeInt32(request_chat_date);
+ }
}
}
@@ -8567,77 +8619,94 @@ public class TLRPC {
}
}
- public static class TL_messages_stickerSet extends TLObject {
- public static int constructor = 0xb60a24a6;
+ public static abstract class messages_StickerSet extends TLObject {
- public StickerSet set;
- public ArrayList packs = new ArrayList<>();
- public ArrayList documents = new ArrayList<>();
+ public StickerSet set;
+ public ArrayList packs = new ArrayList<>();
+ public ArrayList documents = new ArrayList<>();
- public static TL_messages_stickerSet TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
- if (TL_messages_stickerSet.constructor != constructor) {
- if (exception) {
- throw new RuntimeException(String.format("can't parse magic %x in TL_messages_stickerSet", constructor));
- } else {
- return null;
- }
- }
- TL_messages_stickerSet result = new TL_messages_stickerSet();
- result.readParams(stream, exception);
- return result;
- }
+ public static TL_messages_stickerSet TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ TL_messages_stickerSet result = null;
+ switch (constructor) {
+ case 0xb60a24a6:
+ result = new TL_messages_stickerSet();
+ break;
+ case 0xd3f924eb:
+ result = new TL_messages_stickerSetNotModified();
+ break;
+ }
+ if (result == null && exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in messages_StickerSet", constructor));
+ }
+ if (result != null) {
+ result.readParams(stream, exception);
+ }
+ return result;
+ }
+ }
- public void readParams(AbstractSerializedData stream, boolean exception) {
- set = StickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
- int magic = stream.readInt32(exception);
- if (magic != 0x1cb5c415) {
- if (exception) {
- throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
- }
- return;
- }
- int count = stream.readInt32(exception);
- for (int a = 0; a < count; a++) {
- TL_stickerPack object = TL_stickerPack.TLdeserialize(stream, stream.readInt32(exception), exception);
- if (object == null) {
- return;
- }
- packs.add(object);
- }
- magic = stream.readInt32(exception);
- if (magic != 0x1cb5c415) {
- if (exception) {
- throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
- }
- return;
- }
- count = stream.readInt32(exception);
- for (int a = 0; a < count; a++) {
- Document object = Document.TLdeserialize(stream, stream.readInt32(exception), exception);
- if (object == null) {
- return;
- }
- documents.add(object);
- }
- }
+ public static class TL_messages_stickerSet extends messages_StickerSet {
+ public static int constructor = 0xb60a24a6;
- public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- set.serializeToStream(stream);
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ set = StickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ TL_stickerPack object = TL_stickerPack.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ packs.add(object);
+ }
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ Document object = Document.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ documents.add(object);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ set.serializeToStream(stream);
stream.writeInt32(0x1cb5c415);
- int count = packs.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- packs.get(a).serializeToStream(stream);
- }
- stream.writeInt32(0x1cb5c415);
- count = documents.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- documents.get(a).serializeToStream(stream);
- }
- }
- }
+ int count = packs.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ packs.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = documents.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ documents.get(a).serializeToStream(stream);
+ }
+ }
+ }
+
+ public static class TL_messages_stickerSetNotModified extends TL_messages_stickerSet {
+ public static int constructor = 0xd3f924eb;
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ }
+ }
public static abstract class InputGeoPoint extends TLObject {
@@ -10461,6 +10530,7 @@ public class TLRPC {
public ArrayList recent_requesters = new ArrayList<>();
public String theme_emoticon;
public int requests_pending;
+ public Peer default_send_as;
public long inviterId; //custom
public int invitesCount; //custom
@@ -10470,9 +10540,12 @@ public class TLRPC {
case 0x46a6ffb4:
result = new TL_chatFull();
break;
- case 0x59cff963:
+ case 0x56662e2e:
result = new TL_channelFull();
break;
+ case 0x59cff963:
+ result = new TL_channelFull_layer134();
+ break;
case 0x1c87a71a:
result = new TL_channelFull_layer98();
break;
@@ -11910,6 +11983,252 @@ public class TLRPC {
}
public static class TL_channelFull extends ChatFull {
+ public static int constructor = 0x56662e2e;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ can_view_participants = (flags & 8) != 0;
+ can_set_username = (flags & 64) != 0;
+ can_set_stickers = (flags & 128) != 0;
+ hidden_prehistory = (flags & 1024) != 0;
+ can_set_location = (flags & 65536) != 0;
+ has_scheduled = (flags & 524288) != 0;
+ can_view_stats = (flags & 1048576) != 0;
+ blocked = (flags & 4194304) != 0;
+ id = stream.readInt64(exception);
+ about = stream.readString(exception);
+ if ((flags & 1) != 0) {
+ participants_count = stream.readInt32(exception);
+ }
+ if ((flags & 2) != 0) {
+ admins_count = stream.readInt32(exception);
+ }
+ if ((flags & 4) != 0) {
+ kicked_count = stream.readInt32(exception);
+ }
+ if ((flags & 4) != 0) {
+ banned_count = stream.readInt32(exception);
+ }
+ if ((flags & 8192) != 0) {
+ online_count = stream.readInt32(exception);
+ }
+ read_inbox_max_id = stream.readInt32(exception);
+ read_outbox_max_id = stream.readInt32(exception);
+ unread_count = stream.readInt32(exception);
+ chat_photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception);
+ notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if ((flags & 8388608) != 0) {
+ exported_invite = ExportedChatInvite.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ BotInfo object = BotInfo.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ bot_info.add(object);
+ }
+ if ((flags & 16) != 0) {
+ migrated_from_chat_id = stream.readInt64(exception);
+ }
+ if ((flags & 16) != 0) {
+ migrated_from_max_id = stream.readInt32(exception);
+ }
+ if ((flags & 32) != 0) {
+ pinned_msg_id = stream.readInt32(exception);
+ }
+ if ((flags & 256) != 0) {
+ stickerset = StickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 512) != 0) {
+ available_min_id = stream.readInt32(exception);
+ }
+ if ((flags & 2048) != 0) {
+ folder_id = stream.readInt32(exception);
+ }
+ if ((flags & 16384) != 0) {
+ linked_chat_id = stream.readInt64(exception);
+ }
+ if ((flags & 32768) != 0) {
+ location = ChannelLocation.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 131072) != 0) {
+ slowmode_seconds = stream.readInt32(exception);
+ }
+ if ((flags & 262144) != 0) {
+ slowmode_next_send_date = stream.readInt32(exception);
+ }
+ if ((flags & 4096) != 0) {
+ stats_dc = stream.readInt32(exception);
+ }
+ pts = stream.readInt32(exception);
+ if ((flags & 2097152) != 0) {
+ call = TL_inputGroupCall.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 16777216) != 0) {
+ ttl_period = stream.readInt32(exception);
+ }
+ if ((flags & 33554432) != 0) {
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ pending_suggestions.add(stream.readString(exception));
+ }
+ }
+ if ((flags & 67108864) != 0) {
+ groupcall_default_join_as = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 134217728) != 0) {
+ theme_emoticon = stream.readString(exception);
+ }
+ if ((flags & 268435456) != 0) {
+ requests_pending = stream.readInt32(exception);
+ }
+ if ((flags & 268435456) != 0) {
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ recent_requesters.add(stream.readInt64(exception));
+ }
+ }
+ if ((flags & 536870912) != 0) {
+ default_send_as = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = can_view_participants ? (flags | 8) : (flags &~ 8);
+ flags = can_set_username ? (flags | 64) : (flags &~ 64);
+ flags = can_set_stickers ? (flags | 128) : (flags &~ 128);
+ flags = hidden_prehistory ? (flags | 1024) : (flags &~ 1024);
+ flags = can_set_location ? (flags | 65536) : (flags &~ 65536);
+ flags = has_scheduled ? (flags | 524288) : (flags &~ 524288);
+ flags = can_view_stats ? (flags | 1048576) : (flags &~ 1048576);
+ flags = blocked ? (flags | 4194304) : (flags &~ 4194304);
+ stream.writeInt32(flags);
+ stream.writeInt64(id);
+ stream.writeString(about);
+ if ((flags & 1) != 0) {
+ stream.writeInt32(participants_count);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeInt32(admins_count);
+ }
+ if ((flags & 4) != 0) {
+ stream.writeInt32(kicked_count);
+ }
+ if ((flags & 4) != 0) {
+ stream.writeInt32(banned_count);
+ }
+ if ((flags & 8192) != 0) {
+ stream.writeInt32(online_count);
+ }
+ stream.writeInt32(read_inbox_max_id);
+ stream.writeInt32(read_outbox_max_id);
+ stream.writeInt32(unread_count);
+ chat_photo.serializeToStream(stream);
+ notify_settings.serializeToStream(stream);
+ if ((flags & 8388608) != 0) {
+ exported_invite.serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ int count = bot_info.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ bot_info.get(a).serializeToStream(stream);
+ }
+ if ((flags & 16) != 0) {
+ stream.writeInt64(migrated_from_chat_id);
+ }
+ if ((flags & 16) != 0) {
+ stream.writeInt32(migrated_from_max_id);
+ }
+ if ((flags & 32) != 0) {
+ stream.writeInt32(pinned_msg_id);
+ }
+ if ((flags & 256) != 0) {
+ stickerset.serializeToStream(stream);
+ }
+ if ((flags & 512) != 0) {
+ stream.writeInt32(available_min_id);
+ }
+ if ((flags & 2048) != 0) {
+ stream.writeInt32(folder_id);
+ }
+ if ((flags & 16384) != 0) {
+ stream.writeInt64(linked_chat_id);
+ }
+ if ((flags & 32768) != 0) {
+ location.serializeToStream(stream);
+ }
+ if ((flags & 131072) != 0) {
+ stream.writeInt32(slowmode_seconds);
+ }
+ if ((flags & 262144) != 0) {
+ stream.writeInt32(slowmode_next_send_date);
+ }
+ if ((flags & 4096) != 0) {
+ stream.writeInt32(stats_dc);
+ }
+ stream.writeInt32(pts);
+ if ((flags & 2097152) != 0) {
+ call.serializeToStream(stream);
+ }
+ if ((flags & 16777216) != 0) {
+ stream.writeInt32(ttl_period);
+ }
+ if ((flags & 33554432) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ count = pending_suggestions.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeString(pending_suggestions.get(a));
+ }
+ }
+ if ((flags & 67108864) != 0) {
+ groupcall_default_join_as.serializeToStream(stream);
+ }
+ if ((flags & 134217728) != 0) {
+ stream.writeString(theme_emoticon);
+ }
+ if ((flags & 268435456) != 0) {
+ stream.writeInt32(requests_pending);
+ }
+ if ((flags & 268435456) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ count = recent_requesters.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeInt64(recent_requesters.get(a));
+ }
+ }
+ if ((flags & 536870912) != 0) {
+ default_send_as.serializeToStream(stream);
+ }
+ }
+ }
+
+ public static class TL_channelFull_layer134 extends ChatFull {
public static int constructor = 0x59cff963;
public void readParams(AbstractSerializedData stream, boolean exception) {
@@ -14691,12 +15010,14 @@ public class TLRPC {
}
public static class TL_codeSettings extends TLObject {
- public static int constructor = 0xdebebe83;
+ public static int constructor = 0x8a6469c2;
public int flags;
public boolean allow_flashcall;
public boolean current_number;
public boolean allow_app_hash;
+ public boolean allow_missed_call;
+ public ArrayList logout_tokens = new ArrayList<>();
public static TL_codeSettings TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_codeSettings.constructor != constructor) {
@@ -14716,6 +15037,20 @@ public class TLRPC {
allow_flashcall = (flags & 1) != 0;
current_number = (flags & 2) != 0;
allow_app_hash = (flags & 16) != 0;
+ allow_missed_call = (flags & 32) != 0;
+ if ((flags & 64) != 0) {
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ logout_tokens.add(stream.readByteArray(exception));
+ }
+ }
}
public void serializeToStream(AbstractSerializedData stream) {
@@ -14723,7 +15058,16 @@ public class TLRPC {
flags = allow_flashcall ? (flags | 1) : (flags &~ 1);
flags = current_number ? (flags | 2) : (flags &~ 2);
flags = allow_app_hash ? (flags | 16) : (flags &~ 16);
+ flags = allow_missed_call ? (flags | 32) : (flags &~ 32);
stream.writeInt32(flags);
+ if ((flags & 64) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = logout_tokens.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeByteArray(logout_tokens.get(a));
+ }
+ }
}
}
@@ -15522,56 +15866,64 @@ public class TLRPC {
public String fwd_text;
public boolean quiz;
public boolean requires_password;
+ public long user_id;
+ public InputUser inputUser;
- public static KeyboardButton TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
- KeyboardButton result = null;
- switch (constructor) {
- case 0xb16a6c29:
- result = new TL_keyboardButtonRequestPhone();
- break;
- case 0x50f41ccf:
- result = new TL_keyboardButtonGame();
- break;
- case 0x258aff05:
- result = new TL_keyboardButtonUrl();
- break;
- case 0x568a748:
- result = new TL_keyboardButtonSwitchInline();
- break;
- case 0xfc796b3f:
- result = new TL_keyboardButtonRequestGeoLocation();
- break;
- case 0x10b78d29:
- result = new TL_keyboardButtonUrlAuth();
- break;
+ public static KeyboardButton TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ KeyboardButton result = null;
+ switch (constructor) {
case 0xd02e7fd4:
result = new TL_inputKeyboardButtonUrlAuth();
break;
+ case 0xa2fa4880:
+ result = new TL_keyboardButton();
+ break;
+ case 0xfc796b3f:
+ result = new TL_keyboardButtonRequestGeoLocation();
+ break;
+ case 0x258aff05:
+ result = new TL_keyboardButtonUrl();
+ break;
+ case 0x50f41ccf:
+ result = new TL_keyboardButtonGame();
+ break;
+ case 0x683a5e46:
+ result = new TL_keyboardButtonCallback_layer117();
+ break;
+ case 0x568a748:
+ result = new TL_keyboardButtonSwitchInline();
+ break;
+ case 0xb16a6c29:
+ result = new TL_keyboardButtonRequestPhone();
+ break;
+ case 0x10b78d29:
+ result = new TL_keyboardButtonUrlAuth();
+ break;
case 0xbbc7515d:
result = new TL_keyboardButtonRequestPoll();
break;
- case 0xafd93fbb:
- result = new TL_keyboardButtonBuy();
- break;
- case 0x683a5e46:
- result = new TL_keyboardButtonCallback_layer117();
- break;
- case 0xa2fa4880:
- result = new TL_keyboardButton();
- break;
+ case 0xafd93fbb:
+ result = new TL_keyboardButtonBuy();
+ break;
+ case 0xe988037b:
+ result = new TL_inputKeyboardButtonUserProfile();
+ break;
+ case 0x308660c1:
+ result = new TL_keyboardButtonUserProfile();
+ break;
case 0x35bbdb6b:
result = new TL_keyboardButtonCallback();
break;
- }
- if (result == null && exception) {
- throw new RuntimeException(String.format("can't parse magic %x in KeyboardButton", constructor));
- }
- if (result != null) {
- result.readParams(stream, exception);
- }
- return result;
- }
- }
+ }
+ if (result == null && exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in KeyboardButton", constructor));
+ }
+ if (result != null) {
+ result.readParams(stream, exception);
+ }
+ return result;
+ }
+ }
public static class TL_keyboardButtonRequestPhone extends KeyboardButton {
public static int constructor = 0xb16a6c29;
@@ -15727,6 +16079,36 @@ public class TLRPC {
}
}
+ public static class TL_inputKeyboardButtonUserProfile extends KeyboardButton {
+ public static int constructor = 0xe988037b;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ text = stream.readString(exception);
+ inputUser = InputUser.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(text);
+ inputUser.serializeToStream(stream);
+ }
+ }
+
+ public static class TL_keyboardButtonUserProfile extends KeyboardButton {
+ public static int constructor = 0x308660c1;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ text = stream.readString(exception);
+ user_id = stream.readInt64(exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(text);
+ stream.writeInt64(user_id);
+ }
+ }
+
public static class TL_keyboardButtonBuy extends KeyboardButton {
public static int constructor = 0xafd93fbb;
@@ -22729,6 +23111,78 @@ public class TLRPC {
}
}
+ public static class TL_users_userFull extends TLObject {
+ public static int constructor = 0x3b6d152e;
+
+ public UserFull full_user;
+ public ArrayList chats = new ArrayList<>();
+ public ArrayList users = new ArrayList<>();
+
+ public static TL_users_userFull TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_users_userFull.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_users_userFull", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_users_userFull result = new TL_users_userFull();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ full_user = UserFull.TLdeserialize(stream, stream.readInt32(exception), exception);
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ Chat object = Chat.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ chats.add(object);
+ }
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ User object = User.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ users.add(object);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ full_user.serializeToStream(stream);
+ stream.writeInt32(0x1cb5c415);
+ int count = chats.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ chats.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = users.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ users.get(a).serializeToStream(stream);
+ }
+ }
+ }
+
public static class TL_shippingOption extends TLObject {
public static int constructor = 0xb6213cdf;
@@ -25950,6 +26404,78 @@ public class TLRPC {
}
}
+ public static class TL_messages_peerSettings extends TLObject {
+ public static int constructor = 0x6880b94d;
+
+ public TL_peerSettings settings;
+ public ArrayList chats = new ArrayList<>();
+ public ArrayList users = new ArrayList<>();
+
+ public static TL_messages_peerSettings TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_messages_peerSettings.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_messages_peerSettings", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_messages_peerSettings result = new TL_messages_peerSettings();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ settings = TL_peerSettings.TLdeserialize(stream, stream.readInt32(exception), exception);
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ Chat object = Chat.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ chats.add(object);
+ }
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ User object = User.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ users.add(object);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ settings.serializeToStream(stream);
+ stream.writeInt32(0x1cb5c415);
+ int count = chats.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ chats.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = users.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ users.get(a).serializeToStream(stream);
+ }
+ }
+ }
+
public static class TL_messages_checkedHistoryImportPeer extends TLObject {
public static int constructor = 0xa24de717;
@@ -28323,7 +28849,7 @@ public class TLRPC {
public TL_messages_stickerSet stickerset;
public void readParams(AbstractSerializedData stream, boolean exception) {
- stickerset = TL_messages_stickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
+ stickerset = messages_StickerSet.TLdeserialize(stream, stream.readInt32(exception), exception);
}
public void serializeToStream(AbstractSerializedData stream) {
@@ -29280,6 +29806,41 @@ public class TLRPC {
}
}
+ public static class TL_auth_loggedOut extends TLObject {
+ public static int constructor = 0xc3a2835f;
+
+ public int flags;
+ public byte[] future_auth_token;
+
+ public static TL_auth_loggedOut TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_auth_loggedOut.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_auth_loggedOut", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_auth_loggedOut result = new TL_auth_loggedOut();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ if ((flags & 1) != 0) {
+ future_auth_token = stream.readByteArray(exception);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ if ((flags & 1) != 0) {
+ stream.writeByteArray(future_auth_token);
+ }
+ }
+ }
+
public static abstract class UserProfilePhoto extends TLObject {
public int flags;
@@ -35897,6 +36458,9 @@ public class TLRPC {
case 0x50c7ac8:
result = new TL_channelAdminLogEventActionChangeLinkedChat();
break;
+ case 0x278f2868:
+ result = new TL_channelAdminLogEventActionSendMessage();
+ break;
case 0x1b7907ae:
result = new TL_channelAdminLogEventActionToggleInvites();
break;
@@ -35912,6 +36476,9 @@ public class TLRPC {
case 0x6e941a38:
result = new TL_channelAdminLogEventActionChangeHistoryTTL();
break;
+ case 0xcb2ac766:
+ result = new TL_channelAdminLogEventActionToggleNoForwards();
+ break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in ChannelAdminLogEventAction", constructor));
@@ -36388,6 +36955,21 @@ public class TLRPC {
}
}
+ public static class TL_channelAdminLogEventActionSendMessage extends ChannelAdminLogEventAction {
+ public static int constructor = 0x278f2868;
+
+ public Message message;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ message = Message.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ message.serializeToStream(stream);
+ }
+ }
+
public static class TL_channelAdminLogEventActionToggleInvites extends ChannelAdminLogEventAction {
public static int constructor = 0x1b7907ae;
@@ -36469,6 +37051,21 @@ public class TLRPC {
}
}
+ public static class TL_channelAdminLogEventActionToggleNoForwards extends ChannelAdminLogEventAction {
+ public static int constructor = 0xcb2ac766;
+
+ public boolean new_value;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ new_value = stream.readBool(exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeBool(new_value);
+ }
+ }
+
public static abstract class InputWebFileLocation extends TLObject {
public static InputWebFileLocation TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -36884,6 +37481,7 @@ public class TLRPC {
public boolean call_not_empty;
public boolean fake;
public boolean gigagroup;
+ public boolean noforwards;
public ArrayList restriction_reason = new ArrayList<>();
public TL_channelAdminRights_layer92 admin_rights_layer92;
public TL_channelBannedRights_layer92 banned_rights_layer92;
@@ -37075,6 +37673,7 @@ public class TLRPC {
deactivated = (flags & 32) != 0;
call_active = (flags & 8388608) != 0;
call_not_empty = (flags & 16777216) != 0;
+ noforwards = (flags & 33554432) != 0;
id = stream.readInt64(exception);
title = stream.readString(exception);
photo = ChatPhoto.TLdeserialize(stream, stream.readInt32(exception), exception);
@@ -37100,6 +37699,7 @@ public class TLRPC {
flags = deactivated ? (flags | 32) : (flags &~ 32);
flags = call_active ? (flags | 8388608) : (flags &~ 8388608);
flags = call_not_empty ? (flags | 16777216) : (flags &~ 16777216);
+ flags = noforwards ? (flags | 33554432) : (flags &~ 33554432);
stream.writeInt32(flags);
stream.writeInt64(id);
stream.writeString(title);
@@ -37354,6 +37954,7 @@ public class TLRPC {
call_not_empty = (flags & 16777216) != 0;
fake = (flags & 33554432) != 0;
gigagroup = (flags & 67108864) != 0;
+ noforwards = (flags & 134217728) != 0;
id = stream.readInt64(exception);
if ((flags & 8192) != 0) {
access_hash = stream.readInt64(exception);
@@ -37413,6 +38014,7 @@ public class TLRPC {
flags = call_not_empty ? (flags | 16777216) : (flags &~ 16777216);
flags = fake ? (flags | 33554432) : (flags &~ 33554432);
flags = gigagroup ? (flags | 67108864) : (flags &~ 67108864);
+ flags = noforwards ? (flags | 134217728) : (flags &~ 134217728);
stream.writeInt32(flags);
stream.writeInt64(id);
if ((flags & 8192) != 0) {
@@ -38690,6 +39292,9 @@ public class TLRPC {
case 0x226ccefb:
result = new TL_auth_codeTypeFlashCall();
break;
+ case 0xd61ad6ee:
+ result = new TL_auth_codeTypeMissedCall();
+ break;
}
if (result == null && exception) {
throw new RuntimeException(String.format("can't parse magic %x in auth_CodeType", constructor));
@@ -38728,6 +39333,15 @@ public class TLRPC {
}
}
+ public static class TL_auth_codeTypeMissedCall extends auth_CodeType {
+ public static int constructor = 0xd61ad6ee;
+
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ }
+ }
+
public static abstract class MessagesFilter extends TLObject {
public int flags;
public boolean missed;
@@ -40490,13 +41104,18 @@ public class TLRPC {
public int ttl_period;
public TL_peerSettings settings;
public String theme_emoticon;
+ public long id;
+ public String private_forward_name;
public static UserFull TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
UserFull result = null;
switch (constructor) {
- case 0xd697ff05:
+ case 0xcf366521:
result = new TL_userFull();
break;
+ case 0xd697ff05:
+ result = new TL_userFull_layer134();
+ break;
case 0x139a9a77:
result = new TL_userFull_layer131();
break;
@@ -40521,6 +41140,87 @@ public class TLRPC {
}
public static class TL_userFull extends UserFull {
+ public static int constructor = 0xcf366521;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ blocked = (flags & 1) != 0;
+ phone_calls_available = (flags & 16) != 0;
+ phone_calls_private = (flags & 32) != 0;
+ can_pin_message = (flags & 128) != 0;
+ has_scheduled = (flags & 4096) != 0;
+ video_calls_available = (flags & 8192) != 0;
+ id = stream.readInt64(exception);
+ if ((flags & 2) != 0) {
+ about = stream.readString(exception);
+ }
+ settings = TL_peerSettings.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if ((flags & 4) != 0) {
+ profile_photo = Photo.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ notify_settings = PeerNotifySettings.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if ((flags & 8) != 0) {
+ bot_info = BotInfo.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 64) != 0) {
+ pinned_msg_id = stream.readInt32(exception);
+ }
+ common_chats_count = stream.readInt32(exception);
+ if ((flags & 2048) != 0) {
+ folder_id = stream.readInt32(exception);
+ }
+ if ((flags & 16384) != 0) {
+ ttl_period = stream.readInt32(exception);
+ }
+ if ((flags & 32768) != 0) {
+ theme_emoticon = stream.readString(exception);
+ }
+ if ((flags & 65536) != 0) {
+ private_forward_name = stream.readString(exception);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = blocked ? (flags | 1) : (flags &~ 1);
+ flags = phone_calls_available ? (flags | 16) : (flags &~ 16);
+ flags = phone_calls_private ? (flags | 32) : (flags &~ 32);
+ flags = can_pin_message ? (flags | 128) : (flags &~ 128);
+ flags = has_scheduled ? (flags | 4096) : (flags &~ 4096);
+ flags = video_calls_available ? (flags | 8192) : (flags &~ 8192);
+ stream.writeInt32(flags);
+ stream.writeInt64(id);
+ if ((flags & 2) != 0) {
+ stream.writeString(about);
+ }
+ settings.serializeToStream(stream);
+ if ((flags & 4) != 0) {
+ profile_photo.serializeToStream(stream);
+ }
+ notify_settings.serializeToStream(stream);
+ if ((flags & 8) != 0) {
+ bot_info.serializeToStream(stream);
+ }
+ if ((flags & 64) != 0) {
+ stream.writeInt32(pinned_msg_id);
+ }
+ stream.writeInt32(common_chats_count);
+ if ((flags & 2048) != 0) {
+ stream.writeInt32(folder_id);
+ }
+ if ((flags & 16384) != 0) {
+ stream.writeInt32(ttl_period);
+ }
+ if ((flags & 32768) != 0) {
+ stream.writeString(theme_emoticon);
+ }
+ if ((flags & 65536) != 0) {
+ stream.writeString(private_forward_name);
+ }
+ }
+ }
+
+ public static class TL_userFull_layer134 extends TL_userFull {
public static int constructor = 0xd697ff05;
@@ -43194,52 +43894,55 @@ public class TLRPC {
}
}
- public static class TL_account_authorizations extends TLObject {
- public static int constructor = 0x1250abde;
+ public static class TL_account_authorizations extends TLObject {
+ public static int constructor = 0x4bff8ea0;
- public ArrayList authorizations = new ArrayList<>();
+ public int authorization_ttl_days;
+ public ArrayList authorizations = new ArrayList<>();
- public static TL_account_authorizations TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
- if (TL_account_authorizations.constructor != constructor) {
- if (exception) {
- throw new RuntimeException(String.format("can't parse magic %x in TL_account_authorizations", constructor));
- } else {
- return null;
- }
+ public static TL_account_authorizations TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_account_authorizations.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_account_authorizations", constructor));
+ } else {
+ return null;
+ }
}
TL_account_authorizations result = new TL_account_authorizations();
- result.readParams(stream, exception);
- return result;
- }
+ result.readParams(stream, exception);
+ return result;
+ }
- public void readParams(AbstractSerializedData stream, boolean exception) {
- int magic = stream.readInt32(exception);
- if (magic != 0x1cb5c415) {
- if (exception) {
- throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
- }
- return;
- }
- int count = stream.readInt32(exception);
- for (int a = 0; a < count; a++) {
- TL_authorization object = TL_authorization.TLdeserialize(stream, stream.readInt32(exception), exception);
- if (object == null) {
- return;
- }
- authorizations.add(object);
- }
- }
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ authorization_ttl_days = stream.readInt32(exception);
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ TL_authorization object = TL_authorization.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ authorizations.add(object);
+ }
+ }
- public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- stream.writeInt32(0x1cb5c415);
- int count = authorizations.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- authorizations.get(a).serializeToStream(stream);
- }
- }
- }
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(authorization_ttl_days);
+ stream.writeInt32(0x1cb5c415);
+ int count = authorizations.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ authorizations.get(a).serializeToStream(stream);
+ }
+ }
+ }
public static class TL_paymentRequestedInfo extends TLObject {
public static int constructor = 0x909c3f94;
@@ -43358,18 +44061,18 @@ public class TLRPC {
}
}
- public static class TL_auth_logOut extends TLObject {
- public static int constructor = 0x5717da40;
+ public static class TL_auth_logOut extends TLObject {
+ public static int constructor = 0x3e72ba19;
- 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 TL_auth_loggedOut.TLdeserialize(stream, constructor, exception);
+ }
public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- }
- }
+ stream.writeInt32(constructor);
+ }
+ }
public static class TL_auth_resetAuthorizations extends TLObject {
public static int constructor = 0x9fab0d1a;
@@ -43732,20 +44435,60 @@ public class TLRPC {
}
}
- public static class TL_users_getFullUser extends TLObject {
- public static int constructor = 0xca30a5b1;
+ public static class TL_account_setAuthorizationTTL extends TLObject {
+ public static int constructor = 0xbf899aa0;
- public InputUser id;
+ public int authorization_ttl_days;
- public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
- return UserFull.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);
- id.serializeToStream(stream);
- }
- }
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(authorization_ttl_days);
+ }
+ }
+
+ public static class TL_account_changeAuthorizationSettings extends TLObject {
+ public static int constructor = 0x40f48462;
+
+ public int flags;
+ public long hash;
+ public boolean encrypted_requests_disabled;
+ public boolean call_requests_disabled;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Bool.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ stream.writeInt64(hash);
+ if ((flags & 1) != 0) {
+ stream.writeBool(encrypted_requests_disabled);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeBool(call_requests_disabled);
+ }
+ }
+ }
+
+ public static class TL_users_getFullUser extends TLObject {
+ public static int constructor = 0xb60f5918;
+
+ public InputUser id;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return TL_users_userFull.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ id.serializeToStream(stream);
+ }
+ }
public static class TL_contacts_getStatuses extends TLObject {
public static int constructor = 0xc4a353ee;
@@ -44630,7 +45373,7 @@ public class TLRPC {
}
public static class TL_messages_sendMessage extends TLObject {
- public static int constructor = 0x520c3870;
+ public static int constructor = 0xd9d75a4;
public int flags;
public boolean no_webpage;
@@ -44644,6 +45387,7 @@ public class TLRPC {
public ReplyMarkup reply_markup;
public ArrayList entities = new ArrayList<>();
public int schedule_date;
+ public InputPeer send_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@@ -44676,11 +45420,14 @@ public class TLRPC {
if ((flags & 1024) != 0) {
stream.writeInt32(schedule_date);
}
+ if ((flags & 8192) != 0) {
+ send_as.serializeToStream(stream);
+ }
}
}
public static class TL_messages_sendMedia extends TLObject {
- public static int constructor = 0x3491eba9;
+ public static int constructor = 0xe25ff8e0;
public int flags;
public boolean silent;
@@ -44694,6 +45441,7 @@ public class TLRPC {
public ReplyMarkup reply_markup;
public ArrayList entities = new ArrayList<>();
public int schedule_date;
+ public InputPeer send_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@@ -44726,11 +45474,14 @@ public class TLRPC {
if ((flags & 1024) != 0) {
stream.writeInt32(schedule_date);
}
+ if ((flags & 8192) != 0) {
+ send_as.serializeToStream(stream);
+ }
}
}
public static class TL_messages_forwardMessages extends TLObject {
- public static int constructor = 0xd9fee60e;
+ public static int constructor = 0xcc30290b;
public int flags;
public boolean silent;
@@ -44743,6 +45494,7 @@ public class TLRPC {
public ArrayList random_id = new ArrayList<>();
public InputPeer to_peer;
public int schedule_date;
+ public InputPeer send_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@@ -44773,6 +45525,9 @@ public class TLRPC {
if ((flags & 1024) != 0) {
stream.writeInt32(schedule_date);
}
+ if ((flags & 8192) != 0) {
+ send_as.serializeToStream(stream);
+ }
}
}
@@ -44791,20 +45546,20 @@ public class TLRPC {
}
}
- public static class TL_messages_getPeerSettings extends TLObject {
- public static int constructor = 0x3672e09c;
+ public static class TL_messages_getPeerSettings extends TLObject {
+ public static int constructor = 0xefd9a6a2;
- public InputPeer peer;
+ public InputPeer peer;
- public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
- return TL_peerSettings.TLdeserialize(stream, constructor, exception);
- }
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return TL_messages_peerSettings.TLdeserialize(stream, constructor, exception);
+ }
- public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- peer.serializeToStream(stream);
- }
- }
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ peer.serializeToStream(stream);
+ }
+ }
public static class TL_messages_report extends TLObject {
public static int constructor = 0x8953ab4e;
@@ -46831,7 +47586,7 @@ public class TLRPC {
}
public static class TL_messages_sendInlineBotResult extends TLObject {
- public static int constructor = 0x220815b0;
+ public static int constructor = 0x7aa11297;
public int flags;
public boolean silent;
@@ -46844,6 +47599,7 @@ public class TLRPC {
public long query_id;
public String id;
public int schedule_date;
+ public InputPeer send_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@@ -46866,6 +47622,9 @@ public class TLRPC {
if ((flags & 1024) != 0) {
stream.writeInt32(schedule_date);
}
+ if ((flags & 8192) != 0) {
+ send_as.serializeToStream(stream);
+ }
}
}
@@ -47541,7 +48300,7 @@ public class TLRPC {
}
public static class TL_messages_sendMultiMedia extends TLObject {
- public static int constructor = 0xcc0110cb;
+ public static int constructor = 0xf803138f;
public int flags;
public boolean silent;
@@ -47551,6 +48310,7 @@ public class TLRPC {
public int reply_to_msg_id;
public ArrayList multi_media = new ArrayList<>();
public int schedule_date;
+ public InputPeer send_as;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
@@ -47575,6 +48335,9 @@ public class TLRPC {
if ((flags & 1024) != 0) {
stream.writeInt32(schedule_date);
}
+ if ((flags & 8192) != 0) {
+ send_as.serializeToStream(stream);
+ }
}
}
@@ -48636,6 +49399,63 @@ public class TLRPC {
}
}
+ public static class TL_messages_hideAllChatJoinRequests extends TLObject {
+ public static int constructor = 0xe085f4ea;
+
+ public int flags;
+ public boolean approved;
+ public InputPeer peer;
+ public String link;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Updates.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = approved ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
+ peer.serializeToStream(stream);
+ if ((flags & 2) != 0) {
+ stream.writeString(link);
+ }
+ }
+ }
+
+ public static class TL_messages_toggleNoForwards extends TLObject {
+ public static int constructor = 0xb11eafa2;
+
+ public InputPeer peer;
+ public boolean enabled;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Updates.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ peer.serializeToStream(stream);
+ stream.writeBool(enabled);
+ }
+ }
+
+ public static class TL_messages_saveDefaultSendAs extends TLObject {
+ public static int constructor = 0xccfddf96;
+
+ public InputPeer peer;
+ public InputPeer send_as;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Bool.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ peer.serializeToStream(stream);
+ send_as.serializeToStream(stream);
+ }
+ }
+
public static class TL_messages_setHistoryTTL extends TLObject {
public static int constructor = 0xb80e5fe4;
@@ -49068,22 +49888,22 @@ public class TLRPC {
}
}
- public static class TL_channels_deleteUserHistory extends TLObject {
- public static int constructor = 0xd10dd71b;
+ public static class TL_channels_deleteParticipantHistory extends TLObject {
+ public static int constructor = 0x367544db;
- public InputChannel channel;
- public InputUser user_id;
+ public InputChannel channel;
+ public InputPeer participant;
- public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
- return TL_messages_affectedHistory.TLdeserialize(stream, constructor, exception);
- }
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return TL_messages_affectedHistory.TLdeserialize(stream, constructor, exception);
+ }
- public void serializeToStream(AbstractSerializedData stream) {
- stream.writeInt32(constructor);
- channel.serializeToStream(stream);
- user_id.serializeToStream(stream);
- }
- }
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ channel.serializeToStream(stream);
+ participant.serializeToStream(stream);
+ }
+ }
public static class TL_channels_reportSpam extends TLObject {
public static int constructor = 0xfe087810;
@@ -49667,6 +50487,21 @@ public class TLRPC {
}
}
+ public static class TL_channels_getSendAs extends TLObject {
+ public static int constructor = 0xdc770ee;
+
+ public InputPeer peer;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return TL_channels_sendAsPeers.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ peer.serializeToStream(stream);
+ }
+ }
+
public static class TL_stickers_createStickerSet extends TLObject {
public static int constructor = 0x9021ab67;
@@ -50951,6 +51786,97 @@ public class TLRPC {
}
//RichText end
+ public static class TL_channels_sendAsPeers extends TLObject {
+ public static int constructor = 0x8356cda9;
+
+ public ArrayList peers = new ArrayList<>();
+ public ArrayList chats = new ArrayList<>();
+ public ArrayList users = new ArrayList<>();
+
+ public static TL_channels_sendAsPeers TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_channels_sendAsPeers.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_channels_sendAsPeers", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_channels_sendAsPeers result = new TL_channels_sendAsPeers();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ int magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ int count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ Peer object = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ peers.add(object);
+ }
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ Chat object = Chat.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ chats.add(object);
+ }
+ magic = stream.readInt32(exception);
+ if (magic != 0x1cb5c415) {
+ if (exception) {
+ throw new RuntimeException(String.format("wrong Vector magic, got %x", magic));
+ }
+ return;
+ }
+ count = stream.readInt32(exception);
+ for (int a = 0; a < count; a++) {
+ User object = User.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ users.add(object);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(0x1cb5c415);
+ int count = peers.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ peers.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = chats.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ chats.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = users.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ users.get(a).serializeToStream(stream);
+ }
+ }
+ }
+
//MessageMedia start
public static abstract class MessageMedia extends TLObject {
public byte[] bytes;
@@ -51513,6 +52439,7 @@ public class TLRPC {
public TL_messageReactions reactions;
public ArrayList restriction_reason = new ArrayList<>();
public int ttl_period;
+ public boolean noforwards;
public int send_state = 0; //custom
public int fwd_msg_id = 0; //custom
public String attachPath = ""; //custom
@@ -52322,6 +53249,7 @@ public class TLRPC {
legacy = (flags & 524288) != 0;
edit_hide = (flags & 2097152) != 0;
pinned = (flags & 16777216) != 0;
+ noforwards = (flags & 67108864) != 0;
id = stream.readInt32(exception);
if ((flags & 256) != 0) {
from_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
@@ -52418,6 +53346,7 @@ public class TLRPC {
flags = legacy ? (flags | 524288) : (flags &~ 524288);
flags = edit_hide ? (flags | 2097152) : (flags &~ 2097152);
flags = pinned ? (flags | 16777216) : (flags &~ 16777216);
+ flags = noforwards ? (flags | 67108864) : (flags &~ 67108864);
stream.writeInt32(flags);
stream.writeInt32(id);
if ((flags & 256) != 0) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
index 2d6a9fb8a..6d5e79ba3 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
@@ -44,6 +44,7 @@ import android.view.ViewOutlineProvider;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
+import android.widget.LinearLayout;
import com.google.android.exoplayer2.util.Log;
@@ -191,12 +192,13 @@ public class ActionBarLayout extends FrameLayout {
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
- if ((inPreviewMode || transitionAnimationPreviewMode) && (ev.getActionMasked() == MotionEvent.ACTION_DOWN || ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN)) {
+ boolean passivePreview = inPreviewMode && previewMenu == null;
+ if ((passivePreview || transitionAnimationPreviewMode) && (ev.getActionMasked() == MotionEvent.ACTION_DOWN || ev.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN)) {
return false;
}
//
try {
- return (!inPreviewMode || this != containerView) && super.dispatchTouchEvent(ev);
+ return (!passivePreview || this != containerView) && super.dispatchTouchEvent(ev);
} catch (Throwable e) {
FileLog.e(e);
}
@@ -261,7 +263,7 @@ public class ActionBarLayout extends FrameLayout {
private boolean previewOpenAnimationInProgress;
private ColorDrawable previewBackgroundDrawable;
- private LayoutContainer containerView;
+ public LayoutContainer containerView; /* Contest: private -> public temp hack bc I don't know how to blur action bar otherwise */
private LayoutContainer containerViewBack;
private DrawerLayoutContainer drawerLayoutContainer;
private ActionBar currentActionBar;
@@ -269,6 +271,9 @@ public class ActionBarLayout extends FrameLayout {
private BaseFragment newFragment;
private BaseFragment oldFragment;
+ /* Contest */
+ private View previewMenu;
+
private AnimatorSet currentAnimation;
private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator(1.5f);
private AccelerateDecelerateInterpolator accelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator();
@@ -580,10 +585,12 @@ public class ActionBarLayout extends FrameLayout {
if (view != null) {
previewBackgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
previewBackgroundDrawable.draw(canvas);
- int x = (getMeasuredWidth() - AndroidUtilities.dp(24)) / 2;
- int y = (int) (view.getTop() + containerView.getTranslationY() - AndroidUtilities.dp(12 + (Build.VERSION.SDK_INT < 21 ? 20 : 0)));
- Theme.moveUpDrawable.setBounds(x, y, x + AndroidUtilities.dp(24), y + AndroidUtilities.dp(24));
- Theme.moveUpDrawable.draw(canvas);
+ if (previewMenu == null) {
+ int x = (getMeasuredWidth() - AndroidUtilities.dp(24)) / 2;
+ int y = (int) (view.getTop() + containerView.getTranslationY() - AndroidUtilities.dp(12 + (Build.VERSION.SDK_INT < 21 ? 20 : 0)));
+ Theme.moveUpDrawable.setBounds(x, y, x + AndroidUtilities.dp(24), y + AndroidUtilities.dp(24));
+ Theme.moveUpDrawable.draw(canvas);
+ }
}
}
@@ -941,15 +948,19 @@ public class ActionBarLayout extends FrameLayout {
}
public boolean presentFragmentAsPreview(BaseFragment fragment) {
- return presentFragment(fragment, false, false, true, true);
+ return presentFragment(fragment, false, false, true, true, null);
+ }
+
+ public boolean presentFragmentAsPreviewWithMenu(BaseFragment fragment, View menu) {
+ return presentFragment(fragment, false, false, true, true, menu);
}
public boolean presentFragment(BaseFragment fragment) {
- return presentFragment(fragment, false, false, true, false);
+ return presentFragment(fragment, false, false, true, false, null);
}
public boolean presentFragment(BaseFragment fragment, boolean removeLast) {
- return presentFragment(fragment, removeLast, false, true, false);
+ return presentFragment(fragment, removeLast, false, true, false, null);
}
private void startLayoutAnimation(final boolean open, final boolean first, final boolean preview) {
@@ -1038,11 +1049,25 @@ public class ActionBarLayout extends FrameLayout {
return inPreviewMode || transitionAnimationPreviewMode;
}
+ public boolean isInPassivePreviewMode() {
+ return (inPreviewMode && previewMenu == null) || transitionAnimationPreviewMode;
+ }
+
+ public boolean isInPreviewMenuMode() {
+ return isInPreviewMode() && previewMenu != null;
+ }
+
+
public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation, boolean check, final boolean preview) {
+ return presentFragment(fragment, removeLast, forceWithoutAnimation, check, preview, null);
+ }
+
+ public boolean presentFragment(final BaseFragment fragment, final boolean removeLast, boolean forceWithoutAnimation, boolean check, final boolean preview, View menu) {
if (fragment == null || checkTransitionAnimation() || delegate != null && check && !delegate.needPresentFragment(fragment, removeLast, forceWithoutAnimation, this) || !fragment.onFragmentCreate()) {
return false;
}
fragment.setInPreviewMode(preview);
+ fragment.setInMenuMode(menu != null);
if (parentActivity.getCurrentFocus() != null && fragment.hideKeyboardOnShow() && !preview) {
AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
}
@@ -1061,8 +1086,20 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView);
}
}
- containerViewBack.addView(fragmentView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragmentView.getLayoutParams();
+ View wrappedView = fragmentView;
+ containerViewBack.addView(wrappedView);
+ int menuHeight = 0;
+ if (menu != null) {
+ containerViewBack.addView(menu);
+ menu.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST));
+ menuHeight = menu.getMeasuredHeight() + AndroidUtilities.dp(24);
+ FrameLayout.LayoutParams menuParams = (FrameLayout.LayoutParams) menu.getLayoutParams();
+ menuParams.width = LayoutHelper.WRAP_CONTENT;
+ menuParams.height = LayoutHelper.WRAP_CONTENT;
+ menuParams.topMargin = getMeasuredHeight() - menuHeight - AndroidUtilities.dp(6);
+ menu.setLayoutParams(menuParams);
+ }
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) wrappedView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
if (preview) {
@@ -1072,14 +1109,17 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.height = height;
layoutParams.topMargin = statusBarHeight + (getMeasuredHeight() - statusBarHeight - height) / 2;
} else {
- layoutParams.topMargin = layoutParams.bottomMargin = AndroidUtilities.dp(46);
+ layoutParams.topMargin = layoutParams.bottomMargin = AndroidUtilities.dp(menu != null ? 0 : 46);
layoutParams.topMargin += AndroidUtilities.statusBarHeight;
}
+ if (menu != null) {
+ layoutParams.bottomMargin += menuHeight + AndroidUtilities.dp(8);
+ }
layoutParams.rightMargin = layoutParams.leftMargin = AndroidUtilities.dp(8);
} else {
layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
}
- fragmentView.setLayoutParams(layoutParams);
+ wrappedView.setLayoutParams(layoutParams);
if (fragment.actionBar != null && fragment.actionBar.shouldAddToContainer()) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
@@ -1179,6 +1219,7 @@ public class ActionBarLayout extends FrameLayout {
onOpenAnimationEndRunnable = () -> {
if (preview) {
inPreviewMode = true;
+ previewMenu = menu;
transitionAnimationPreviewMode = false;
containerView.setScaleX(1.0f);
containerView.setScaleY(1.0f);
@@ -1346,7 +1387,7 @@ public class ActionBarLayout extends FrameLayout {
}
public void movePreviewFragment(float dy) {
- if (!inPreviewMode || transitionAnimationPreviewMode) {
+ if (!inPreviewMode || transitionAnimationPreviewMode || previewMenu != null) {
return;
}
float currentTranslation = containerView.getTranslationY();
@@ -1486,10 +1527,21 @@ public class ActionBarLayout extends FrameLayout {
layoutToIgnore = containerView;
final BaseFragment previousFragmentFinal = previousFragment;
onCloseAnimationEndRunnable = () -> {
+ if (previewMenu != null) {
+ ViewGroup parent = (ViewGroup) previewMenu.getParent();
+ if (parent != null) {
+ //ViewGroup grandparent = (ViewGroup) parent.getParent();
+ parent.removeView(previewMenu);
+ /*if (grandparent != null) {
+ grandparent.removeView(parent);
+ }*/
+ }
+ }
if (inPreviewMode || transitionAnimationPreviewMode) {
containerViewBack.setScaleX(1.0f);
containerViewBack.setScaleY(1.0f);
inPreviewMode = false;
+ previewMenu = null;
transitionAnimationPreviewMode = false;
} else {
containerViewBack.setTranslationX(0);
@@ -2088,4 +2140,4 @@ public class ActionBarLayout extends FrameLayout {
}
}
}
-}
+}
\ No newline at end of file
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 fefac3a21..e3b25c574 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
@@ -1593,6 +1593,23 @@ public class ActionBarMenuItem extends FrameLayout {
}
}
+ /**
+ * Hides this menu item if no subitems are available
+ */
+ public void checkHideMenuItem() {
+ boolean isVisible = false;
+ for (int i = 0; i < popupLayout.getItemsCount(); i++) {
+ if (popupLayout.getItemAt(i).getVisibility() == VISIBLE) {
+ isVisible = true;
+ break;
+ }
+ }
+ int v = isVisible ? VISIBLE : GONE;
+ if (v != getVisibility()) {
+ setVisibility(v);
+ }
+ }
+
public void hideAllSubItems() {
if (popupLayout == null) {
return;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java
index e5982c48f..4685fb50a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java
@@ -88,6 +88,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
private int topResId;
private View topView;
private int topAnimationId;
+ private int topAnimationSize;
private int topHeight = 132;
private Drawable topDrawable;
private int topBackgroundColor;
@@ -138,6 +139,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
private float aspectRatio;
private boolean dimEnabled = true;
private final Theme.ResourcesProvider resourcesProvider;
+ private boolean topAnimationAutoRepeat = true;
public static class AlertDialogCell extends FrameLayout {
@@ -461,8 +463,8 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
} else if (topResId != 0) {
topImageView.setImageResource(topResId);
} else {
- topImageView.setAutoRepeat(true);
- topImageView.setAnimation(topAnimationId, 94, 94);
+ topImageView.setAutoRepeat(topAnimationAutoRepeat);
+ topImageView.setAnimation(topAnimationId, topAnimationSize, topAnimationSize);
topImageView.playAnimation();
}
topImageView.setScaleType(ImageView.ScaleType.CENTER);
@@ -1059,7 +1061,11 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
}
public void setTopAnimation(int resId, int backgroundColor) {
+ setTopAnimation(resId, 94, backgroundColor);
+ }
+ public void setTopAnimation(int resId, int size, int backgroundColor) {
topAnimationId = resId;
+ topAnimationSize = size;
topBackgroundColor = backgroundColor;
}
@@ -1273,11 +1279,16 @@ public class AlertDialog extends Dialog implements Drawable.Callback {
return this;
}
- public Builder setTopAnimation(int resId, int backgroundColor) {
+ public Builder setTopAnimation(int resId, int size, boolean autoRepeat, int backgroundColor) {
alertDialog.topAnimationId = resId;
+ alertDialog.topAnimationSize = size;
+ alertDialog.topAnimationAutoRepeat = autoRepeat;
alertDialog.topBackgroundColor = backgroundColor;
return this;
}
+ public Builder setTopAnimation(int resId, int backgroundColor) {
+ return setTopAnimation(resId, 94, true, backgroundColor);
+ }
public Builder setTopImage(Drawable drawable, int backgroundColor) {
alertDialog.topDrawable = drawable;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
index cca31bc25..377108284 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
@@ -61,6 +61,7 @@ public abstract class BaseFragment {
protected ActionBarLayout parentLayout;
protected ActionBar actionBar;
protected boolean inPreviewMode;
+ protected boolean inMenuMode;
protected boolean inBubbleMode;
protected int classGuid;
protected Bundle arguments;
@@ -122,6 +123,14 @@ public abstract class BaseFragment {
return inBubbleMode;
}
+ public boolean getInPreviewMode() {
+ return inPreviewMode;
+ }
+
+ public boolean getInPassivePreviewMode() {
+ return parentLayout != null && parentLayout.isInPassivePreviewMode();
+ }
+
protected void setInPreviewMode(boolean value) {
inPreviewMode = value;
if (actionBar != null) {
@@ -133,6 +142,10 @@ public abstract class BaseFragment {
}
}
+ protected void setInMenuMode(boolean value) {
+ inMenuMode = value;
+ }
+
protected void onPreviewOpenAnimationEnd() {
}
@@ -361,19 +374,23 @@ public abstract class BaseFragment {
}
public boolean presentFragmentAsPreview(BaseFragment fragment) {
- return parentLayout != null && parentLayout.presentFragmentAsPreview(fragment);
+ return allowPresentFragment() && parentLayout != null && parentLayout.presentFragmentAsPreview(fragment);
+ }
+
+ public boolean presentFragmentAsPreviewWithMenu(BaseFragment fragment, View menu) {
+ return allowPresentFragment() && parentLayout != null && parentLayout.presentFragmentAsPreviewWithMenu(fragment, menu);
}
public boolean presentFragment(BaseFragment fragment) {
- return parentLayout != null && parentLayout.presentFragment(fragment);
+ return allowPresentFragment() && parentLayout != null && parentLayout.presentFragment(fragment);
}
public boolean presentFragment(BaseFragment fragment, boolean removeLast) {
- return parentLayout != null && parentLayout.presentFragment(fragment, removeLast);
+ return allowPresentFragment() && parentLayout != null && parentLayout.presentFragment(fragment, removeLast);
}
public boolean presentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation) {
- return parentLayout != null && parentLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, true, false);
+ return allowPresentFragment() && parentLayout != null && parentLayout.presentFragment(fragment, removeLast, forceWithoutAnimation, true, false, null);
}
public Activity getParentActivity() {
@@ -713,4 +730,9 @@ public abstract class BaseFragment {
public Theme.ResourcesProvider getResourceProvider() {
return null;
}
-}
+
+ protected boolean allowPresentFragment() {
+ return true;
+ }
+
+}
\ No newline at end of file
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java
index c55136a4a..adafad47e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java
@@ -165,6 +165,7 @@ public class BottomSheet extends Dialog {
private ValueAnimator keyboardContentAnimator;
protected boolean smoothKeyboardAnimationEnabled;
+ private boolean openNoDelay;
protected class ContainerView extends FrameLayout implements NestedScrollingParent {
@@ -1024,7 +1025,7 @@ public class BottomSheet extends Dialog {
startAnimationRunnable = null;
startOpenAnimation();
}
- }, 150);
+ }, openNoDelay ? 0 : 150);
} else {
startOpenAnimation();
}
@@ -1540,4 +1541,8 @@ public class BottomSheet extends Dialog {
Integer color = resourcesProvider != null ? resourcesProvider.getColor(key) : null;
return color != null ? color : Theme.getColor(key);
}
+
+ public void setOpenNoDelay(boolean openNoDelay) {
+ this.openNoDelay = openNoDelay;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/EmojiThemes.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/EmojiThemes.java
index 3801ad080..ab2c786d6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/EmojiThemes.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/EmojiThemes.java
@@ -7,8 +7,6 @@ import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.util.Pair;
-import com.google.android.exoplayer2.util.Log;
-
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ChatThemeController;
@@ -21,7 +19,6 @@ import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.ResultCallback;
import org.telegram.tgnet.TLRPC;
-import org.telegram.ui.Components.ChatThemeBottomSheet;
import java.io.File;
import java.io.FileOutputStream;
@@ -36,6 +33,17 @@ public class EmojiThemes {
int currentIndex = 0;
ArrayList items = new ArrayList<>();
+ private static final String[] previewColorKeys = new String[]{
+ Theme.key_chat_inBubble,
+ Theme.key_chat_outBubble,
+ Theme.key_featuredStickers_addButton,
+ Theme.key_chat_wallpaper,
+ Theme.key_chat_wallpaper_gradient_to1,
+ Theme.key_chat_wallpaper_gradient_to2,
+ Theme.key_chat_wallpaper_gradient_to3,
+ Theme.key_chat_wallpaper_gradient_rotation
+ };
+
private EmojiThemes() {
}
@@ -98,8 +106,20 @@ public class EmojiThemes {
Theme.ThemeInfo themeInfo = Theme.getTheme(lastDayCustomTheme);
if (themeInfo == null) {
lastDayCustomTheme = "Blue";
+ dayAccentId = 99;
+ } else {
+ dayAccentId = themeInfo.currentAccentId;
}
preferences.edit().putString("lastDayCustomTheme", lastDayCustomTheme).apply();
+ } else {
+ if (dayAccentId == -1) {
+ dayAccentId = Theme.getTheme(lastDayCustomTheme).lastAccentId;
+ }
+ }
+
+ if (dayAccentId == -1) {
+ lastDayCustomTheme = "Blue";
+ dayAccentId = 99;
}
String lastDarkCustomTheme = preferences.getString("lastDarkCustomTheme", null);
@@ -109,10 +129,21 @@ public class EmojiThemes {
Theme.ThemeInfo themeInfo = Theme.getTheme(lastDarkCustomTheme);
if (themeInfo == null) {
lastDarkCustomTheme = "Dark Blue";
+ darkAccentId = 0;
+ } else {
+ darkAccentId = themeInfo.currentAccentId;
}
preferences.edit().putString("lastDarkCustomTheme", lastDarkCustomTheme).apply();
+ } else {
+ if (darkAccentId == -1) {
+ darkAccentId = Theme.getTheme(lastDayCustomTheme).lastAccentId;
+ }
}
+ if (darkAccentId == -1) {
+ lastDarkCustomTheme = "Dark Blue";
+ darkAccentId = 0;
+ }
ThemeItem lightTheme = new ThemeItem();
lightTheme.themeInfo = Theme.getTheme(lastDayCustomTheme);
@@ -156,8 +187,8 @@ public class EmojiThemes {
}
public void initColors() {
- getCurrentColors(0, 0);
- getCurrentColors(0, 1);
+ getPreviewColors(0, 0);
+ getPreviewColors(0, 1);
}
public String getEmoticon() {
@@ -184,8 +215,8 @@ public class EmojiThemes {
return items.get(index).settingsIndex;
}
- public HashMap getCurrentColors(int currentAccount, int index) {
- HashMap currentColors = items.get(index).currentColors;
+ public HashMap getPreviewColors(int currentAccount, int index) {
+ HashMap currentColors = items.get(index).currentPreviewColors;
if (currentColors != null) {
return currentColors;
}
@@ -215,9 +246,64 @@ public class EmojiThemes {
items.get(index).wallpaperLink = wallpaperLink[0];
- currentColors = new HashMap<>(currentColorsNoAccent);
if (accent != null) {
+ currentColors = new HashMap<>(currentColorsNoAccent);
accent.fillAccentColors(currentColorsNoAccent, currentColors);
+ currentColorsNoAccent.clear();
+ } else {
+ currentColors = currentColorsNoAccent;
+ }
+
+ HashMap fallbackKeys = Theme.getFallbackKeys();
+ items.get(index).currentPreviewColors = new HashMap<>();
+ for (int i = 0; i < previewColorKeys.length; i++) {
+ String key = previewColorKeys[i];
+ items.get(index).currentPreviewColors.put(key, currentColors.get(key));
+
+ if (!items.get(index).currentPreviewColors.containsKey(key)) {
+ Integer color = currentColors.get(fallbackKeys.get(key));
+ currentColors.put(key, color);
+ }
+ }
+ currentColors.clear();
+
+ return items.get(index).currentPreviewColors;
+ }
+
+ public HashMap createColors(int currentAccount, int index) {
+ HashMap currentColors;
+
+ Theme.ThemeInfo themeInfo = getThemeInfo(index);
+ Theme.ThemeAccent accent = null;
+ if (themeInfo == null) {
+ int settingsIndex = getSettingsIndex(index);
+ TLRPC.TL_theme tlTheme = getTlTheme(index);
+ Theme.ThemeInfo baseTheme = Theme.getTheme(Theme.getBaseThemeKey(tlTheme.settings.get(settingsIndex)));
+ themeInfo = new Theme.ThemeInfo(baseTheme);
+ accent = themeInfo.createNewAccent(tlTheme, currentAccount, true, settingsIndex);
+ themeInfo.setCurrentAccentId(accent.id);
+ } else {
+ if (themeInfo.themeAccentsMap != null) {
+ accent = themeInfo.themeAccentsMap.get(items.get(index).accentId);
+ }
+ }
+
+ HashMap currentColorsNoAccent = new HashMap<>();
+ String[] wallpaperLink = new String[1];
+ if (themeInfo.pathToFile != null) {
+ currentColorsNoAccent.putAll(Theme.getThemeFileValues(new File(themeInfo.pathToFile), null, wallpaperLink));
+ } else if (themeInfo.assetName != null) {
+ currentColorsNoAccent.putAll(Theme.getThemeFileValues(null, themeInfo.assetName, wallpaperLink));
+ }
+
+ items.get(index).wallpaperLink = wallpaperLink[0];
+
+ if (accent != null) {
+ currentColors = new HashMap<>(currentColorsNoAccent);
+ accent.fillAccentColors(currentColorsNoAccent, currentColors);
+ currentColorsNoAccent.clear();
+ } else {
+ currentColors = currentColorsNoAccent;
}
HashMap fallbackKeys = Theme.getFallbackKeys();
@@ -234,7 +320,6 @@ public class EmojiThemes {
currentColors.put(entry.getKey(), entry.getValue());
}
}
- items.get(index).currentColors = currentColors;
return currentColors;
}
@@ -313,6 +398,12 @@ public class EmojiThemes {
return;
}
+ if (wallpaper.document == null) {
+ if (callback != null) {
+ callback.onComplete(new Pair<>(themeId, null));
+ }
+ return;
+ }
final TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(wallpaper.document.thumbs, 120);
ImageLocation imageLocation = ImageLocation.getForDocument(thumbSize, wallpaper.document);
ImageReceiver imageReceiver = new ImageReceiver();
@@ -379,7 +470,7 @@ public class EmojiThemes {
}
}
- public static HashMap getCurrentColors(Theme.ThemeInfo themeInfo) {
+ public static HashMap getPreviewColors(Theme.ThemeInfo themeInfo) {
HashMap currentColorsNoAccent = new HashMap<>();
if (themeInfo.pathToFile != null) {
currentColorsNoAccent.putAll(Theme.getThemeFileValues(new File(themeInfo.pathToFile), null, null));
@@ -403,7 +494,7 @@ public class EmojiThemes {
if (items.get(i) == null) {
continue;
}
- HashMap colorsMap = getCurrentColors(currentAccount, i);
+ HashMap colorsMap = getPreviewColors(currentAccount, i);
Integer color = colorsMap.get(Theme.key_chat_inBubble);
if (color == null) {
color = Theme.getDefaultColor(Theme.key_chat_inBubble);
@@ -443,6 +534,12 @@ public class EmojiThemes {
} else {
items.get(i).patternBgGradientColor3 = color;
}
+ color = colorsMap.get(Theme.key_chat_wallpaper_gradient_rotation);
+ if (color == null) {
+ items.get(i).patternBgRotation = 0;
+ } else {
+ items.get(i).patternBgRotation = color;
+ }
if (items.get(i).themeInfo != null && items.get(i).themeInfo.getKey().equals("Blue")) {
int accentId = items.get(i).accentId >= 0 ? items.get(i).accentId : items.get(i).themeInfo.currentAccentId;
if (accentId == 99) {
@@ -490,13 +587,14 @@ public class EmojiThemes {
.putInt(accentKey, accentId)
.apply();
}
+
public static class ThemeItem {
public Theme.ThemeInfo themeInfo;
TLRPC.TL_theme tlTheme;
int settingsIndex;
public int accentId = -1;
- public HashMap currentColors;
+ public HashMap currentPreviewColors;
private String wallpaperLink;
public int inBubbleColor;
@@ -506,5 +604,6 @@ public class EmojiThemes {
public int patternBgGradientColor1;
public int patternBgGradientColor2;
public int patternBgGradientColor3;
+ public int patternBgRotation;
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java
index ca1a0a1a1..2b9d63c66 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java
@@ -52,6 +52,8 @@ public class MenuDrawable extends Drawable {
public static int TYPE_UDPATE_AVAILABLE = 1;
public static int TYPE_UDPATE_DOWNLOADING = 2;
+ private int alpha = 255;
+
public MenuDrawable() {
this(TYPE_DEFAULT);
}
@@ -71,6 +73,10 @@ public class MenuDrawable extends Drawable {
rotateToBack = value;
}
+ public float getCurrentRotation() {
+ return currentRotation;
+ }
+
public void setRotation(float rotation, boolean animated) {
lastFrameTime = 0;
if (currentRotation == 1) {
@@ -164,6 +170,7 @@ public class MenuDrawable extends Drawable {
if (rotateToBack) {
canvas.rotate(currentRotation * (reverseAngle ? -180 : 180), AndroidUtilities.dp(9), 0);
paint.setColor(color1);
+ paint.setAlpha(alpha);
canvas.drawLine(0, 0, AndroidUtilities.dp(18) - AndroidUtilities.dp(3.0f) * currentRotation - diffMiddle, 0, paint);
endYDiff = AndroidUtilities.dp(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation);
endXDiff = AndroidUtilities.dp(18) - AndroidUtilities.dp(2.5f) * Math.abs(currentRotation);
@@ -173,6 +180,7 @@ public class MenuDrawable extends Drawable {
canvas.rotate(currentRotation * (reverseAngle ? -225 : 135), AndroidUtilities.dp(9), 0);
if (miniIcon) {
paint.setColor(color1);
+ paint.setAlpha(alpha);
canvas.drawLine(AndroidUtilities.dpf2(2) * (1 - Math.abs(currentRotation)) + AndroidUtilities.dp(1) * currentRotation, 0, AndroidUtilities.dpf2(16) * (1f - currentRotation) + AndroidUtilities.dp(17) * currentRotation - diffMiddle, 0, paint);
endYDiff = AndroidUtilities.dpf2(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dpf2(0.5f) * Math.abs(currentRotation);
endXDiff = AndroidUtilities.dpf2(16) * (1 - Math.abs(currentRotation)) + (AndroidUtilities.dpf2(9)) * Math.abs(currentRotation);
@@ -184,6 +192,7 @@ public class MenuDrawable extends Drawable {
int backColor2 = Theme.getColor(Theme.key_actionBarActionModeDefault);
backColor1 = AndroidUtilities.getOffsetColor(backColor1, backColor2, currentRotation, 1.0f);
paint.setColor(AndroidUtilities.getOffsetColor(color1, color2, currentRotation, 1.0f));
+ paint.setAlpha(alpha);
canvas.drawLine(AndroidUtilities.dp(1) * currentRotation, 0, AndroidUtilities.dp(18) - AndroidUtilities.dp(1) * currentRotation - diffMiddle, 0, paint);
endYDiff = AndroidUtilities.dp(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation);
endXDiff = AndroidUtilities.dp(18) - AndroidUtilities.dp(9) * Math.abs(currentRotation);
@@ -207,13 +216,14 @@ public class MenuDrawable extends Drawable {
rad *= (1.0f - typeAnimationProgress);
}
backPaint.setColor(backColor1);
+ backPaint.setAlpha(alpha);
canvas.drawCircle(cx, cy, rad, paint);
if (type == TYPE_UDPATE_AVAILABLE || previousType == TYPE_UDPATE_AVAILABLE) {
backPaint.setStrokeWidth(AndroidUtilities.density * 1.66f);
if (previousType == TYPE_UDPATE_AVAILABLE) {
- backPaint.setAlpha((int) (255 * (1.0f - typeAnimationProgress)));
+ backPaint.setAlpha((int) (alpha * (1.0f - typeAnimationProgress)));
} else {
- backPaint.setAlpha(255);
+ backPaint.setAlpha(alpha);
}
canvas.drawLine(cx, cy - AndroidUtilities.dp(2), cx, cy, backPaint);
canvas.drawPoint(cx, cy + AndroidUtilities.dp(2.5f), backPaint);
@@ -221,9 +231,9 @@ public class MenuDrawable extends Drawable {
if (type == TYPE_UDPATE_DOWNLOADING || previousType == TYPE_UDPATE_DOWNLOADING) {
backPaint.setStrokeWidth(AndroidUtilities.dp(2));
if (previousType == TYPE_UDPATE_DOWNLOADING) {
- backPaint.setAlpha((int) (255 * (1.0f - typeAnimationProgress)));
+ backPaint.setAlpha((int) (alpha * (1.0f - typeAnimationProgress)));
} else {
- backPaint.setAlpha(255);
+ backPaint.setAlpha(alpha);
}
float arcRad = Math.max(4, 360 * animatedDownloadProgress);
rect.set(cx - AndroidUtilities.dp(3), cy - AndroidUtilities.dp(3), cx + AndroidUtilities.dp(3), cy + AndroidUtilities.dp(3));
@@ -266,7 +276,12 @@ public class MenuDrawable extends Drawable {
@Override
public void setAlpha(int alpha) {
-
+ if (this.alpha != alpha) {
+ this.alpha = alpha;
+ paint.setAlpha(alpha);
+ backPaint.setAlpha(alpha);
+ invalidateSelf();
+ }
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java
index 750bd1ee0..fd875e8fe 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java
@@ -67,7 +67,6 @@ import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.Bitmaps;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatThemeController;
-import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation;
@@ -120,7 +119,6 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -207,6 +205,7 @@ public class Theme {
private Shader crosfadeFromBitmapShader;
PathDrawParams pathDrawCacheParams;
+ private int overrideRoundRadius;
public MessageDrawable(int type, boolean out, boolean selected) {
this(type, out, selected, null);
@@ -658,7 +657,10 @@ public class Theme {
int padding = dp(2);
int rad;
int nearRad;
- if (currentType == TYPE_PREVIEW) {
+ if (overrideRoundRadius != 0) {
+ rad = overrideRoundRadius;
+ nearRad = overrideRoundRadius;
+ } else if (currentType == TYPE_PREVIEW) {
rad = dp(6);
nearRad = dp(6);
} else {
@@ -866,6 +868,10 @@ public class Theme {
}
}
+ public void setRoundRadius(int radius) {
+ this.overrideRoundRadius = radius;
+ }
+
public static class PathDrawParams {
Path path = new Path();
Rect lastRect = new Rect();
@@ -1519,7 +1525,7 @@ public class Theme {
if (id < 100) {
return !TextUtils.isEmpty(patternSlug) ? new File(ApplicationLoader.getFilesDirFixed(), String.format(Locale.US, "%s_%d_%s_v5.jpg", parentTheme.getKey(), id, patternSlug)) : null;
} else {
- return !TextUtils.isEmpty(patternSlug) ? new File(ApplicationLoader.getFilesDirFixed(), String.format(Locale.US, "%s_%d_%s_v8_dubug.jpg", parentTheme.getKey(), id, patternSlug)) : null;
+ return !TextUtils.isEmpty(patternSlug) ? new File(ApplicationLoader.getFilesDirFixed(), String.format(Locale.US, "%s_%d_%s_v8_debug.jpg", parentTheme.getKey(), id, patternSlug)) : null;
}
}
@@ -2140,6 +2146,9 @@ public class Theme {
for (int a = 0; a < accent.length; a++) {
ThemeAccent themeAccent = new ThemeAccent();
themeAccent.id = ids != null ? ids[a] : a;
+ if (isHome(themeAccent)) {
+ themeAccent.isDefault = true;
+ }
themeAccent.accentColor = accent[a];
themeAccent.parentTheme = this;
if (myMessages != null) {
@@ -2356,6 +2365,7 @@ public class Theme {
themeAccent.account = account;
themeAccentsMap.put(id, themeAccent);
themeAccents.add(0, themeAccent);
+ sortAccents(this);
accentsByThemeId.put(info.id, themeAccent);
return themeAccent;
}
@@ -2393,6 +2403,7 @@ public class Theme {
overrideWallpaper = themeAccent.overrideWallpaper;
themeAccentsMap.put(id, themeAccent);
themeAccents.add(0, themeAccent);
+ sortAccents(this);
return themeAccent;
} else {
return accent;
@@ -4839,6 +4850,7 @@ public class Theme {
new int[] { 0, 180, 45, 0, 45, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 52, 46, 57, 45, 64, 52, 35, 36, 41, 50, 50, 35, 38, 37, 30 }
);
+ sortAccents(themeInfo);
themes.add(currentDayTheme = currentTheme = defaultTheme = themeInfo);
themesDict.put("Blue", themeInfo);
@@ -4862,6 +4874,7 @@ public class Theme {
new int[] { 225, 45, 225, 135, 45, 225, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 40, 40, 31, 50, 25, 34, 35, 35, 38, 29, 24, 34, 34, 31, 29, 37, 21, 38 }
);
+ sortAccents(themeInfo);
themes.add(themeInfo);
themesDict.put("Dark Blue", currentNightTheme = themeInfo);
@@ -4885,6 +4898,7 @@ public class Theme {
new int[] { 315, 315, 225, 315, 0, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 50, 50, 58, 47, 46, 50, 49, 46, 51, 50, 49, 34, 54, 50, 40 }
);
+ sortAccents(themeInfo);
themes.add(themeInfo);
themesDict.put("Arctic Blue", themeInfo);
@@ -4908,6 +4922,7 @@ public class Theme {
new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
);
+ sortAccents(themeInfo);
themes.add(themeInfo);
themesDict.put("Day", themeInfo);
@@ -4931,15 +4946,21 @@ public class Theme {
new int[] { 45, 135, 0, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
new int[] { 34, 47, 52, 48, 54, 50, 37, 56, 48, 49, 40, 64, 38, 48 }
);
+ sortAccents(themeInfo);
themes.add(themeInfo);
themesDict.put("Night", themeInfo);
String themesString = themeConfig.getString("themes2", null);
- for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
- remoteThemesHash[a] = themeConfig.getLong("2remoteThemesHash" + (a != 0 ? a : ""), 0);
- lastLoadingThemesTime[a] = themeConfig.getInt("lastLoadingThemesTime" + (a != 0 ? a : ""), 0);
+ int remoteVersion = themeConfig.getInt("remote_version", 0);
+ int appRemoteThemesVersion = 1;
+ if (remoteVersion == appRemoteThemesVersion) {
+ for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
+ remoteThemesHash[a] = themeConfig.getLong("2remoteThemesHash" + (a != 0 ? a : ""), 0);
+ lastLoadingThemesTime[a] = themeConfig.getInt("lastLoadingThemesTime" + (a != 0 ? a : ""), 0);
+ }
}
+ themeConfig.edit().putInt("remote_version", appRemoteThemesVersion).apply();
if (!TextUtils.isEmpty(themesString)) {
try {
JSONArray jsonArray = new JSONArray(themesString);
@@ -5150,15 +5171,8 @@ public class Theme {
}
}
if (!newAccents.isEmpty()) {
- Collections.sort(newAccents, (o1, o2) -> {
- if (o1.id > o2.id) {
- return -1;
- } else if (o1.id < o2.id) {
- return 1;
- }
- return 0;
- });
info.themeAccents.addAll(0, newAccents);
+ sortAccents(info);
}
if (info.themeAccentsMap != null && info.themeAccentsMap.get(info.currentAccentId) == null) {
info.currentAccentId = info.firstAccentIsDefault ? DEFALT_THEME_ACCENT_ID : 0;
@@ -5252,7 +5266,10 @@ public class Theme {
SerializedData serializedData = new SerializedData(Utilities.hexToBytes(value));
try {
TLRPC.TL_theme theme = TLRPC.Theme.TLdeserialize(serializedData, serializedData.readInt32(true), true);
- previewItems.add(new ChatThemeBottomSheet.ChatThemeItem(EmojiThemes.createPreviewFullTheme(theme)));
+ EmojiThemes fullTheme = EmojiThemes.createPreviewFullTheme(theme);
+ if (fullTheme.items.size() >= 4) {
+ previewItems.add(new ChatThemeBottomSheet.ChatThemeItem(fullTheme));
+ }
ChatThemeController.chatThemeQueue.postRunnable(new Runnable() {
@Override
@@ -5263,7 +5280,6 @@ public class Theme {
AndroidUtilities.runOnUIThread(() -> {
defaultEmojiThemes.clear();
defaultEmojiThemes.addAll(previewItems);
- NotificationCenter.getInstance(0).postNotificationName(NotificationCenter.emojiPreviewThemesChanged);
});
}
});
@@ -5273,6 +5289,42 @@ public class Theme {
}
}
+ private static void sortAccents(ThemeInfo info) {
+ Collections.sort(info.themeAccents, (o1, o2) -> {
+ if (isHome(o1)) {
+ return -1;
+ }
+ if (isHome(o2)) {
+ return 1;
+ }
+ int i1 = o1.isDefault ? 1 : 0;
+ int i2 = o2.isDefault ? 1 : 0;
+
+ if (i1 == i2) {
+ if (o1.isDefault) {
+ if (o1.id > o2.id) {
+ return 1;
+ } else if (o1.id < o2.id) {
+ return -1;
+ }
+ } else {
+ if (o1.id > o2.id) {
+ return -1;
+ } else if (o1.id < o2.id) {
+ return 1;
+ }
+ }
+ } else {
+ if (i1 > i2) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+ return 0;
+ });
+ }
+
private static Method StateListDrawable_getStateDrawableMethod;
private static Field BitmapDrawable_mColorFilter;
@@ -7112,7 +7164,7 @@ public class Theme {
}
public static void loadRemoteThemes(final int currentAccount, boolean force) {
- if (loadingRemoteThemes[currentAccount]) {
+ if (loadingRemoteThemes[currentAccount] || !force && Math.abs(System.currentTimeMillis() / 1000 - lastLoadingThemesTime[currentAccount]) < 60 * 60 || !UserConfig.getInstance(currentAccount).isClientActivated()) {
return;
}
loadingRemoteThemes[currentAccount] = true;
@@ -7143,15 +7195,13 @@ public class Theme {
boolean loadPatterns = false;
boolean added = false;
for (int a = 0, N = res.themes.size(); a < N; a++) {
- TLRPC.Theme t = res.themes.get(a);
+ TLRPC.TL_theme t = res.themes.get(a);
if (!(t instanceof TLRPC.TL_theme)) {
continue;
}
- TLRPC.TL_theme theme = (TLRPC.TL_theme) t;
+ TLRPC.TL_theme theme = t;
if (theme.isDefault) {
- //TODO new emoji themes
- continue;
- //emojiPreviewThemes.add(theme);
+ emojiPreviewThemes.add(theme);
}
if (theme.settings != null && theme.settings.size() > 0) {
for (int i = 0; i < theme.settings.size(); i++) {
@@ -7183,7 +7233,7 @@ public class Theme {
accent.patternMotion = settings.wallpaper != null && settings.wallpaper.settings != null && settings.wallpaper.settings.motion;
oldServerThemes.remove(accent);
} else {
- accent = info.createNewAccent(theme, currentAccount);
+ accent = info.createNewAccent(theme, currentAccount, false, i);
if (!TextUtils.isEmpty(accent.patternSlug)) {
loadPatterns = true;
}
@@ -7262,7 +7312,6 @@ public class Theme {
SerializedData data = new SerializedData(tlChatTheme.getObjectSize());
tlChatTheme.serializeToStream(data);
editor.putString("theme_" + i, Utilities.bytesToHex(data.toByteArray()));
- EmojiThemes chatTheme = new EmojiThemes(tlChatTheme, false);
}
editor.apply();
@@ -7273,7 +7322,9 @@ public class Theme {
TLRPC.TL_theme theme = emojiPreviewThemes.get(i);
EmojiThemes chatTheme = EmojiThemes.createPreviewFullTheme(theme);
ChatThemeBottomSheet.ChatThemeItem item = new ChatThemeBottomSheet.ChatThemeItem(chatTheme);
- previewItems.add(item);
+ if (chatTheme.items.size() >= 4) {
+ previewItems.add(item);
+ }
}
ChatThemeController.chatThemeQueue.postRunnable(new Runnable() {
@Override
@@ -7284,13 +7335,13 @@ public class Theme {
AndroidUtilities.runOnUIThread(() -> {
defaultEmojiThemes.clear();
defaultEmojiThemes.addAll(previewItems);
- NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.emojiPreviewThemesChanged);
+ NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.emojiPreviewThemesChanged);
});
}
});
} else {
defaultEmojiThemes.clear();
- NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.emojiPreviewThemesChanged);
+ NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.emojiPreviewThemesChanged);
}
}
@@ -9438,6 +9489,7 @@ public class Theme {
Integer gradientToColor2 = currentColors.get(key_chat_wallpaper_gradient_to2);
gradientToColor2 = currentColors.get(key_chat_wallpaper_gradient_to2);
Integer gradientToColor1 = currentColors.get(key_chat_wallpaper_gradient_to1);
+
if (wallpaperFile != null && wallpaperFile.exists()) {
try {
if (backgroundColor != null && gradientToColor1 != null && gradientToColor2 != null) {
@@ -9972,4 +10024,19 @@ public class Theme {
public static boolean isCurrentThemeDay() {
return !getActiveTheme().isDark();
}
+
+ public static boolean isHome(ThemeAccent accent) {
+ if (accent.parentTheme != null) {
+ if (accent.parentTheme.getKey().equals("Blue") && accent.id == 99) {
+ return true;
+ }
+ if (accent.parentTheme.getKey().equals("Day") && accent.id == 9) {
+ return true;
+ }
+ if ((accent.parentTheme.getKey().equals("Night") || accent.parentTheme.getKey().equals("Dark Blue")) && accent.id == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java
index caf0a1ab9..d4ad964f9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionIntroActivity.java
@@ -80,6 +80,7 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
private String currentGroupCreateAddress;
private String currentGroupCreateDisplayAddress;
private Location currentGroupCreateLocation;
+ private boolean showingAsBottomSheet;
private ActionIntroQRLoginDelegate qrLoginDelegate;
@@ -103,23 +104,26 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
@Override
public View createView(Context context) {
- actionBar.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), false);
- actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarWhiteSelector), false);
- actionBar.setCastShadows(false);
- actionBar.setAddToContainer(false);
- if (!AndroidUtilities.isTablet()) {
- actionBar.showActionModeTop();
- }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- }
+ if (actionBar != null) {
+ actionBar.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
+
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), false);
+ actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarWhiteSelector), false);
+ actionBar.setCastShadows(false);
+ actionBar.setAddToContainer(false);
+ if (!AndroidUtilities.isTablet()) {
+ actionBar.showActionModeTop();
}
- });
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ }
+ }
+ });
+ }
fragmentView = new ViewGroup(context) {
@@ -128,8 +132,9 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
- actionBar.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightMeasureSpec);
-
+ if (actionBar != null) {
+ actionBar.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightMeasureSpec);
+ }
switch (currentType) {
case ACTION_TYPE_CHANNEL_CREATE: {
if (width > height) {
@@ -146,7 +151,13 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
break;
}
case ACTION_TYPE_QR_LOGIN: {
- if (width > height) {
+ if (showingAsBottomSheet) {
+ imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.32f), MeasureSpec.EXACTLY));
+ titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
+ descriptionLayout.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
+ buttonTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(42), MeasureSpec.EXACTLY));
+ height = imageView.getMeasuredHeight() + titleTextView.getMeasuredHeight() + AndroidUtilities.dp(20) + titleTextView.getMeasuredHeight() + descriptionLayout.getMeasuredHeight() + buttonTextView.getMeasuredHeight();
+ } else if (width > height) {
imageView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.45f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec((int) (height * 0.68f), MeasureSpec.EXACTLY));
titleTextView.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionLayout.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.6f), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
@@ -214,7 +225,9 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
- actionBar.layout(0, 0, r, actionBar.getMeasuredHeight());
+ if (actionBar != null) {
+ actionBar.layout(0, 0, r, actionBar.getMeasuredHeight());
+ }
int width = r - l;
int height = b - t;
@@ -247,7 +260,21 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
break;
}
case ACTION_TYPE_QR_LOGIN: {
- if (r > b) {
+ if (showingAsBottomSheet) {
+ int y;
+
+ y = 0;
+ imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
+ y = (int) (height * 0.403f);
+ titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
+ y = (int) (height * 0.631f);
+
+ int x = (getMeasuredWidth() - descriptionLayout.getMeasuredWidth()) / 2;
+ descriptionLayout.layout(x, y, x + descriptionLayout.getMeasuredWidth(), y + descriptionLayout.getMeasuredHeight());
+ x = (width - buttonTextView.getMeasuredWidth()) / 2;
+ y = (int) (height * 0.853f);
+ buttonTextView.layout(x, y, x + buttonTextView.getMeasuredWidth(), y + buttonTextView.getMeasuredHeight());
+ } else if (r > b) {
int y = (height - imageView.getMeasuredHeight()) / 2;
imageView.layout(0, y, imageView.getMeasuredWidth(), y + imageView.getMeasuredHeight());
int x = (int) (width * 0.4f);
@@ -383,7 +410,9 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
ViewGroup viewGroup = (ViewGroup) fragmentView;
viewGroup.setOnTouchListener((v, event) -> true);
- viewGroup.addView(actionBar);
+ if (actionBar != null) {
+ viewGroup.addView(actionBar);
+ }
imageView = new RLottieImageView(context);
viewGroup.addView(imageView);
@@ -796,7 +825,7 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
}
private void processOpenQrReader() {
- CameraScanActivity.showAsSheet(this, false, new CameraScanActivity.CameraScanActivityDelegate() {
+ CameraScanActivity.showAsSheet(this, false, CameraScanActivity.TYPE_QR, new CameraScanActivity.CameraScanActivityDelegate() {
@Override
public void didFindQr(String text) {
finishFragment(false);
@@ -809,6 +838,10 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
return currentType;
}
+ public void setShowingAsBottomSheet(boolean showingAsBottomSheet) {
+ this.showingAsBottomSheet = showingAsBottomSheet;
+ }
+
@Override
public ArrayList getThemeDescriptions() {
ArrayList themeDescriptions = new ArrayList<>();
@@ -817,9 +850,11 @@ public class ActionIntroActivity extends BaseFragment implements LocationControl
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, delegate, Theme.key_windowBackgroundWhite));
- themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
- themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
- themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarWhiteSelector));
+ if (actionBar != null) {
+ themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
+ themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
+ themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarWhiteSelector));
+ }
themeDescriptions.add(new ThemeDescription(titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, delegate, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(subtitleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
index 4d5b90e16..cca5ae1d6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CacheControlActivity.java
@@ -10,10 +10,13 @@ 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.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;
@@ -22,18 +25,25 @@ 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;
+import androidx.annotation.RequiresApi;
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;
@@ -69,7 +79,11 @@ 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 {
@@ -99,10 +113,12 @@ public class CacheControlActivity extends BaseFragment {
private long totalSize = -1;
private long totalDeviceSize = -1;
private long totalDeviceFreeSize = -1;
+ private long migrateOldFolderRow = -1;
private StorageDiagramView.ClearViewData[] clearViewData = new StorageDiagramView.ClearViewData[7];
private boolean calculating = true;
private volatile boolean canceled = false;
+ private boolean hasOldFolder;
private View bottomSheetView;
private BottomSheet bottomSheet;
@@ -116,18 +132,6 @@ public class CacheControlActivity extends BaseFragment {
public boolean onFragmentCreate() {
super.onFragmentCreate();
- rowCount = 0;
-
- keepMediaHeaderRow = rowCount++;
- keepMediaChooserRow = rowCount++;
- keepMediaInfoRow = rowCount++;
- deviseStorageHeaderRow = rowCount++;
- storageUsageRow = rowCount++;
-
- cacheInfoRow = rowCount++;
- databaseRow = rowCount++;
- databaseInfoRow = rowCount++;
-
databaseSize = MessagesStorage.getInstance(currentAccount).getDatabaseSize();
Utilities.globalQueue.postRunnable(() -> {
@@ -209,9 +213,45 @@ 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;
}
+ private void updateRows() {
+ rowCount = 0;
+
+ keepMediaHeaderRow = rowCount++;
+ keepMediaChooserRow = rowCount++;
+ keepMediaInfoRow = rowCount++;
+ deviseStorageHeaderRow = rowCount++;
+ storageUsageRow = rowCount++;
+
+ cacheInfoRow = rowCount++;
+ databaseRow = rowCount++;
+ databaseInfoRow = rowCount++;
+// if (hasOldFolder) {
+// migrateOldFolderRow = rowCount++;
+// }
+ }
+
private void updateStorageUsageRow() {
View view = layoutManager.findViewByPosition(storageUsageRow);
if (view instanceof StroageUsageView) {
@@ -406,7 +446,9 @@ public class CacheControlActivity extends BaseFragment {
if (getParentActivity() == null) {
return;
}
- if (position == databaseRow) {
+ if (position == migrateOldFolderRow) {
+ migrateOldFolder();
+ } else if (position == databaseRow) {
clearDatabase();
} else if (position == storageUsageRow) {
if (totalSize <= 0 || getParentActivity() == null) {
@@ -525,6 +567,115 @@ public class CacheControlActivity extends BaseFragment {
return fragmentView;
}
+ @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();
+ }
+
private void clearDatabase() {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("LocalDatabaseClearTextTitle", R.string.LocalDatabaseClearTextTitle));
@@ -657,7 +808,7 @@ public class CacheControlActivity extends BaseFragment {
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
int position = holder.getAdapterPosition();
- return position == databaseRow || (position == storageUsageRow && (totalSize > 0) && !calculating);
+ return position == migrateOldFolderRow || position == databaseRow || (position == storageUsageRow && (totalSize > 0) && !calculating);
}
@Override
@@ -721,6 +872,8 @@ public class CacheControlActivity extends BaseFragment {
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
if (position == databaseRow) {
textCell.setTextAndValue(LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
+ } else if (position == migrateOldFolderRow) {
+ textCell.setTextAndValue(LocaleController.getString("MigrateOldFolder", R.string.MigrateOldFolder), null, false);
}
break;
case 1:
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java
new file mode 100644
index 000000000..e70961ae7
--- /dev/null
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java
@@ -0,0 +1,1424 @@
+package org.telegram.ui;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ValueAnimator;
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.text.TextPaint;
+import android.util.SparseArray;
+import android.util.TypedValue;
+import android.view.GestureDetector;
+import android.view.Gravity;
+import android.view.HapticFeedbackConstants;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.core.content.ContextCompat;
+import androidx.core.graphics.ColorUtils;
+import androidx.core.view.GestureDetectorCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import org.telegram.messenger.AndroidUtilities;
+import org.telegram.messenger.ChatObject;
+import org.telegram.messenger.DownloadController;
+import org.telegram.messenger.FileLoader;
+import org.telegram.messenger.ImageLocation;
+import org.telegram.messenger.ImageReceiver;
+import org.telegram.messenger.LocaleController;
+import org.telegram.messenger.MessageObject;
+import org.telegram.messenger.MessagesController;
+import org.telegram.messenger.MessagesStorage;
+import org.telegram.messenger.R;
+import org.telegram.messenger.Utilities;
+import org.telegram.tgnet.TLRPC;
+import org.telegram.ui.ActionBar.ActionBar;
+import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
+import org.telegram.ui.ActionBar.ActionBarPopupWindow;
+import org.telegram.ui.ActionBar.BackDrawable;
+import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.ActionBar.SimpleTextView;
+import org.telegram.ui.ActionBar.Theme;
+import org.telegram.ui.ActionBar.ThemeDescription;
+import org.telegram.ui.Components.AlertsCreator;
+import org.telegram.ui.Components.BulletinFactory;
+import org.telegram.ui.Components.CubicBezierInterpolator;
+import org.telegram.ui.Components.Easings;
+import org.telegram.ui.Components.HideViewAfterAnimation;
+import org.telegram.ui.Components.HintView;
+import org.telegram.ui.Components.LayoutHelper;
+import org.telegram.ui.Components.RecyclerListView;
+import org.telegram.ui.Components.SharedMediaLayout;
+import org.telegram.ui.Components.Tooltip;
+
+import java.time.YearMonth;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+
+public class CalendarActivity extends BaseFragment {
+
+ public final static int TYPE_CHAT_ACTIVITY = 0;
+ public final static int TYPE_MEDIA_CALENDAR = 1;
+
+ FrameLayout contentView;
+
+ RecyclerListView listView;
+ LinearLayoutManager layoutManager;
+ TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+ TextPaint activeTextPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+ TextPaint textPaint2 = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+
+ TextView selectDaysButton;
+ TextView removeDaysButton;
+
+ private Paint selectOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private Paint selectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ private View blurredView;
+
+ Paint blackoutPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+
+ private long dialogId;
+ private boolean loading;
+ private boolean checkEnterItems;
+ private boolean inSelectionMode;
+ BackDrawable backDrawable;
+
+ int startFromYear;
+ int startFromMonth;
+ int monthCount;
+
+ CalendarAdapter adapter;
+ Callback callback;
+
+ HintView selectDaysHint;
+
+
+ private int dateSelectedStart;
+ private int dateSelectedEnd;
+ private ValueAnimator selectionAnimator;
+
+ SparseArray> messagesByYearMounth = new SparseArray<>();
+ boolean endReached;
+ int startOffset = 0;
+ int lastId;
+ int minMontYear;
+ private int photosVideosTypeFilter;
+ private boolean isOpened;
+ int selectedYear;
+ int selectedMonth;
+ private FrameLayout bottomBar;
+ private int minDate;
+ private boolean canClearHistory;
+
+ private int calendarType;
+
+ public CalendarActivity(Bundle args, int photosVideosTypeFilter, int selectedDate) {
+ super(args);
+ this.photosVideosTypeFilter = photosVideosTypeFilter;
+
+ if (selectedDate != 0) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(selectedDate * 1000L);
+ selectedYear = calendar.get(Calendar.YEAR);
+ selectedMonth = calendar.get(Calendar.MONTH);
+ }
+
+ selectOutlinePaint.setStyle(Paint.Style.STROKE);
+ selectOutlinePaint.setStrokeCap(Paint.Cap.ROUND);
+ selectOutlinePaint.setStrokeWidth(AndroidUtilities.dp(2));
+ }
+
+ @Override
+ public boolean onFragmentCreate() {
+ dialogId = getArguments().getLong("dialog_id");
+ calendarType = getArguments().getInt("type");
+
+ if (dialogId >= 0) {
+ canClearHistory = true;
+ } else {
+ canClearHistory = false;
+ }
+ return super.onFragmentCreate();
+ }
+
+ @Override
+ public View createView(Context context) {
+ textPaint.setTextSize(AndroidUtilities.dp(16));
+ textPaint.setTextAlign(Paint.Align.CENTER);
+
+ textPaint2.setTextSize(AndroidUtilities.dp(11));
+ textPaint2.setTextAlign(Paint.Align.CENTER);
+ textPaint2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+
+ activeTextPaint.setTextSize(AndroidUtilities.dp(16));
+ activeTextPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ activeTextPaint.setTextAlign(Paint.Align.CENTER);
+
+ contentView = new FrameLayout(context) {
+ int lastSize;
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ int size = getMeasuredHeight() + getMeasuredWidth() << 16;
+ if (lastSize != size) {
+ lastSize = size;
+ adapter.notifyDataSetChanged();
+ }
+ }
+ };
+ createActionBar(context);
+ contentView.addView(actionBar);
+ actionBar.setTitle(LocaleController.getString("Calendar", R.string.Calendar));
+ actionBar.setCastShadows(false);
+
+ listView = new RecyclerListView(context) {
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ super.dispatchDraw(canvas);
+ checkEnterItems = false;
+ }
+ };
+ listView.setLayoutManager(layoutManager = new LinearLayoutManager(context));
+ layoutManager.setReverseLayout(true);
+ listView.setAdapter(adapter = new CalendarAdapter());
+ listView.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ super.onScrolled(recyclerView, dx, dy);
+ checkLoadNext();
+ }
+ });
+
+ boolean showBottomPanel = calendarType == TYPE_CHAT_ACTIVITY && canClearHistory;
+ contentView.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 36, 0, showBottomPanel ? 48 : 0));
+
+ final String[] daysOfWeek = new String[]{
+ LocaleController.getString("CalendarWeekNameShortMonday", R.string.CalendarWeekNameShortMonday),
+ LocaleController.getString("CalendarWeekNameShortTuesday", R.string.CalendarWeekNameShortTuesday),
+ LocaleController.getString("CalendarWeekNameShortWednesday", R.string.CalendarWeekNameShortWednesday),
+ LocaleController.getString("CalendarWeekNameShortThursday", R.string.CalendarWeekNameShortThursday),
+ LocaleController.getString("CalendarWeekNameShortFriday", R.string.CalendarWeekNameShortFriday),
+ LocaleController.getString("CalendarWeekNameShortSaturday", R.string.CalendarWeekNameShortSaturday),
+ LocaleController.getString("CalendarWeekNameShortSunday", R.string.CalendarWeekNameShortSunday),
+ };
+
+
+ Drawable headerShadowDrawable = ContextCompat.getDrawable(context, R.drawable.header_shadow).mutate();
+
+ View calendarSignatureView = new View(context) {
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+ float xStep = getMeasuredWidth() / 7f;
+ for (int i = 0; i < 7; i++) {
+ float cx = xStep * i + xStep / 2f;
+ float cy = (getMeasuredHeight() - AndroidUtilities.dp(2)) / 2f;
+ canvas.drawText(daysOfWeek[i], cx, cy + AndroidUtilities.dp(5), textPaint2);
+ }
+ headerShadowDrawable.setBounds(0, getMeasuredHeight() - AndroidUtilities.dp(3), getMeasuredWidth(), getMeasuredHeight());
+ headerShadowDrawable.draw(canvas);
+ }
+ };
+
+ contentView.addView(calendarSignatureView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, 0, 0, 0, 0, 0));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ if (dateSelectedStart != 0 || dateSelectedEnd != 0 || inSelectionMode) {
+ inSelectionMode = false;
+ dateSelectedStart = 0;
+ dateSelectedEnd = 0;
+ updateTitle();
+ animateSelection();
+ } else {
+ finishFragment();
+ }
+ }
+ }
+ });
+
+ fragmentView = contentView;
+
+ Calendar calendar = Calendar.getInstance();
+ startFromYear = calendar.get(Calendar.YEAR);
+ startFromMonth = calendar.get(Calendar.MONTH);
+
+ if (selectedYear != 0) {
+ monthCount = (startFromYear - selectedYear) * 12 + startFromMonth - selectedMonth + 1;
+ layoutManager.scrollToPositionWithOffset(monthCount - 1, AndroidUtilities.dp(120));
+ }
+ if (monthCount < 3) {
+ monthCount = 3;
+ }
+
+ backDrawable = new BackDrawable(false);
+ actionBar.setBackButtonDrawable(backDrawable);
+ backDrawable.setRotation(0f, false);
+
+ loadNext();
+ updateColors();
+ activeTextPaint.setColor(Color.WHITE);
+
+ if (showBottomPanel) {
+ bottomBar = new FrameLayout(context) {
+ @Override
+ public void onDraw(Canvas canvas) {
+ canvas.drawRect(0, 0, getMeasuredWidth(), AndroidUtilities.getShadowHeight(), Theme.dividerPaint);
+ }
+ };
+ bottomBar.setWillNotDraw(false);
+ bottomBar.setPadding(0, AndroidUtilities.getShadowHeight(), 0, 0);
+ bottomBar.setClipChildren(false);
+ selectDaysButton = new TextView(context);
+ selectDaysButton.setGravity(Gravity.CENTER);
+ selectDaysButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ selectDaysButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ selectDaysButton.setOnClickListener(view -> {
+ inSelectionMode = true;
+ updateTitle();
+ });
+ selectDaysButton.setText(LocaleController.getString("SelectDays", R.string.SelectDays));
+ selectDaysButton.setAllCaps(true);
+ bottomBar.addView(selectDaysButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0f, 0, 0));
+
+ removeDaysButton = new TextView(context);
+ removeDaysButton.setGravity(Gravity.CENTER);
+ removeDaysButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ removeDaysButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ removeDaysButton.setOnClickListener(view -> {
+ if (lastDaysSelected == 0) {
+ if (selectDaysHint == null) {
+ selectDaysHint = new HintView(contentView.getContext(), 8);
+ selectDaysHint.setExtraTranslationY(AndroidUtilities.dp(24));
+ contentView.addView(selectDaysHint, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 19, 0, 19, 0));
+ selectDaysHint.setText(LocaleController.getString("SelectDaysTooltip", R.string.SelectDaysTooltip));
+ }
+ selectDaysHint.showForView(bottomBar, true);
+ return;
+ }
+ AlertsCreator.createClearDaysDialogAlert(this, lastDaysSelected, getMessagesController().getUser(dialogId), new MessagesStorage.BooleanCallback() {
+ @Override
+ public void run(boolean forAll) {
+ finishFragment();
+
+ if (parentLayout.fragmentsStack.size() >= 2) {
+ BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
+ if (fragment instanceof ChatActivity) {
+ ((ChatActivity) fragment).deleteHistory(dateSelectedStart, dateSelectedEnd + 86400, forAll);
+ }
+ }
+ }
+ }, null);
+ });
+ removeDaysButton.setAllCaps(true);
+
+ removeDaysButton.setVisibility(View.GONE);
+ bottomBar.addView(removeDaysButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0f, 0, 0));
+ contentView.addView(bottomBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM, 0, 0, 0, 0));
+
+
+ selectDaysButton.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_fieldOverlayText), (int) (0.2f * 255)), 2));
+ removeDaysButton.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_dialogTextRed), (int) (0.2f * 255)), 2));
+ selectDaysButton.setTextColor(Theme.getColor(Theme.key_chat_fieldOverlayText));
+ removeDaysButton.setTextColor(Theme.getColor(Theme.key_dialogTextRed));
+ }
+
+ return fragmentView;
+ }
+
+ private void updateColors() {
+ actionBar.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
+ activeTextPaint.setColor(Color.WHITE);
+ textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ textPaint2.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ actionBar.setTitleColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ backDrawable.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), false);
+ actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_listSelector), false);
+ }
+
+ private void loadNext() {
+ if (loading || endReached) {
+ return;
+ }
+ loading = true;
+ TLRPC.TL_messages_getSearchResultsCalendar req = new TLRPC.TL_messages_getSearchResultsCalendar();
+ if (photosVideosTypeFilter == SharedMediaLayout.FILTER_PHOTOS_ONLY) {
+ req.filter = new TLRPC.TL_inputMessagesFilterPhotos();
+ } else if (photosVideosTypeFilter == SharedMediaLayout.FILTER_VIDEOS_ONLY) {
+ req.filter = new TLRPC.TL_inputMessagesFilterVideo();
+ } else {
+ req.filter = new TLRPC.TL_inputMessagesFilterPhotoVideo();
+ }
+
+ req.peer = MessagesController.getInstance(currentAccount).getInputPeer(dialogId);
+ req.offset_id = lastId;
+
+ Calendar calendar = Calendar.getInstance();
+ listView.setItemAnimator(null);
+ getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
+ if (error == null) {
+ TLRPC.TL_messages_searchResultsCalendar res = (TLRPC.TL_messages_searchResultsCalendar) response;
+
+ for (int i = 0; i < res.periods.size(); i++) {
+ TLRPC.TL_searchResultsCalendarPeriod period = res.periods.get(i);
+ calendar.setTimeInMillis(period.date * 1000L);
+ int month = calendar.get(Calendar.YEAR) * 100 + calendar.get(Calendar.MONTH);
+ SparseArray messagesByDays = messagesByYearMounth.get(month);
+ if (messagesByDays == null) {
+ messagesByDays = new SparseArray<>();
+ messagesByYearMounth.put(month, messagesByDays);
+ }
+ PeriodDay periodDay = new PeriodDay();
+ MessageObject messageObject = new MessageObject(currentAccount, res.messages.get(i), false, false);
+ periodDay.messageObject = messageObject;
+ periodDay.date = (int) (calendar.getTimeInMillis() / 1000L);
+ startOffset += res.periods.get(i).count;
+ periodDay.startOffset = startOffset;
+ int index = calendar.get(Calendar.DAY_OF_MONTH) - 1;
+ if (messagesByDays.get(index, null) == null || !messagesByDays.get(index, null).hasImage) {
+ messagesByDays.put(index, periodDay);
+ }
+ if (month < minMontYear || minMontYear == 0) {
+ minMontYear = month;
+ }
+ }
+
+ int maxDate = (int) (System.currentTimeMillis() / 1000L);
+ minDate = res.min_date;
+
+ for (int date = res.min_date; date < maxDate; date += 86400) {
+ calendar.setTimeInMillis(date * 1000L);
+ calendar.set(Calendar.HOUR_OF_DAY, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+
+ int month = calendar.get(Calendar.YEAR) * 100 + calendar.get(Calendar.MONTH);
+ SparseArray messagesByDays = messagesByYearMounth.get(month);
+ if (messagesByDays == null) {
+ messagesByDays = new SparseArray<>();
+ messagesByYearMounth.put(month, messagesByDays);
+ }
+ int index = calendar.get(Calendar.DAY_OF_MONTH) - 1;
+ if (messagesByDays.get(index, null) == null) {
+ PeriodDay periodDay = new PeriodDay();
+ periodDay.hasImage = false;
+ periodDay.date = (int) (calendar.getTimeInMillis() / 1000L);
+ messagesByDays.put(index, periodDay);
+ }
+ }
+
+ loading = false;
+ if (!res.messages.isEmpty()) {
+ lastId = res.messages.get(res.messages.size() - 1).id;
+ endReached = false;
+ checkLoadNext();
+ } else {
+ endReached = true;
+ }
+ if (isOpened) {
+ checkEnterItems = true;
+ }
+ listView.invalidate();
+ int newMonthCount = (int) (((calendar.getTimeInMillis() / 1000) - res.min_date) / 2629800) + 1;
+ adapter.notifyItemRangeChanged(0, monthCount);
+ if (newMonthCount > monthCount) {
+ adapter.notifyItemRangeInserted(monthCount + 1, newMonthCount);
+ monthCount = newMonthCount;
+ }
+ if (endReached) {
+ resumeDelayedFragmentAnimation();
+ }
+ }
+ }));
+ }
+
+ private void checkLoadNext() {
+ if (loading || endReached) {
+ return;
+ }
+ int listMinMonth = Integer.MAX_VALUE;
+ for (int i = 0; i < listView.getChildCount(); i++) {
+ View child = listView.getChildAt(i);
+ if (child instanceof MonthView) {
+ int currentMonth = ((MonthView) child).currentYear * 100 + ((MonthView) child).currentMonthInYear;
+ if (currentMonth < listMinMonth) {
+ listMinMonth = currentMonth;
+ }
+ }
+ }
+ int min1 = (minMontYear / 100 * 12) + minMontYear % 100;
+ int min2 = (listMinMonth / 100 * 12) + listMinMonth % 100;
+ if (min1 + 3 >= min2) {
+ loadNext();
+ }
+ }
+
+ private class CalendarAdapter extends RecyclerView.Adapter {
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ return new RecyclerListView.Holder(new MonthView(parent.getContext()));
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ MonthView monthView = (MonthView) holder.itemView;
+
+ int year = startFromYear - position / 12;
+ int month = startFromMonth - position % 12;
+ if (month < 0) {
+ month += 12;
+ year--;
+ }
+ boolean animated = monthView.currentYear == year && monthView.currentMonthInYear == month;
+ monthView.setDate(year, month, messagesByYearMounth.get(year * 100 + month), animated);
+ monthView.startSelectionAnimation(dateSelectedStart, dateSelectedEnd);
+ monthView.setSelectionValue(1f);
+ updateRowSelections(monthView, false);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ int year = startFromYear - position / 12;
+ int month = startFromMonth - position % 12;
+ return year * 100L + month;
+ }
+
+ @Override
+ public int getItemCount() {
+ return monthCount;
+ }
+ }
+
+ private class MonthView extends FrameLayout {
+
+ SimpleTextView titleView;
+ int currentYear;
+ int currentMonthInYear;
+ int daysInMonth;
+ int startDayOfWeek;
+ int cellCount;
+ int startMonthTime;
+
+ SparseArray messagesByDays = new SparseArray<>();
+ SparseArray imagesByDays = new SparseArray<>();
+
+ boolean attached;
+
+ GestureDetectorCompat gestureDetector;
+
+ public MonthView(Context context) {
+ super(context);
+ setWillNotDraw(false);
+ titleView = new SimpleTextView(context);
+ if (calendarType == TYPE_CHAT_ACTIVITY && canClearHistory) {
+ titleView.setOnLongClickListener(view -> {
+ if (messagesByDays == null) {
+ return false;
+ }
+ int start = -1;
+ int end = -1;
+ for (int i = 0; i < daysInMonth; i++) {
+ PeriodDay day = messagesByDays.get(i, null);
+ if (day != null) {
+ if (start == -1) {
+ start = day.date;
+ }
+ end = day.date;
+ }
+ }
+
+ if (start >= 0 && end >= 0) {
+ inSelectionMode = true;
+ dateSelectedStart = start;
+ dateSelectedEnd = end;
+ updateTitle();
+ animateSelection();
+ }
+
+ return false;
+ });
+ titleView.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (messagesByDays == null) {
+ return;
+ }
+ if (inSelectionMode) {
+ int start = -1;
+ int end = -1;
+ for (int i = 0; i < daysInMonth; i++) {
+ PeriodDay day = messagesByDays.get(i, null);
+ if (day != null) {
+ if (start == -1) {
+ start = day.date;
+ }
+ end = day.date;
+ }
+ }
+
+ if (start >= 0 && end >= 0) {
+ dateSelectedStart = start;
+ dateSelectedEnd = end;
+ updateTitle();
+ animateSelection();
+ }
+ }
+ }
+ });
+ }
+ titleView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 2));
+ titleView.setTextSize(15);
+ titleView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ titleView.setGravity(Gravity.CENTER);
+ titleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28, 0, 0, 12, 0, 4));
+
+ gestureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() {
+
+ @Override
+ public boolean onDown(MotionEvent e) {
+ return true;
+ }
+
+
+ @SuppressLint("NotifyDataSetChanged")
+ @Override
+ public boolean onSingleTapUp(MotionEvent e) {
+ if (calendarType == TYPE_MEDIA_CALENDAR && messagesByDays != null) {
+ PeriodDay day = getDayAtCoord(e.getX(), e.getY());
+ if (day != null && day.messageObject != null && callback != null) {
+ callback.onDateSelected(day.messageObject.getId(), day.startOffset);
+ finishFragment();
+ }
+ }
+ if (messagesByDays != null) {
+ if (inSelectionMode) {
+ PeriodDay day = getDayAtCoord(e.getX(), e.getY());
+ if (day != null) {
+ if (selectionAnimator != null) {
+ selectionAnimator.cancel();
+ selectionAnimator = null;
+ }
+ if (dateSelectedStart != 0 || dateSelectedEnd != 0) {
+ if (dateSelectedStart == day.date && dateSelectedEnd == day.date) {
+ dateSelectedStart = dateSelectedEnd = 0;
+ } else if (dateSelectedStart == day.date) {
+ dateSelectedStart = dateSelectedEnd;
+ } else if (dateSelectedEnd == day.date) {
+ dateSelectedEnd = dateSelectedStart;
+ } else if (dateSelectedStart == dateSelectedEnd) {
+ if (day.date > dateSelectedEnd) {
+ dateSelectedEnd = day.date;
+ } else {
+ dateSelectedStart = day.date;
+ }
+ } else {
+ dateSelectedStart = dateSelectedEnd = day.date;
+ }
+ } else {
+ dateSelectedStart = dateSelectedEnd = day.date;
+
+ }
+ updateTitle();
+ animateSelection();
+ }
+ } else {
+ PeriodDay day = getDayAtCoord(e.getX(), e.getY());
+ if (parentLayout.fragmentsStack.size() >= 2) {
+ BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2);
+ if (fragment instanceof ChatActivity) {
+ finishFragment();
+ ((ChatActivity) fragment).jumpToDate(day.date);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private PeriodDay getDayAtCoord(float pressedX, float pressedY) {
+ if (messagesByDays == null) {
+ return null;
+ }
+ int currentCell = 0;
+ int currentColumn = startDayOfWeek;
+
+ float xStep = getMeasuredWidth() / 7f;
+ float yStep = AndroidUtilities.dp(44 + 8);
+ int hrad = AndroidUtilities.dp(44) / 2;
+ for (int i = 0; i < daysInMonth; i++) {
+ float cx = xStep * currentColumn + xStep / 2f;
+ float cy = yStep * currentCell + yStep / 2f + AndroidUtilities.dp(44);
+
+ if (pressedX >= cx - hrad && pressedX <= cx + hrad && pressedY >= cy - hrad && pressedY <= cy + hrad) {
+ PeriodDay day = messagesByDays.get(i, null);
+ if (day != null) {
+ return day;
+ }
+ }
+
+ currentColumn++;
+ if (currentColumn >= 7) {
+ currentColumn = 0;
+ currentCell++;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void onLongPress(MotionEvent e) {
+ super.onLongPress(e);
+ if (calendarType != TYPE_CHAT_ACTIVITY) {
+ return;
+ }
+ PeriodDay periodDay = getDayAtCoord(e.getX(), e.getY());
+
+ if (periodDay != null) {
+ performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+
+ Bundle bundle = new Bundle();
+ if (dialogId > 0) {
+ bundle.putLong("user_id", dialogId);
+ } else {
+ bundle.putLong("chat_id", -dialogId);
+ }
+ bundle.putInt("start_from_date", periodDay.date);
+ bundle.putBoolean("need_remove_previous_same_chat_activity", false);
+ ChatActivity chatActivity = new ChatActivity(bundle);
+
+ ActionBarPopupWindow.ActionBarPopupWindowLayout previewMenu = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity(), R.drawable.popup_fixed_alert, getResourceProvider());
+ previewMenu.setBackgroundColor(getThemedColor(Theme.key_actionBarDefaultSubmenuBackground));
+
+ ActionBarMenuSubItem cellJump = new ActionBarMenuSubItem(getParentActivity(), true, false);
+ cellJump.setTextAndIcon(LocaleController.getString("JumpToDate", R.string.JumpToDate), R.drawable.msg_message);
+ cellJump.setMinimumWidth(160);
+ cellJump.setOnClickListener(view -> {
+ if (parentLayout.fragmentsStack.size() >= 3) {
+ BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 3);
+ if (fragment instanceof ChatActivity) {
+ AndroidUtilities.runOnUIThread(() -> {
+ finishFragment();
+ ((ChatActivity) fragment).jumpToDate(periodDay.date);
+ }, 300);
+ }
+ }
+ finishPreviewFragment();
+ });
+ previewMenu.addView(cellJump);
+
+ if (canClearHistory) {
+ ActionBarMenuSubItem cellSelect = new ActionBarMenuSubItem(getParentActivity(), false, false);
+ cellSelect.setTextAndIcon(LocaleController.getString("SelectThisDay", R.string.SelectThisDay), R.drawable.msg_select);
+ cellSelect.setMinimumWidth(160);
+ cellSelect.setOnClickListener(view -> {
+ dateSelectedStart = dateSelectedEnd = periodDay.date;
+ inSelectionMode = true;
+ updateTitle();
+ animateSelection();
+ finishPreviewFragment();
+ });
+ previewMenu.addView(cellSelect);
+
+ ActionBarMenuSubItem cellDelete = new ActionBarMenuSubItem(getParentActivity(), false, true);
+ cellDelete.setTextAndIcon(LocaleController.getString("ClearHistory", R.string.ClearHistory), R.drawable.msg_delete);
+ cellDelete.setMinimumWidth(160);
+ cellDelete.setOnClickListener(view -> {
+ if (parentLayout.fragmentsStack.size() >= 3) {
+ BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 3);
+ if (fragment instanceof ChatActivity) {
+ AlertsCreator.createClearDaysDialogAlert(CalendarActivity.this, 1, getMessagesController().getUser(dialogId), new MessagesStorage.BooleanCallback() {
+ @Override
+ public void run(boolean forAll) {
+ finishFragment();
+ ((ChatActivity) fragment).deleteHistory(dateSelectedStart, dateSelectedEnd + 86400, forAll);
+ }
+ }, null);
+ }
+ }
+ finishPreviewFragment();
+ });
+ previewMenu.addView(cellDelete);
+ }
+ previewMenu.setFitItems(true);
+
+
+ blurredView = new View(context) {
+ @Override
+ public void setAlpha(float alpha) {
+ super.setAlpha(alpha);
+ if (fragmentView != null) {
+ fragmentView.invalidate();
+ }
+ }
+ };
+ blurredView.setOnClickListener(view -> {
+ finishPreviewFragment();
+ });
+ blurredView.setVisibility(View.GONE);
+ blurredView.setFitsSystemWindows(true);
+ parentLayout.containerView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
+ prepareBlurBitmap();
+
+ presentFragmentAsPreviewWithMenu(chatActivity, previewMenu);
+
+ }
+ }
+ });
+ gestureDetector.setIsLongpressEnabled(calendarType == TYPE_CHAT_ACTIVITY);
+ }
+
+ private void startSelectionAnimation(int fromDate, int toDate) {
+ if (messagesByDays != null) {
+ for (int i = 0; i < daysInMonth; i++) {
+ PeriodDay day = messagesByDays.get(i, null);
+ if (day != null) {
+ day.fromSelProgress = day.selectProgress;
+ day.toSelProgress = day.date >= fromDate && day.date <= toDate ? 1 : 0;
+
+ day.fromSelSEProgress = day.selectStartEndProgress;
+ if (day.date == fromDate || day.date == toDate)
+ day.toSelSEProgress = 1;
+ else day.toSelSEProgress = 0;
+ }
+ }
+ }
+ }
+
+ private void setSelectionValue(float f) {
+ if (messagesByDays != null) {
+ for (int i = 0; i < daysInMonth; i++) {
+ PeriodDay day = messagesByDays.get(i, null);
+ if (day != null) {
+ day.selectProgress = day.fromSelProgress + (day.toSelProgress - day.fromSelProgress) * f;
+ day.selectStartEndProgress = day.fromSelSEProgress + (day.toSelSEProgress - day.fromSelSEProgress) * f;
+ }
+ }
+ }
+ invalidate();
+ }
+
+ private SparseArray rowAnimators = new SparseArray<>();
+ private SparseArray rowSelectionPos = new SparseArray<>();
+
+ public void dismissRowAnimations(boolean animate) {
+ for (int i = 0; i < rowSelectionPos.size(); i++) {
+ animateRow(rowSelectionPos.keyAt(i), 0, 0, false, animate);
+ }
+ }
+
+ public void animateRow(int row, int startColumn, int endColumn, boolean appear, boolean animate) {
+ ValueAnimator a = rowAnimators.get(row);
+ if (a != null) a.cancel();
+
+ float xStep = getMeasuredWidth() / 7f;
+
+ float cxFrom1, cxFrom2, fromAlpha;
+ RowAnimationValue p = rowSelectionPos.get(row);
+ if (p != null) {
+ cxFrom1 = p.startX;
+ cxFrom2 = p.endX;
+ fromAlpha = p.alpha;
+ } else {
+ cxFrom1 = xStep * startColumn + xStep / 2f;
+ cxFrom2 = xStep * startColumn + xStep / 2f;
+ fromAlpha = 0;
+ }
+ float cxTo1 = appear ? xStep * startColumn + xStep / 2f : cxFrom1;
+ float cxTo2 = appear ? xStep * endColumn + xStep / 2f : cxFrom2;
+ float toAlpha = appear ? 1 : 0;
+
+ RowAnimationValue pr = new RowAnimationValue(cxFrom1, cxFrom2);
+ rowSelectionPos.put(row, pr);
+
+ if (animate) {
+ ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(300);
+ anim.setInterpolator(Easings.easeInOutQuad);
+ anim.addUpdateListener(animation -> {
+ float val = (float) animation.getAnimatedValue();
+ pr.startX = cxFrom1 + (cxTo1 - cxFrom1) * val;
+ pr.endX = cxFrom2 + (cxTo2 - cxFrom2) * val;
+ pr.alpha = fromAlpha + (toAlpha - fromAlpha) * val;
+ invalidate();
+ });
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ pr.startX = cxTo1;
+ pr.endX = cxTo2;
+ pr.alpha = toAlpha;
+ invalidate();
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ rowAnimators.remove(row);
+ if (!appear)
+ rowSelectionPos.remove(row);
+ }
+ });
+ anim.start();
+ rowAnimators.put(row, anim);
+ } else {
+ pr.startX = cxTo1;
+ pr.endX = cxTo2;
+ pr.alpha = toAlpha;
+ invalidate();
+ }
+ }
+
+ @SuppressLint("ClickableViewAccessibility")
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ return gestureDetector.onTouchEvent(event);
+ }
+
+ public void setDate(int year, int monthInYear, SparseArray messagesByDays, boolean animated) {
+ boolean dateChanged = year != currentYear || monthInYear != currentMonthInYear;
+ currentYear = year;
+ currentMonthInYear = monthInYear;
+ this.messagesByDays = messagesByDays;
+
+ if (dateChanged) {
+ if (imagesByDays != null) {
+ for (int i = 0; i < imagesByDays.size(); i++) {
+ imagesByDays.valueAt(i).onDetachedFromWindow();
+ imagesByDays.valueAt(i).setParentView(null);
+ }
+ imagesByDays = null;
+ }
+ }
+ if (messagesByDays != null) {
+ if (imagesByDays == null) {
+ imagesByDays = new SparseArray<>();
+ }
+
+ for (int i = 0; i < messagesByDays.size(); i++) {
+ int key = messagesByDays.keyAt(i);
+ if (imagesByDays.get(key, null) != null || !messagesByDays.get(key).hasImage) {
+ continue;
+ }
+ ImageReceiver receiver = new ImageReceiver();
+ receiver.setParentView(this);
+ PeriodDay periodDay = messagesByDays.get(key);
+ MessageObject messageObject = periodDay.messageObject;
+ if (messageObject != null) {
+ if (messageObject.isVideo()) {
+ TLRPC.Document document = messageObject.getDocument();
+ TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 50);
+ TLRPC.PhotoSize qualityThumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 320);
+ if (thumb == qualityThumb) {
+ qualityThumb = null;
+ }
+ if (thumb != null) {
+ if (messageObject.strippedThumb != null) {
+ receiver.setImage(ImageLocation.getForDocument(qualityThumb, document), "44_44", messageObject.strippedThumb, null, messageObject, 0);
+ } else {
+ receiver.setImage(ImageLocation.getForDocument(qualityThumb, document), "44_44", ImageLocation.getForDocument(thumb, document), "b", (String) null, messageObject, 0);
+ }
+ }
+ } else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) {
+ TLRPC.PhotoSize currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 50);
+ TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 320, false, currentPhotoObjectThumb, false);
+ if (messageObject.mediaExists || DownloadController.getInstance(currentAccount).canDownloadMedia(messageObject)) {
+ if (currentPhotoObject == currentPhotoObjectThumb) {
+ currentPhotoObjectThumb = null;
+ }
+ if (messageObject.strippedThumb != null) {
+ receiver.setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "44_44", null, null, messageObject.strippedThumb, currentPhotoObject != null ? currentPhotoObject.size : 0, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1);
+ } else {
+ receiver.setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "44_44", ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", currentPhotoObject != null ? currentPhotoObject.size : 0, null, messageObject, messageObject.shouldEncryptPhotoOrVideo() ? 2 : 1);
+ }
+ } else {
+ if (messageObject.strippedThumb != null) {
+ receiver.setImage(null, null, messageObject.strippedThumb, null, messageObject, 0);
+ } else {
+ receiver.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, messageObject.photoThumbsObject), "b", (String) null, messageObject, 0);
+ }
+ }
+ }
+ receiver.setRoundRadius(AndroidUtilities.dp(22));
+ imagesByDays.put(key, receiver);
+ }
+ }
+ }
+
+ YearMonth yearMonthObject = YearMonth.of(year, monthInYear + 1);
+ daysInMonth = yearMonthObject.lengthOfMonth();
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(year, monthInYear, 0);
+ startDayOfWeek = (calendar.get(Calendar.DAY_OF_WEEK) + 6) % 7;
+ startMonthTime = (int) (calendar.getTimeInMillis() / 1000L);
+
+ int totalColumns = daysInMonth + startDayOfWeek;
+ cellCount = (int) (totalColumns / 7f) + (totalColumns % 7 == 0 ? 0 : 1);
+ calendar.set(year, monthInYear + 1, 0);
+ titleView.setText(LocaleController.formatYearMont(calendar.getTimeInMillis() / 1000, true));
+
+ updateRowSelections(this, false);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(cellCount * (44 + 8) + 44), MeasureSpec.EXACTLY));
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ int currentCell = 0;
+ int currentColumn = startDayOfWeek;
+ float xStep = getMeasuredWidth() / 7f;
+ float yStep = AndroidUtilities.dp(44 + 8);
+
+ int selSize = AndroidUtilities.dp(44);
+ for (int row = 0; row < Math.ceil((startDayOfWeek + daysInMonth) / 7f); row++) {
+ float cy = yStep * row + yStep / 2f + AndroidUtilities.dp(44);
+ RowAnimationValue v = rowSelectionPos.get(row);
+ if (v != null) {
+ selectPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
+ selectPaint.setAlpha((int) (v.alpha * (255 * 0.16f)));
+ AndroidUtilities.rectTmp.set(v.startX - selSize / 2f, cy - selSize / 2f, v.endX + selSize / 2f, cy + selSize / 2f);
+ int dp = AndroidUtilities.dp(32);
+ canvas.drawRoundRect(AndroidUtilities.rectTmp, dp, dp, selectPaint);
+ }
+ }
+ for (int i = 0; i < daysInMonth; i++) {
+ float cx = xStep * currentColumn + xStep / 2f;
+ float cy = yStep * currentCell + yStep / 2f + AndroidUtilities.dp(44);
+ int nowTime = (int) (System.currentTimeMillis() / 1000L);
+
+ PeriodDay day = messagesByDays != null ? messagesByDays.get(i, null) : null;
+ if (nowTime < startMonthTime + (i + 1) * 86400 || (minDate > 0 && minDate > startMonthTime + (i + 2) * 86400)) {
+ int oldAlpha = textPaint.getAlpha();
+ textPaint.setAlpha((int) (oldAlpha * 0.3f));
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), textPaint);
+ textPaint.setAlpha(oldAlpha);
+ } else if (day != null && day.hasImage) {
+ float alpha = 1f;
+ if (imagesByDays.get(i) != null) {
+ if (checkEnterItems && !day.wasDrawn) {
+ day.enterAlpha = 0f;
+ day.startEnterDelay = Math.max(0, (cy + getY()) / listView.getMeasuredHeight() * 150);
+ }
+ if (day.startEnterDelay > 0) {
+ day.startEnterDelay -= 16;
+ if (day.startEnterDelay < 0) {
+ day.startEnterDelay = 0;
+ } else {
+ invalidate();
+ }
+ }
+ if (day.startEnterDelay >= 0 && day.enterAlpha != 1f) {
+ day.enterAlpha += 16 / 220f;
+ if (day.enterAlpha > 1f) {
+ day.enterAlpha = 1f;
+ } else {
+ invalidate();
+ }
+ }
+ alpha = day.enterAlpha;
+ if (alpha != 1f) {
+ canvas.save();
+ float s = 0.8f + 0.2f * alpha;
+ canvas.scale(s, s, cx, cy);
+ }
+ int pad = (int) (AndroidUtilities.dp(7f) * day.selectProgress);
+ if (day.selectStartEndProgress >= 0.01f) {
+ selectPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
+ selectPaint.setAlpha((int) (day.selectStartEndProgress * 0xFF));
+ canvas.drawCircle(cx, cy, AndroidUtilities.dp(44) / 2f, selectPaint);
+
+ selectOutlinePaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
+ AndroidUtilities.rectTmp.set(cx - AndroidUtilities.dp(44) / 2f, cy - AndroidUtilities.dp(44) / 2f, cx + AndroidUtilities.dp(44) / 2f, cy + AndroidUtilities.dp(44) / 2f);
+ canvas.drawArc(AndroidUtilities.rectTmp, -90, day.selectStartEndProgress * 360, false, selectOutlinePaint);
+ }
+
+ imagesByDays.get(i).setAlpha(day.enterAlpha);
+ imagesByDays.get(i).setImageCoords(cx - (AndroidUtilities.dp(44) - pad) / 2f, cy - (AndroidUtilities.dp(44) - pad) / 2f, AndroidUtilities.dp(44) - pad, AndroidUtilities.dp(44) - pad);
+ imagesByDays.get(i).draw(canvas);
+
+ blackoutPaint.setColor(ColorUtils.setAlphaComponent(Color.BLACK, (int) (day.enterAlpha * 80)));
+ canvas.drawCircle(cx, cy, (AndroidUtilities.dp(44) - pad) / 2f, blackoutPaint);
+ day.wasDrawn = true;
+ if (alpha != 1f) {
+ canvas.restore();
+ }
+ }
+ if (alpha != 1f) {
+ int oldAlpha = textPaint.getAlpha();
+ textPaint.setAlpha((int) (oldAlpha * (1f - alpha)));
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), textPaint);
+ textPaint.setAlpha(oldAlpha);
+
+ oldAlpha = textPaint.getAlpha();
+ activeTextPaint.setAlpha((int) (oldAlpha * alpha));
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), activeTextPaint);
+ activeTextPaint.setAlpha(oldAlpha);
+ } else {
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), activeTextPaint);
+ }
+ } else {
+ if (day != null && day.selectStartEndProgress >= 0.01f) {
+ selectPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
+ selectPaint.setAlpha((int) (day.selectStartEndProgress * 0xFF));
+ canvas.drawCircle(cx, cy, AndroidUtilities.dp(44) / 2f, selectPaint);
+
+ selectOutlinePaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
+ AndroidUtilities.rectTmp.set(cx - AndroidUtilities.dp(44) / 2f, cy - AndroidUtilities.dp(44) / 2f, cx + AndroidUtilities.dp(44) / 2f, cy + AndroidUtilities.dp(44) / 2f);
+ canvas.drawArc(AndroidUtilities.rectTmp, -90, day.selectStartEndProgress * 360, false, selectOutlinePaint);
+
+ int pad = (int) (AndroidUtilities.dp(7f) * day.selectStartEndProgress);
+ selectPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
+ selectPaint.setAlpha((int) (day.selectStartEndProgress * 0xFF));
+ canvas.drawCircle(cx, cy, (AndroidUtilities.dp(44) - pad) / 2f, selectPaint);
+
+ float alpha = day.selectStartEndProgress;
+ if (alpha != 1f) {
+ int oldAlpha = textPaint.getAlpha();
+ textPaint.setAlpha((int) (oldAlpha * (1f - alpha)));
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), textPaint);
+ textPaint.setAlpha(oldAlpha);
+
+ oldAlpha = textPaint.getAlpha();
+ activeTextPaint.setAlpha((int) (oldAlpha * alpha));
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), activeTextPaint);
+ activeTextPaint.setAlpha(oldAlpha);
+ } else {
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), activeTextPaint);
+ }
+ } else {
+ canvas.drawText(Integer.toString(i + 1), cx, cy + AndroidUtilities.dp(5), textPaint);
+ }
+ }
+
+ currentColumn++;
+ if (currentColumn >= 7) {
+ currentColumn = 0;
+ currentCell++;
+ }
+ }
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ attached = true;
+ if (imagesByDays != null) {
+ for (int i = 0; i < imagesByDays.size(); i++) {
+ imagesByDays.valueAt(i).onAttachedToWindow();
+ }
+ }
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ attached = false;
+ if (imagesByDays != null) {
+ for (int i = 0; i < imagesByDays.size(); i++) {
+ imagesByDays.valueAt(i).onDetachedFromWindow();
+ }
+ }
+ }
+ }
+
+ int lastDaysSelected;
+ boolean lastInSelectionMode;
+
+ private void updateTitle() {
+ if (!canClearHistory) {
+ actionBar.setTitle(LocaleController.getString("Calendar", R.string.Calendar));
+ backDrawable.setRotation(0f, true);
+ return;
+ }
+ int daysSelected;
+ if (dateSelectedStart == dateSelectedEnd && dateSelectedStart == 0) {
+ daysSelected = 0;
+ } else {
+ daysSelected = 1 + (Math.abs(dateSelectedStart - dateSelectedEnd) / 86400);
+ }
+ boolean oldInSelectionMode = lastInSelectionMode;
+ if (daysSelected != lastDaysSelected || lastInSelectionMode != inSelectionMode) {
+ boolean fromBottom = lastDaysSelected > daysSelected;
+ lastDaysSelected = daysSelected;
+ lastInSelectionMode = inSelectionMode;
+ String title;
+ if (daysSelected > 0) {
+ title = LocaleController.formatPluralString("Days", daysSelected);
+ backDrawable.setRotation(1f, true);
+ } else if (inSelectionMode) {
+ title = LocaleController.getString("SelectDays", R.string.SelectDays);
+ backDrawable.setRotation(1f, true);
+ } else {
+ title = LocaleController.getString("Calendar", R.string.Calendar);
+ backDrawable.setRotation(0f, true);
+ }
+ if (daysSelected > 1) {
+ removeDaysButton.setText(LocaleController.formatString("ClearHistoryForTheseDays", R.string.ClearHistoryForTheseDays));
+ } else if (daysSelected > 0 || inSelectionMode) {
+ removeDaysButton.setText(LocaleController.formatString("ClearHistoryForThisDay", R.string.ClearHistoryForThisDay));
+ }
+ actionBar.setTitleAnimated(title, fromBottom, 150);
+
+
+ if ((!inSelectionMode || daysSelected > 0) && selectDaysHint != null) {
+ selectDaysHint.hide();
+ }
+ if (daysSelected > 0 || inSelectionMode) {
+ if (removeDaysButton.getVisibility() == View.GONE) {
+ removeDaysButton.setAlpha(0f);
+ removeDaysButton.setTranslationY(-AndroidUtilities.dp(20));
+ }
+ removeDaysButton.setVisibility(View.VISIBLE);
+ selectDaysButton.animate().setListener(null).cancel();
+ removeDaysButton.animate().setListener(null).cancel();
+ selectDaysButton.animate().alpha(0f).translationY(AndroidUtilities.dp(20)).setDuration(150).setListener(new HideViewAfterAnimation(selectDaysButton)).start();
+ removeDaysButton.animate().alpha(daysSelected == 0 ? 0.5f : 1f).translationY(0).start();
+ selectDaysButton.setEnabled(false);
+ removeDaysButton.setEnabled(true);
+ } else {
+ if (selectDaysButton.getVisibility() == View.GONE) {
+ selectDaysButton.setAlpha(0f);
+ selectDaysButton.setTranslationY(AndroidUtilities.dp(20));
+ }
+ selectDaysButton.setVisibility(View.VISIBLE);
+ selectDaysButton.animate().setListener(null).cancel();
+ removeDaysButton.animate().setListener(null).cancel();
+ selectDaysButton.animate().alpha(1f).translationY(0).start();
+ removeDaysButton.animate().alpha(0f).translationY(-AndroidUtilities.dp(20)).setDuration(150).setListener(new HideViewAfterAnimation(removeDaysButton)).start();
+ selectDaysButton.setEnabled(true);
+ removeDaysButton.setEnabled(false);
+ }
+ }
+
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ public interface Callback {
+ void onDateSelected(int messageId, int startOffset);
+ }
+
+ private class PeriodDay {
+ MessageObject messageObject;
+ int startOffset;
+ float enterAlpha = 1f;
+ float startEnterDelay = 1f;
+ boolean wasDrawn;
+ boolean hasImage = true;
+ int date;
+
+ float selectStartEndProgress;
+ float fromSelSEProgress;
+ float toSelSEProgress;
+
+ float selectProgress;
+ float fromSelProgress;
+ float toSelProgress;
+ }
+
+ @Override
+ public ArrayList getThemeDescriptions() {
+
+ ThemeDescription.ThemeDescriptionDelegate descriptionDelegate = new ThemeDescription.ThemeDescriptionDelegate() {
+ @Override
+ public void didSetColor() {
+ updateColors();
+ }
+ };
+ ArrayList themeDescriptions = new ArrayList<>();
+ new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_windowBackgroundWhite);
+ new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_windowBackgroundWhiteBlackText);
+ new ThemeDescription(null, 0, null, null, null, descriptionDelegate, Theme.key_listSelector);
+
+
+ return super.getThemeDescriptions();
+ }
+
+ @Override
+ public boolean needDelayOpenAnimation() {
+ return true;
+ }
+
+ @Override
+ protected void onTransitionAnimationStart(boolean isOpen, boolean backward) {
+ super.onTransitionAnimationStart(isOpen, backward);
+ isOpened = true;
+ }
+
+ @Override
+ protected void onTransitionAnimationProgress(boolean isOpen, float progress) {
+ super.onTransitionAnimationProgress(isOpen, progress);
+ if (blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
+ if (isOpen) {
+ blurredView.setAlpha(1.0f - progress);
+ } else {
+ blurredView.setAlpha(progress);
+ }
+ }
+ }
+
+ @Override
+ protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
+ if (isOpen && blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
+ blurredView.setVisibility(View.GONE);
+ blurredView.setBackground(null);
+ }
+ }
+
+ private void animateSelection() {
+ ValueAnimator a = ValueAnimator.ofFloat(0f, 1f).setDuration(300);
+ a.setInterpolator(CubicBezierInterpolator.DEFAULT);
+ a.addUpdateListener(animation -> {
+ float selectProgress = (float) animation.getAnimatedValue();
+ for (int j = 0; j < listView.getChildCount(); j++) {
+ MonthView m = (MonthView) listView.getChildAt(j);
+ m.setSelectionValue(selectProgress);
+ }
+ });
+ a.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ for (int j = 0; j < listView.getChildCount(); j++) {
+ MonthView m = (MonthView) listView.getChildAt(j);
+ m.startSelectionAnimation(dateSelectedStart, dateSelectedEnd);
+ }
+ }
+ });
+ a.start();
+ selectionAnimator = a;
+
+ int minIndex = Integer.MAX_VALUE;
+ int maxIndex = -1;
+ for (int j = 0; j < listView.getChildCount(); j++) {
+ MonthView m = (MonthView) listView.getChildAt(j);
+ updateRowSelections(m, true);
+ }
+
+ for (int j = 0; j < listView.getCachedChildCount(); j++) {
+ MonthView m = (MonthView) listView.getCachedChildAt(j);
+ updateRowSelections(m, false);
+ m.startSelectionAnimation(dateSelectedStart, dateSelectedEnd);
+ m.setSelectionValue(1f);
+ }
+ for (int j = 0; j < listView.getHiddenChildCount(); j++) {
+ MonthView m = (MonthView) listView.getHiddenChildAt(j);
+ updateRowSelections(m, false);
+ m.startSelectionAnimation(dateSelectedStart, dateSelectedEnd);
+ m.setSelectionValue(1f);
+ }
+ for (int j = 0; j < listView.getAttachedScrapChildCount(); j++) {
+ MonthView m = (MonthView) listView.getAttachedScrapChildAt(j);
+ updateRowSelections(m, false);
+ m.startSelectionAnimation(dateSelectedStart, dateSelectedEnd);
+ m.setSelectionValue(1f);
+ }
+ }
+
+ private void updateRowSelections(MonthView m, boolean animate) {
+ if (dateSelectedStart == 0 || dateSelectedEnd == 0) {
+ m.dismissRowAnimations(animate);
+ } else {
+ if (m.messagesByDays == null) {
+ return;
+ }
+ if (!animate) {
+ m.dismissRowAnimations(false);
+ }
+
+ int row = 0;
+ int dayInRow = m.startDayOfWeek;
+ int sDay = -1, eDay = -1;
+ for (int i = 0; i < m.daysInMonth; i++) {
+ PeriodDay day = m.messagesByDays.get(i, null);
+ if (day != null) {
+ if (day.date >= dateSelectedStart && day.date <= dateSelectedEnd) {
+ if (sDay == -1)
+ sDay = dayInRow;
+ eDay = dayInRow;
+ }
+ }
+
+ dayInRow++;
+ if (dayInRow >= 7) {
+ dayInRow = 0;
+ if (sDay != -1 && eDay != -1) {
+ m.animateRow(row, sDay, eDay, true, animate);
+ } else m.animateRow(row, 0, 0, false, animate);
+
+ row++;
+ sDay = -1;
+ eDay = -1;
+ }
+ }
+ if (sDay != -1 && eDay != -1) {
+ m.animateRow(row, sDay, eDay, true, animate);
+ } else {
+ m.animateRow(row, 0, 0, false, animate);
+ }
+ }
+ }
+
+ private final static class RowAnimationValue {
+ float startX, endX;
+ float alpha;
+
+ RowAnimationValue(float s, float e) {
+ startX = s;
+ endX = e;
+ }
+ }
+
+ private void prepareBlurBitmap() {
+ if (blurredView == null) {
+ return;
+ }
+ int w = (int) (parentLayout.getMeasuredWidth() / 6.0f);
+ int h = (int) (parentLayout.getMeasuredHeight() / 6.0f);
+ Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ canvas.scale(1.0f / 6.0f, 1.0f / 6.0f);
+ parentLayout.draw(canvas);
+ Utilities.stackBlurBitmap(bitmap, Math.max(7, Math.max(w, h) / 180));
+ blurredView.setBackground(new BitmapDrawable(bitmap));
+ blurredView.setAlpha(0.0f);
+ blurredView.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public boolean onBackPressed() {
+ if (inSelectionMode) {
+ inSelectionMode = false;
+ dateSelectedStart = dateSelectedEnd = 0;
+ updateTitle();
+ animateSelection();
+ return false;
+ }
+ return super.onBackPressed();
+ }
+}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CameraScanActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CameraScanActivity.java
index 1b92f9417..0dbeb62b9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/CameraScanActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CameraScanActivity.java
@@ -13,6 +13,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.ImageFormat;
import android.graphics.Paint;
import android.graphics.Path;
@@ -24,6 +25,8 @@ import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.HandlerThread;
+import android.text.SpannableStringBuilder;
+import android.text.Spanned;
import android.text.TextUtils;
import android.util.SparseArray;
import android.util.TypedValue;
@@ -33,6 +36,8 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
+import androidx.core.graphics.ColorUtils;
+
import com.google.android.gms.vision.Frame;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.gms.vision.barcode.BarcodeDetector;
@@ -65,6 +70,10 @@ import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper;
+import org.telegram.ui.Components.LinkPath;
+import org.telegram.ui.Components.TextPaintWebpageUrlSpan;
+import org.telegram.ui.Components.TypefaceSpan;
+import org.telegram.ui.Components.URLSpanNoUnderline;
import java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -97,6 +106,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
public static final int TYPE_MRZ = 0;
public static final int TYPE_QR = 1;
+ public static final int TYPE_QR_LOGIN = 2;
public interface CameraScanActivityDelegate {
default void didFindMrzInfo(MrzRecognizer.Result result) {
@@ -108,7 +118,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
}
}
- public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, CameraScanActivityDelegate delegate) {
+ public static ActionBarLayout[] showAsSheet(BaseFragment parentFragment, boolean gallery, int type, CameraScanActivityDelegate delegate) {
if (parentFragment == null || parentFragment.getParentActivity() == null) {
return null;
}
@@ -116,7 +126,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
BottomSheet bottomSheet = new BottomSheet(parentFragment.getParentActivity(), false) {
{
actionBarLayout[0].init(new ArrayList<>());
- CameraScanActivity fragment = new CameraScanActivity(TYPE_QR) {
+ CameraScanActivity fragment = new CameraScanActivity(type) {
@Override
public void finishFragment() {
dismiss();
@@ -171,7 +181,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
// }
});
currentType = type;
- if (currentType == TYPE_QR) {
+ if (isQr()) {
qrReader = new QRCodeReader();
visionQrReader = new BarcodeDetector.Builder(ApplicationLoader.applicationContext).setBarcodeFormats(Barcode.QR_CODE).build();
}
@@ -200,7 +210,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
actionBar.setItemsColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), false);
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarWhiteSelector), false);
actionBar.setCastShadows(false);
- if (!AndroidUtilities.isTablet() && currentType != TYPE_QR) {
+ if (!AndroidUtilities.isTablet() && !isQr()) {
actionBar.showActionModeTop();
}
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@@ -235,7 +245,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
}
flashButton.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(60), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(60), MeasureSpec.EXACTLY));
}
- titleTextView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
+ titleTextView.measure(MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(72), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
descriptionText.measure(MeasureSpec.makeMeasureSpec((int) (width * 0.9f), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.UNSPECIFIED));
setMeasuredDimension(width, height);
@@ -250,15 +260,19 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
if (currentType == TYPE_MRZ) {
cameraView.layout(0, y, cameraView.getMeasuredWidth(), y + cameraView.getMeasuredHeight());
y = (int) (height * 0.65f);
- titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
+ titleTextView.layout(AndroidUtilities.dp(36), y, AndroidUtilities.dp(36) + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
recognizedMrzView.setTextSize(TypedValue.COMPLEX_UNIT_PX, cameraView.getMeasuredHeight() / 22);
recognizedMrzView.setPadding(0, 0, 0, cameraView.getMeasuredHeight() / 15);
} else {
actionBar.layout(0, 0, actionBar.getMeasuredWidth(), actionBar.getMeasuredHeight());
cameraView.layout(0, 0, cameraView.getMeasuredWidth(), cameraView.getMeasuredHeight());
int size = (int) (Math.min(cameraView.getWidth(), cameraView.getHeight()) / 1.5f);
- y = (cameraView.getMeasuredHeight() - size) / 2 - titleTextView.getMeasuredHeight() - AndroidUtilities.dp(30);
- titleTextView.layout(0, y, titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
+ if (currentType == TYPE_QR) {
+ y = (cameraView.getMeasuredHeight() - size) / 2 - titleTextView.getMeasuredHeight() - AndroidUtilities.dp(30);
+ } else {
+ y = (cameraView.getMeasuredHeight() - size) / 2 - titleTextView.getMeasuredHeight() - AndroidUtilities.dp(64);
+ }
+ titleTextView.layout(AndroidUtilities.dp(36), y, AndroidUtilities.dp(36) + titleTextView.getMeasuredWidth(), y + titleTextView.getMeasuredHeight());
recognizedMrzView.layout(0, getMeasuredHeight() - recognizedMrzView.getMeasuredHeight(), getMeasuredWidth(), getMeasuredHeight());
int x;
@@ -284,7 +298,7 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
- if (currentType == TYPE_QR && child == cameraView) {
+ if (isQr() && child == cameraView) {
int size = (int) (Math.min(child.getWidth(), child.getHeight()) / 1.5f);
int x = (child.getWidth() - size) / 2;
int y = (child.getHeight() - size) / 2;
@@ -351,9 +365,48 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
viewGroup.addView(actionBar);
}
- titleTextView = new TextView(context);
+ if (currentType == TYPE_QR_LOGIN) {
+ actionBar.setTitle(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
+ }
+
+ Paint selectionPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ selectionPaint.setColor(ColorUtils.setAlphaComponent(Color.WHITE, 100));
+ titleTextView = new TextView(context) {
+ LinkPath textPath;
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ if (getText() instanceof Spanned) {
+ Spanned spanned = (Spanned) getText();
+ URLSpanNoUnderline[] innerSpans = spanned.getSpans(0, spanned.length(), URLSpanNoUnderline.class);
+ if (innerSpans != null && innerSpans.length > 0) {
+ textPath = new LinkPath(true);
+ textPath.setAllowReset(false);
+ for (int a = 0; a < innerSpans.length; a++) {
+ int start = spanned.getSpanStart(innerSpans[a]);
+ int end = spanned.getSpanEnd(innerSpans[a]);
+ textPath.setCurrentLayout(getLayout(), start, 0);
+ int shift = getText() != null ? getPaint().baselineShift : 0;
+ textPath.setBaselineShift(shift != 0 ? shift + AndroidUtilities.dp(shift > 0 ? 5 : -2) : 0);
+ getLayout().getSelectionPath(start, end, textPath);
+ }
+ textPath.setAllowReset(true);
+ }
+ }
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ if (textPath != null) {
+ canvas.drawPath(textPath, selectionPaint);
+ }
+ super.onDraw(canvas);
+ }
+ };
titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
+
viewGroup.addView(titleTextView);
descriptionText = new TextView(context);
@@ -377,7 +430,45 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
if (needGalleryButton) {
//titleTextView.setText(LocaleController.getString("WalletScanCode", R.string.WalletScanCode));
} else {
- titleTextView.setText(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
+ if (currentType == TYPE_QR) {
+ titleTextView.setText(LocaleController.getString("AuthAnotherClientScan", R.string.AuthAnotherClientScan));
+ } else {
+ String text = LocaleController.getString("AuthAnotherClientInfo5", R.string.AuthAnotherClientInfo5);
+ SpannableStringBuilder spanned = new SpannableStringBuilder(text);
+ int index1 = text.indexOf('*');
+ int index2 = text.indexOf('*', index1 + 1);
+
+ if (index1 != -1 && index2 != -1 && index1 != index2) {
+ titleTextView.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy());
+ spanned.replace(index2, index2 + 1, " ");
+ spanned.replace(index1, index1 + 1, " ");
+ index1 += 1;
+ index2 += 1;
+ spanned.setSpan(new URLSpanNoUnderline(LocaleController.getString("AuthAnotherClientDownloadClientUrl", R.string.AuthAnotherClientDownloadClientUrl)), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ spanned.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+
+ text = spanned.toString();
+ index1 = text.indexOf('*');
+ index2 = text.indexOf('*', index1 + 1);
+
+ if (index1 != -1 && index2 != -1 && index1 != index2) {
+ spanned.replace(index2, index2 + 1, " ");
+ spanned.replace(index1, index1 + 1, " ");
+ index1 += 1;
+ index2 += 1;
+ spanned.setSpan(new URLSpanNoUnderline(LocaleController.getString("AuthAnotherWebClientUrl", R.string.AuthAnotherWebClientUrl)), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ spanned.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+
+ titleTextView.setLinkTextColor(Color.WHITE);
+ titleTextView.setHighlightColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkSelection));
+
+ titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+ titleTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ titleTextView.setPadding(0, 0, 0, 0);
+ titleTextView.setText(spanned);
+ }
}
titleTextView.setTextColor(0xffffffff);
recognizedMrzView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@@ -650,10 +741,15 @@ public class CameraScanActivity extends BaseFragment implements Camera.PreviewCa
return null;
}
+
+ private boolean isQr() {
+ return currentType == TYPE_QR || currentType == TYPE_QR_LOGIN;
+ }
+
@Override
public ArrayList getThemeDescriptions() {
ArrayList themeDescriptions = new ArrayList<>();
- if (currentType == TYPE_QR) {
+ if (isQr()) {
return themeDescriptions;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CancelAccountDeletionActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CancelAccountDeletionActivity.java
index e189298ce..31102f6eb 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/CancelAccountDeletionActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CancelAccountDeletionActivity.java
@@ -150,7 +150,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
@Override
public void onItemClick(int id) {
if (id == done_button) {
- views[currentViewNum].onNextPressed();
+ views[currentViewNum].onNextPressed(null);
} else if (id == -1) {
finishFragment();
}
@@ -337,7 +337,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
}
@Override
- public void onNextPressed() {
+ public void onNextPressed(String code) {
if (getParentActivity() == null || nextPressed) {
return;
}
@@ -392,7 +392,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
@Override
public void onShow() {
super.onShow();
- onNextPressed();
+ onNextPressed(null);
}
}
@@ -556,7 +556,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
Intent mailer = new Intent(Intent.ACTION_SENDTO);
mailer.setData(Uri.parse("mailto:"));
- mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"reports@stel.com"});
+ mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@telegram.org"});
mailer.putExtra(Intent.EXTRA_SUBJECT, "Android cancel account deletion issue " + version + " " + phone);
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + phone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);
getContext().startActivity(Intent.createChooser(mailer, "Send email..."));
@@ -744,7 +744,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
codeField[num + 1].requestFocus();
}
if ((num == length - 1 || num == length - 2 && len >= 2) && getCode().length() == length) {
- onNextPressed();
+ onNextPressed(null);
}
}
}
@@ -760,7 +760,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
});
codeField[a].setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_NEXT) {
- onNextPressed();
+ onNextPressed(null);
return true;
}
return false;
@@ -965,11 +965,13 @@ public class CancelAccountDeletionActivity extends BaseFragment {
}
@Override
- public void onNextPressed() {
+ public void onNextPressed(String code) {
if (nextPressed) {
return;
}
- String code = getCode();
+ if (code == null) {
+ code = getCode();
+ }
if (TextUtils.isEmpty(code)) {
AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
return;
@@ -1070,7 +1072,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
}
if (id == NotificationCenter.didReceiveSmsCode) {
codeField[0].setText("" + args[0]);
- onNextPressed();
+ onNextPressed(null);
} else if (id == NotificationCenter.didReceiveCall) {
String num = "" + args[0];
if (!AndroidUtilities.checkPhonePattern(pattern, num)) {
@@ -1079,7 +1081,7 @@ public class CancelAccountDeletionActivity extends BaseFragment {
ignoreOnTextChange = true;
codeField[0].setText(num);
ignoreOnTextChange = false;
- onNextPressed();
+ onNextPressed(null);
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
index f98dd1cf3..5b5e7a595 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
@@ -2369,7 +2369,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private boolean checkTextSelection(MotionEvent event) {
TextSelectionHelper.ChatListTextSelectionHelper textSelectionHelper = delegate.getTextSelectionHelper();
- if (textSelectionHelper == null) {
+ if (textSelectionHelper == null || MessagesController.getInstance(currentAccount).isChatNoForwards(currentMessageObject.getChatId())) {
return false;
}
boolean hasTextBlocks = currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty();
@@ -2434,7 +2434,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
private void updateSelectionTextPosition() {
- if (getDelegate().getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
+ if (getDelegate() != null && getDelegate().getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
int textSelectionType = getDelegate().getTextSelectionHelper().getTextSelectionType(this);
if (textSelectionType == TextSelectionHelper.ChatListTextSelectionHelper.TYPE_DESCRIPTION) {
int linkX;
@@ -2969,7 +2969,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
- if (getDelegate().getTextSelectionHelper() != null) {
+ if (getDelegate() != null && getDelegate().getTextSelectionHelper() != null) {
getDelegate().getTextSelectionHelper().onChatMessageCellDetached(this);
}
@@ -3053,7 +3053,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
animatingDrawVideoImageButtonProgress = (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO || documentAttachType == DOCUMENT_ATTACH_TYPE_GIF) && drawVideoSize ? 1.0f : 0.0f;
}
- if (getDelegate().getTextSelectionHelper() != null) {
+ if (getDelegate() != null && getDelegate().getTextSelectionHelper() != null) {
getDelegate().getTextSelectionHelper().onChatMessageCellAttached(this);
}
@@ -3177,9 +3177,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
drawVideoSize = false;
canStreamVideo = false;
animatingNoSound = 0;
- drawSideButton = !isRepliesChat && checkNeedDrawShareButton(messageObject) && (currentPosition == null || currentPosition.last) ? 1 : 0;
- if (isPinnedChat || drawSideButton == 1 && messageObject.messageOwner.fwd_from != null && !messageObject.isOutOwner() && messageObject.messageOwner.fwd_from.saved_from_peer != null && messageObject.getDialogId() == UserConfig.getInstance(currentAccount).getClientUserId()) {
- drawSideButton = 2;
+ if (MessagesController.getInstance(currentAccount).isChatNoForwards(messageObject.getChatId())) {
+ drawSideButton = 0;
+ } else {
+ drawSideButton = !isRepliesChat && checkNeedDrawShareButton(messageObject) && (currentPosition == null || currentPosition.last) ? 1 : 0;
+ if (isPinnedChat || drawSideButton == 1 && messageObject.messageOwner.fwd_from != null && !messageObject.isOutOwner() && messageObject.messageOwner.fwd_from.saved_from_peer != null && messageObject.getDialogId() == UserConfig.getInstance(currentAccount).getClientUserId()) {
+ drawSideButton = 2;
+ }
}
replyNameLayout = null;
adminLayout = null;
@@ -8118,7 +8122,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
canvas.drawPath(urlPath.get(b), Theme.chat_urlPaint);
}
}
- if (delegate.getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
+ if (delegate != null && delegate.getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
delegate.getTextSelectionHelper().drawDescription(currentMessageObject.isOutOwner(), descriptionLayout, canvas);
}
descriptionLayout.draw(canvas);
@@ -8146,7 +8150,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
imageDrawn = true;
drawTime = true;
} else {
- if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this)) {
+ if (delegate == null || delegate.getPinchToZoomHelper() == null || !delegate.getPinchToZoomHelper().isInOverlayModeFor(this) && drawInstantViewType != 11) {
if (alpha != 1f) {
photoImage.setAlpha(alpha);
imageDrawn = photoImage.draw(canvas);
@@ -11105,7 +11109,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
Theme.chat_namePaint.setColor(getThemedColor(AvatarDrawable.getNameColorNameForId(currentUser.id)));
}
} else if (currentChat != null) {
- if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) {
+ if (currentMessageObject.isOutOwner() && ChatObject.isChannel(currentChat)) {
+ if (currentBackgroundDrawable != null && currentBackgroundDrawable.hasGradient()) {
+ Theme.chat_namePaint.setColor(getThemedColor(Theme.key_chat_messageTextOut));
+ } else {
+ Theme.chat_namePaint.setColor(getThemedColor(Theme.key_chat_outForwardedNameText));
+ }
+ } else if (ChatObject.isChannel(currentChat) && !currentChat.megagroup) {
Theme.chat_namePaint.setColor(Theme.changeColorAccent(getThemedColor(AvatarDrawable.getNameColorNameForId(5))));
} else if (currentMessageObject.isOutOwner()) {
Theme.chat_namePaint.setColor(getThemedColor(Theme.key_chat_outForwardedNameText));
@@ -11844,7 +11854,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
if (!selectionOnly) {
try {
- if (getDelegate().getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
+ if (getDelegate() != null && getDelegate().getTextSelectionHelper() != null && getDelegate().getTextSelectionHelper().isSelected(currentMessageObject)) {
getDelegate().getTextSelectionHelper().drawCaption(currentMessageObject.isOutOwner(), captionLayout, canvas);
}
Emoji.emojiDrawingYOffset = -transitionYOffsetForDrawables;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PatternCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PatternCell.java
index f15f61abc..05306832d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PatternCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PatternCell.java
@@ -195,7 +195,7 @@ public class PatternCell extends BackupImageView implements DownloadController.F
if (backgroundGradientColor2 != 0) {
gradientShader = null;
if (backgroundDrawable != null) {
- backgroundDrawable.setColors(backgroundColor, backgroundGradientColor1, backgroundGradientColor2, backgroundGradientColor3, false);
+ backgroundDrawable.setColors(backgroundColor, backgroundGradientColor1, backgroundGradientColor2, backgroundGradientColor3, 0, false);
} else {
backgroundDrawable = new MotionBackgroundDrawable(backgroundColor, backgroundGradientColor1, backgroundGradientColor2, backgroundGradientColor3, true);
backgroundDrawable.setRoundRadius(AndroidUtilities.dp(6));
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 f18ed80fe..61a170e7d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java
@@ -10,14 +10,22 @@ package org.telegram.ui.Cells;
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
+import android.graphics.drawable.Drawable;
+import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
+import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.core.content.ContextCompat;
+
import org.telegram.messenger.AndroidUtilities;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
@@ -29,6 +37,9 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
+import org.telegram.ui.Components.CombinedDrawable;
+import org.telegram.ui.Components.DotDividerSpan;
+import org.telegram.ui.Components.FlickerLoadingView;
import org.telegram.ui.Components.LayoutHelper;
import java.util.Locale;
@@ -42,13 +53,16 @@ public class SessionCell extends FrameLayout {
private BackupImageView imageView;
private AvatarDrawable avatarDrawable;
private boolean needDivider;
+ private boolean showStub;
+ FlickerLoadingView globalGradient;
+ LinearLayout linearLayout;
private int currentAccount = UserConfig.selectedAccount;
public SessionCell(Context context, int type) {
super(context);
- LinearLayout linearLayout = new LinearLayout(context);
+ linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setWeightSum(1);
@@ -57,14 +71,18 @@ public class SessionCell extends FrameLayout {
avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(10));
-
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(10));
addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 21), 13, (LocaleController.isRTL ? 21 : 0), 0));
} else {
- addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 21), 11, (LocaleController.isRTL ? 21 : 15), 0));
+ imageView = new BackupImageView(context);
+ imageView.setRoundRadius(AndroidUtilities.dp(10));
+ addView(imageView, LayoutHelper.createFrame(42, 42, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 16), 13, (LocaleController.isRTL ? 16 : 0), 0));
+
+ addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 72), 11, (LocaleController.isRTL ? 72 : 15), 0));
}
+
nameTextView = new TextView(context);
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@@ -95,7 +113,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, 21, 36, 21, 0));
+ 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));
detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
@@ -105,7 +123,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, 21, 59, 21, 0));
+ 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));
}
@Override
@@ -118,41 +136,17 @@ public class SessionCell extends FrameLayout {
if (object instanceof TLRPC.TL_authorization) {
TLRPC.TL_authorization session = (TLRPC.TL_authorization) object;
- nameTextView.setText(String.format(Locale.US, "%s %s", session.app_name, session.app_version));
- if ((session.flags & 1) != 0) {
- setTag(Theme.key_windowBackgroundWhiteValueText);
- onlineTextView.setText(LocaleController.getString("Online", R.string.Online));
- onlineTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
- } else {
- setTag(Theme.key_windowBackgroundWhiteGrayText3);
- onlineTextView.setText(LocaleController.stringForMessageListDate(session.date_active));
- onlineTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
- }
+
+
+ imageView.setImageDrawable(createDrawable(session));
+ // nameTextView.setText(String.format(Locale.US, "%s %s", session.app_name, session.app_version));
+
StringBuilder stringBuilder = new StringBuilder();
- if (session.ip.length() != 0) {
- stringBuilder.append(session.ip);
- }
- if (session.country.length() != 0) {
- if (stringBuilder.length() != 0) {
- stringBuilder.append(" ");
- }
- stringBuilder.append("— ");
- stringBuilder.append(session.country);
- }
- detailExTextView.setText(stringBuilder);
-
- stringBuilder = new StringBuilder();
if (session.device_model.length() != 0) {
- if (stringBuilder.length() != 0) {
- stringBuilder.append(", ");
- }
stringBuilder.append(session.device_model);
}
- if (session.system_version.length() != 0 || session.platform.length() != 0) {
- if (stringBuilder.length() != 0) {
- stringBuilder.append(", ");
- }
+ if (stringBuilder.length() == 0) {
if (session.platform.length() != 0) {
stringBuilder.append(session.platform);
}
@@ -163,17 +157,33 @@ public class SessionCell extends FrameLayout {
stringBuilder.append(session.system_version);
}
}
+ nameTextView.setText(stringBuilder);
- if (!session.official_app) {
- if (stringBuilder.length() != 0) {
- stringBuilder.append(", ");
- }
- stringBuilder.append(LocaleController.getString("UnofficialApp", R.string.UnofficialApp));
- stringBuilder.append(" (ID: ");
- stringBuilder.append(session.api_id);
- stringBuilder.append(")");
+ String timeText;
+ if ((session.flags & 1) != 0) {
+ setTag(Theme.key_windowBackgroundWhiteValueText);
+ timeText = LocaleController.getString("Online", R.string.Online);
+ } else {
+ setTag(Theme.key_windowBackgroundWhiteGrayText3);
+ timeText = LocaleController.stringForMessageListDate(session.date_active);
}
+ SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
+ if (session.country.length() != 0) {
+ spannableStringBuilder.append(session.country);
+ }
+ if (spannableStringBuilder.length() != 0) {
+ DotDividerSpan dotDividerSpan = new DotDividerSpan();
+ dotDividerSpan.setTopPadding(AndroidUtilities.dp(1.5f));
+ spannableStringBuilder.append(" . ").setSpan(dotDividerSpan, spannableStringBuilder.length() - 2, spannableStringBuilder.length() - 1, 0);
+ }
+ spannableStringBuilder.append(timeText);
+ detailExTextView.setText(spannableStringBuilder);
+
+ stringBuilder = new StringBuilder();
+ stringBuilder.append(session.app_name);
+ stringBuilder.append(" ").append(session.app_version);
+
detailTextView.setText(stringBuilder);
} else if (object instanceof TLRPC.TL_webAuthorization) {
TLRPC.TL_webAuthorization session = (TLRPC.TL_webAuthorization) object;
@@ -224,12 +234,111 @@ public class SessionCell extends FrameLayout {
detailTextView.setText(stringBuilder);
}
+
+ if (showStub) {
+ showStub = false;
+ invalidate();
+ }
+ }
+
+ public static Drawable createDrawable(TLRPC.TL_authorization session) {
+ String platform = session.platform.toLowerCase();
+ if (platform.isEmpty()) {
+ platform = session.system_version.toLowerCase();
+ }
+ String deviceModel = session.device_model.toLowerCase();
+ int iconId;
+ String colorKey;
+ if (deviceModel.contains("safari")) {
+ iconId = R.drawable.device_web_safari;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (deviceModel.contains("edge")) {
+ iconId = R.drawable.device_web_edge;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (deviceModel.contains("chrome")) {
+ iconId = R.drawable.device_web_chrome;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (deviceModel.contains("opera")) {
+ iconId = R.drawable.device_web_opera;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (deviceModel.contains("firefox")) {
+ iconId = R.drawable.device_web_firefox;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (deviceModel.contains("vivaldi")) {
+ iconId = R.drawable.device_web_other;
+ colorKey = Theme.key_avatar_backgroundPink;
+ } else if (platform.contains("ios")) {
+ iconId = deviceModel.contains("ipad") ? R.drawable.device_tablet_ios : R.drawable.device_phone_ios;
+ colorKey = Theme.key_avatar_backgroundBlue;
+ } else if (platform.contains("windows")) {
+ iconId = R.drawable.device_desktop_win;
+ colorKey = Theme.key_avatar_backgroundCyan;
+ } else if (platform.contains("macos")) {
+ iconId = R.drawable.device_desktop_osx;
+ colorKey = Theme.key_avatar_backgroundCyan;
+ } else if (platform.contains("android")) {
+ iconId = deviceModel.contains("tab") ? R.drawable.device_tablet_android : R.drawable.device_phone_android;
+ colorKey = Theme.key_avatar_backgroundGreen;
+ } else {
+ if (session.app_name.toLowerCase().contains("desktop")) {
+ iconId = R.drawable.device_desktop_other;
+ colorKey = Theme.key_avatar_backgroundCyan;
+ } else {
+ iconId = R.drawable.device_web_other;
+ colorKey = Theme.key_avatar_backgroundPink;
+ }
+ }
+ Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, iconId).mutate();
+ iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_text), PorterDuff.Mode.SRC_IN));
+ CombinedDrawable combinedDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(42), Theme.getColor(colorKey)), iconDrawable);
+ return combinedDrawable;
}
@Override
protected void onDraw(Canvas canvas) {
+ if (showStub && globalGradient != null) {
+ globalGradient.updateColors();
+ globalGradient.updateGradient();
+ if (getParent() != null) {
+ View parent = (View) getParent();
+ globalGradient.setParentSize(parent.getMeasuredWidth(), parent.getMeasuredHeight(), -getX());
+ }
+ float y = linearLayout.getTop() + nameTextView.getTop() + AndroidUtilities.dp(12);
+ float x = linearLayout.getX();
+
+ AndroidUtilities.rectTmp.set(x, y - AndroidUtilities.dp(4), x + getMeasuredWidth() * 0.2f, y + AndroidUtilities.dp(4));
+ canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(4), AndroidUtilities.dp(4), globalGradient.getPaint());
+
+ y = linearLayout.getTop() + detailTextView.getTop() - AndroidUtilities.dp(1);
+ x = linearLayout.getX();
+
+ AndroidUtilities.rectTmp.set(x, y - AndroidUtilities.dp(4), x + getMeasuredWidth() * 0.4f, y + AndroidUtilities.dp(4));
+ canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(4), AndroidUtilities.dp(4), globalGradient.getPaint());
+
+ y = linearLayout.getTop() + detailExTextView.getTop() - AndroidUtilities.dp(1);
+ x = linearLayout.getX();
+
+ AndroidUtilities.rectTmp.set(x, y - AndroidUtilities.dp(4), x + getMeasuredWidth() * 0.3f, y + AndroidUtilities.dp(4));
+ canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(4), AndroidUtilities.dp(4), globalGradient.getPaint());
+ invalidate();
+ }
if (needDivider) {
canvas.drawLine(LocaleController.isRTL ? 0 : AndroidUtilities.dp(20), getMeasuredHeight() - 1, getMeasuredWidth() - (LocaleController.isRTL ? AndroidUtilities.dp(20) : 0), getMeasuredHeight() - 1, Theme.dividerPaint);
}
}
+
+ public void showStub(FlickerLoadingView globalGradient) {
+ this.globalGradient = globalGradient;
+ showStub = true;
+
+ Drawable iconDrawable = ContextCompat.getDrawable(ApplicationLoader.applicationContext, AndroidUtilities.isTablet() ? R.drawable.device_tablet_android : R.drawable.device_phone_android).mutate();
+ iconDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_avatar_text), PorterDuff.Mode.SRC_IN));
+ CombinedDrawable combinedDrawable = new CombinedDrawable(Theme.createCircleDrawable(AndroidUtilities.dp(42), Theme.getColor(Theme.key_avatar_backgroundGreen)), iconDrawable);
+ imageView.setImageDrawable(combinedDrawable);
+ invalidate();
+ }
+
+ public boolean isStub() {
+ return showStub;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckBoxCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckBoxCell.java
index 8f3f0f22b..257e2b7c0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckBoxCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckBoxCell.java
@@ -30,12 +30,17 @@ public class TextCheckBoxCell extends FrameLayout {
private boolean needDivider;
public TextCheckBoxCell(Context context) {
- this(context, false);
+ this(context, false, false);
}
- public TextCheckBoxCell(Context context, boolean dialog) {
+ public TextCheckBoxCell(Context context, boolean dialog, boolean revereLayout) {
super(context);
+ boolean isRtl = LocaleController.isRTL;
+ if (revereLayout) {
+ isRtl = !isRtl;
+ }
+
textView = new TextView(context);
textView.setTextColor(Theme.getColor(dialog ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@@ -44,14 +49,15 @@ public class TextCheckBoxCell extends FrameLayout {
textView.setSingleLine(true);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
- addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 66 : 21, 0, LocaleController.isRTL ? 21 : 66, 0));
+
+ addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (isRtl ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, isRtl ? 66 : 21, 0, isRtl ? 21 : 66, 0));
checkBox = new CheckBoxSquare(context, dialog);
checkBox.setDuplicateParentStateEnabled(false);
checkBox.setFocusable(false);
checkBox.setFocusableInTouchMode(false);
checkBox.setClickable(false);
- addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0));
+ addView(checkBox, LayoutHelper.createFrame(18, 18, (isRtl ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0));
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
index b3ac23512..60f0d1b00 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
@@ -153,7 +153,7 @@ public class ChangePhoneActivity extends BaseFragment {
@Override
public void onItemClick(int id) {
if (id == done_button) {
- views[currentViewNum].onNextPressed();
+ views[currentViewNum].onNextPressed(null);
} else if (id == -1) {
finishFragment();
}
@@ -211,7 +211,7 @@ public class ChangePhoneActivity extends BaseFragment {
if (requestCode == 6) {
checkPermissions = false;
if (currentViewNum == 0) {
- views[currentViewNum].onNextPressed();
+ views[currentViewNum].onNextPressed(null);
}
}
}
@@ -594,7 +594,7 @@ public class ChangePhoneActivity extends BaseFragment {
});
phoneField.setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_NEXT) {
- onNextPressed();
+ onNextPressed(null);
return true;
}
return false;
@@ -712,7 +712,7 @@ public class ChangePhoneActivity extends BaseFragment {
}
@Override
- public void onNextPressed() {
+ public void onNextPressed(String code) {
if (getParentActivity() == null || nextPressed) {
return;
}
@@ -985,7 +985,7 @@ public class ChangePhoneActivity extends BaseFragment {
Intent mailer = new Intent(Intent.ACTION_SENDTO);
mailer.setData(Uri.parse("mailto:"));
- mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"reports@stel.com"});
+ mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@telegram.org"});
mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + emailPhone);
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);
getContext().startActivity(Intent.createChooser(mailer, "Send email..."));
@@ -1178,7 +1178,7 @@ public class ChangePhoneActivity extends BaseFragment {
codeField[num + 1].requestFocus();
}
if ((num == length - 1 || num == length - 2 && len >= 2) && getCode().length() == length) {
- onNextPressed();
+ onNextPressed(null);
}
}
}
@@ -1194,7 +1194,7 @@ public class ChangePhoneActivity extends BaseFragment {
});
codeField[a].setOnEditorActionListener((textView, i, keyEvent) -> {
if (i == EditorInfo.IME_ACTION_NEXT) {
- onNextPressed();
+ onNextPressed(null);
return true;
}
return false;
@@ -1398,11 +1398,11 @@ public class ChangePhoneActivity extends BaseFragment {
}
@Override
- public void onNextPressed() {
+ public void onNextPressed(String code) {
if (nextPressed) {
return;
}
- String code = getCode();
+ code = getCode();
if (TextUtils.isEmpty(code)) {
AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
return;
@@ -1550,7 +1550,7 @@ public class ChangePhoneActivity extends BaseFragment {
}
if (id == NotificationCenter.didReceiveSmsCode) {
codeField[0].setText("" + args[0]);
- onNextPressed();
+ onNextPressed(null);
} else if (id == NotificationCenter.didReceiveCall) {
String num = "" + args[0];
if (!AndroidUtilities.checkPhonePattern(pattern, num)) {
@@ -1559,7 +1559,7 @@ public class ChangePhoneActivity extends BaseFragment {
ignoreOnTextChange = true;
codeField[0].setText(num);
ignoreOnTextChange = false;
- onNextPressed();
+ onNextPressed(null);
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
index 82c7b4d3d..892bc3555 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
@@ -60,6 +60,7 @@ import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
+import android.util.Log;
import android.util.Property;
import android.util.SparseArray;
import android.util.SparseIntArray;
@@ -98,7 +99,6 @@ import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
-import com.google.android.exoplayer2.util.Log;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
@@ -220,6 +220,7 @@ import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.ReportAlert;
import org.telegram.ui.Components.SearchCounterView;
import org.telegram.ui.Components.ShareAlert;
+import org.telegram.ui.Components.SharedMediaLayout;
import org.telegram.ui.Components.Size;
import org.telegram.ui.Components.SizeNotifierFrameLayout;
import org.telegram.ui.Components.StickersAlert;
@@ -265,7 +266,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private ArrayList chatMessageCellsCache = new ArrayList<>();
- private HashMap alredyPlayedStickers = new HashMap<>();
+ private HashMap alreadyPlayedStickers = new HashMap<>();
private Dialog closeChatDialog;
private boolean showCloseChatDialogLater;
@@ -342,6 +343,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean addToContactsButtonArchive;
private TextView reportSpamButton;
private ImageView closeReportSpam;
+ private TextView chatWithAdminTextView;
private FragmentContextView fragmentContextView;
private FragmentContextView fragmentLocationContextView;
private View replyLineView;
@@ -351,6 +353,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private HintView searchAsListHint;
private HintView scheduledOrNoSoundHint;
private boolean searchAsListHintShown;
+ private HintView fwdRestrictedTopHint;
+ private HintView fwdRestrictedBottomHint;
private HintView slowModeHint;
private HintView pollHintView;
private HintView timerHintView;
@@ -538,7 +542,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean clearingHistory;
public boolean openAnimationEnded;
- private boolean fragmentOpened;
+ public boolean fragmentOpened;
private long openAnimationStartTime;
private boolean scrollToTopOnResume;
@@ -592,6 +596,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean showScrollToMessageError;
private int startLoadFromMessageId;
+ private int startLoadFromDate;
private int startLoadFromMessageIdSaved;
private int startLoadFromMessageOffset = Integer.MAX_VALUE;
private int startFromVideoTimestamp = -1;
@@ -752,6 +757,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private ThemeDelegate themeDelegate;
private ChatActivityMemberRequestsDelegate pendingRequestsDelegate;
+ private TLRPC.TL_channels_sendAsPeers sendAsPeersObj;
+
private final static int[] allowedNotificationsDuringChatListAnimations = new int[]{
NotificationCenter.messagesRead,
NotificationCenter.threadMessagesRead,
@@ -764,6 +771,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.updateMentionsCount,
NotificationCenter.didUpdateConnectionState,
NotificationCenter.updateInterfaces,
+ NotificationCenter.updateDefaultSendAsPeer,
NotificationCenter.closeChats,
NotificationCenter.chatInfoCantLoad,
NotificationCenter.userInfoDidLoad,
@@ -804,6 +812,37 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private PinchToZoomHelper pinchToZoomHelper;
private EmojiAnimationsOverlay emojiAnimationsOverlay;
+ public void deleteHistory(int dateSelectedStart, int dateSelectedEnd, boolean forAll) {
+ chatAdapter.frozenMessages.clear();
+ for (int i = 0; i < messages.size(); i++) {
+ MessageObject messageObject = messages.get(i);
+ if (messageObject.messageOwner.date <= dateSelectedStart || messageObject.messageOwner.date >= dateSelectedEnd) {
+ chatAdapter.frozenMessages.add(messageObject);
+ }
+ }
+ if (chatListView != null) {
+ chatListView.setEmptyView(null);
+ }
+ if (chatAdapter.frozenMessages.isEmpty()) {
+ showProgressView(true);
+ }
+ chatAdapter.isFrozen = true;
+ chatAdapter.notifyDataSetChanged(true);
+ getUndoView().showWithAction(dialog_id, UndoView.ACTION_CLEAR_DATES, () -> {
+ getMessagesController().deleteMessagesRange(dialog_id, ChatObject.isChannel(currentChat) ? dialog_id : 0, dateSelectedStart, dateSelectedEnd, forAll, () -> {
+ chatAdapter.frozenMessages.clear();
+ chatAdapter.isFrozen = false;
+ chatAdapter.notifyDataSetChanged(true);
+ showProgressView(false);
+ });
+ }, () -> {
+ chatAdapter.frozenMessages.clear();
+ chatAdapter.isFrozen = false;
+ chatAdapter.notifyDataSetChanged(true);
+ showProgressView(false);
+ });
+ }
+
private interface ChatActivityDelegate {
default void openReplyMessage(int mid) {
@@ -1151,7 +1190,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
RecyclerListView.OnItemLongClickListenerExtended onItemLongClickListener = new RecyclerListView.OnItemLongClickListenerExtended() {
@Override
public boolean onItemClick(View view, int position, float x, float y) {
- if (textSelectionHelper.isTryingSelect() || textSelectionHelper.isSelectionMode()) {
+ if (textSelectionHelper.isTryingSelect() || textSelectionHelper.isSelectionMode() || inPreviewMode) {
return false;
}
wasManualScroll = true;
@@ -1283,7 +1322,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
RecyclerListView.OnItemClickListenerExtended onItemClickListener = new RecyclerListView.OnItemClickListenerExtended() {
@Override
public void onItemClick(View view, int position, float x, float y) {
+ if (inPreviewMode) {
+ return;
+ }
wasManualScroll = true;
+ if (view instanceof ChatActionCell && ((ChatActionCell) view).getMessageObject().isDateObject) {
+ Bundle bundle = new Bundle();
+ int date = ((ChatActionCell) view).getMessageObject().messageOwner.date;
+ bundle.putLong("dialog_id", dialog_id);
+ bundle.putInt("type", CalendarActivity.TYPE_CHAT_ACTIVITY);
+ CalendarActivity calendarActivity = new CalendarActivity(bundle, SharedMediaLayout.FILTER_PHOTOS_AND_VIDEOS, date);
+ presentFragment(calendarActivity);
+ return;
+ }
if (actionBar.isActionModeShowed() || reportType >= 0) {
boolean outside = false;
if (view instanceof ChatMessageCell) {
@@ -1337,6 +1388,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
inlineReturn = arguments.getLong("inline_return", 0);
String inlineQuery = arguments.getString("inline_query");
startLoadFromMessageId = arguments.getInt("message_id", 0);
+ startLoadFromDate = arguments.getInt("start_from_date", 0);
startFromVideoTimestamp = arguments.getInt("video_timestamp", -1);
threadUnreadMessagesCount = arguments.getInt("unread_count", 0);
if (startFromVideoTimestamp >= 0) {
@@ -1489,12 +1541,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.invalidateMotionBackground);
getNotificationCenter().addObserver(this, NotificationCenter.didUpdateConnectionState);
getNotificationCenter().addObserver(this, NotificationCenter.updateInterfaces);
+ getNotificationCenter().addObserver(this, NotificationCenter.updateDefaultSendAsPeer);
if (chatMode != MODE_PINNED) {
getNotificationCenter().addObserver(this, NotificationCenter.didReceiveNewMessages);
}
if (chatMode == 0) {
getNotificationCenter().addObserver(this, NotificationCenter.didLoadSponsoredMessages);
}
+ getNotificationCenter().addObserver(this, NotificationCenter.didLoadSendAsPeers);
getNotificationCenter().addObserver(this, NotificationCenter.closeChats);
getNotificationCenter().addObserver(this, NotificationCenter.messagesDeleted);
getNotificationCenter().addObserver(this, NotificationCenter.historyCleared);
@@ -1612,7 +1666,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (chatMode != MODE_PINNED && !forceHistoryEmpty) {
waitingForLoad.add(lastLoadIndex);
- if (startLoadFromMessageId != 0 && (!isThreadChat() || startLoadFromMessageId == highlightMessageId)) {
+ if (startLoadFromDate != 0) {
+ getMessagesController().loadMessages(dialog_id, mergeDialogId, false, 30, 0, startLoadFromDate, true, 0, classGuid, 4, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++);
+ } else if (startLoadFromMessageId != 0 && (!isThreadChat() || startLoadFromMessageId == highlightMessageId)) {
startLoadFromMessageIdSaved = startLoadFromMessageId;
if (migrated_to != 0) {
mergeDialogId = migrated_to;
@@ -1730,6 +1786,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
+ /**
+ * Gets same chats index difference
+ * [..., other_same, this, ...] => -1
+ * [..., this, other_same, ...] => 1
+ * [..., this, ...] => 0
+ * @return Other same chats index difference
+ */
+ public int getOtherSameChatsDiff() {
+ int cur = parentLayout.fragmentsStack.indexOf(this);
+ 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);
+ if (fragment != this && fragment instanceof ChatActivity) {
+ ChatActivity chatActivity = (ChatActivity) fragment;
+ if (chatActivity.dialog_id == dialog_id) {
+ i = a;
+ break;
+ }
+ }
+ }
+ return i - cur;
+ }
+
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
@@ -1760,6 +1841,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.invalidateMotionBackground);
getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateConnectionState);
getNotificationCenter().removeObserver(this, NotificationCenter.updateInterfaces);
+ getNotificationCenter().removeObserver(this, NotificationCenter.updateDefaultSendAsPeer);
getNotificationCenter().removeObserver(this, NotificationCenter.didReceiveNewMessages);
getNotificationCenter().removeObserver(this, NotificationCenter.closeChats);
getNotificationCenter().removeObserver(this, NotificationCenter.messagesRead);
@@ -1819,6 +1901,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
getNotificationCenter().removeObserver(this, NotificationCenter.diceStickersDidLoad);
getNotificationCenter().removeObserver(this, NotificationCenter.dialogDeleted);
getNotificationCenter().removeObserver(this, NotificationCenter.didLoadSponsoredMessages);
+ getNotificationCenter().removeObserver(this, NotificationCenter.didLoadSendAsPeers);
if (currentEncryptedChat != null) {
getNotificationCenter().removeObserver(this, NotificationCenter.didVerifyMessagesStickers);
}
@@ -1830,9 +1913,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (currentUser != null) {
MediaController.getInstance().stopMediaObserver();
}
- if (currentEncryptedChat != null) {
+
+ if (getOtherSameChatsDiff() == 0) {
try {
- if (Build.VERSION.SDK_INT >= 23 && (SharedConfig.passcodeHash.length() == 0 || SharedConfig.allowScreenCapture)) {
+ if (Build.VERSION.SDK_INT >= 23) {
AndroidUtilities.setFlagSecure(this, false);
}
} catch (Throwable e) {
@@ -2004,7 +2088,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
createDeleteMessagesAlert(null, null);
} else if (id == forward) {
- openForward();
+ openForward(true);
} else if (id == save_to) {
ArrayList messageObjects = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
@@ -2217,6 +2301,53 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionBar.setTitle(LocaleController.getString("ReportChatPornography", R.string.ReportChatPornography));
}
actionBar.setSubtitle(LocaleController.getString("ReportSelectMessages", R.string.ReportSelectMessages));
+ } else if (startLoadFromDate != 0) {
+ final int date = startLoadFromDate;
+ actionBar.setOnClickListener((v) -> {
+ jumpToDate(date);
+ });
+ actionBar.setTitle(LocaleController.formatDateChat(startLoadFromDate, false));
+ actionBar.setSubtitle(LocaleController.getString("Loading", R.string.Loading));
+
+ TLRPC.TL_messages_getHistory gh1 = new TLRPC.TL_messages_getHistory();
+ gh1.peer = getMessagesController().getInputPeer(dialog_id);
+ gh1.offset_date = startLoadFromDate;
+ gh1.limit = 1;
+ gh1.add_offset = -1;
+
+ int req = getConnectionsManager().sendRequest(gh1, (response, error) -> {
+ if (response instanceof TLRPC.messages_Messages) {
+ List l = ((TLRPC.messages_Messages) response).messages;
+ if (!l.isEmpty()) {
+
+ TLRPC.TL_messages_getHistory gh2 = new TLRPC.TL_messages_getHistory();
+ gh2.peer = getMessagesController().getInputPeer(dialog_id);
+ gh2.offset_date = startLoadFromDate + 60 * 60 * 24;
+ gh2.limit = 1;
+
+ getConnectionsManager().sendRequest(gh2, (response1, error1) -> {
+ if (response1 instanceof TLRPC.messages_Messages) {
+ List l2 = ((TLRPC.messages_Messages) response1).messages;
+ int count = 0;
+ if (!l2.isEmpty()) {
+ count = ((TLRPC.messages_Messages) response).offset_id_offset - ((TLRPC.messages_Messages) response1).offset_id_offset;
+ } else {
+ count = ((TLRPC.messages_Messages) response).offset_id_offset;
+ }
+ int finalCount = count;
+ AndroidUtilities.runOnUIThread(() -> {
+ if (finalCount != 0) {
+ AndroidUtilities.runOnUIThread(() -> actionBar.setSubtitle(LocaleController.formatPluralString("messages", finalCount)));
+ } else {
+ actionBar.setSubtitle(LocaleController.getString("NoMessagesForThisDay", R.string.NoMessagesForThisDay));
+ }
+ });
+ }
+ });
+ }
+ }
+ });
+ getConnectionsManager().bindRequestToGuid(req, classGuid);
} else {
actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, !inPreviewMode ? 56 : (chatMode == MODE_PINNED ? 10 : 0), 0, 40, 0));
}
@@ -2257,6 +2388,7 @@ 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) {
@@ -2273,6 +2405,7 @@ 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) {
@@ -2538,7 +2671,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionModeViews.add(actionMode.addItemWithWidth(delete, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete)));
}
actionMode.getItem(edit).setVisibility(canEditMessagesCount == 1 && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.VISIBLE : View.GONE);
- actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
+ actionMode.getItem(copy).setVisibility(!getMessagesController().isChatNoForwards(currentChat) && selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.getItem(star).setVisibility(selectedMessagesCanStarIds[0].size() + selectedMessagesCanStarIds[1].size() != 0 ? View.VISIBLE : View.GONE);
actionMode.getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
checkActionBarMenu(false);
@@ -2577,6 +2710,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
+ @Override
+ protected void onTransitionEnd() {
+ if (chatActivityEnterView != null) {
+ chatActivityEnterView.onAdjustPanTransitionEnd();
+ }
+ }
+
@Override
protected void onPanTranslationUpdate(float y, float progress, boolean keyboardVisible) {
if (getParentLayout() != null && getParentLayout().isPreviewOpenAnimationInProgress()) {
@@ -3804,7 +3944,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (e != null) {
wasManualScroll = true;
}
- if (e != null && e.getAction() == MotionEvent.ACTION_DOWN && !startedTrackingSlidingView && !maybeStartTrackingSlidingView && slidingView == null) {
+ if (e != null && e.getAction() == MotionEvent.ACTION_DOWN && !startedTrackingSlidingView && !maybeStartTrackingSlidingView && slidingView == null && !inPreviewMode) {
View view = getPressedChildView();
if (view instanceof ChatMessageCell) {
if (slidingView != null) {
@@ -3909,7 +4049,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (pullingDownDrawable != null && pullingDownDrawable.emptyStub && (System.currentTimeMillis() - pullingDownDrawable.lastShowingReleaseTime) < 500 && pullingDownDrawable.animateSwipeToRelease) {
AnimatorSet animatorSet = new AnimatorSet();
pullingDownBackAnimator = animatorSet;
- pullingDownDrawable.showBottomPanel(false);
+ if (pullingDownDrawable != null) {
+ pullingDownDrawable.showBottomPanel(false);
+ }
ValueAnimator animator = ValueAnimator.ofFloat(pullingDownOffset, AndroidUtilities.dp(111));
animator.addUpdateListener(valueAnimator -> {
pullingDownOffset = (float) valueAnimator.getAnimatedValue();
@@ -3932,7 +4074,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
ValueAnimator animator = ValueAnimator.ofFloat(pullingDownOffset, 0);
pullingDownBackAnimator = animator;
- pullingDownDrawable.showBottomPanel(false);
+ if (pullingDownDrawable != null) {
+ pullingDownDrawable.showBottomPanel(false);
+ }
animator.addUpdateListener(valueAnimator -> {
pullingDownOffset = (float) valueAnimator.getAnimatedValue();
chatListView.invalidate();
@@ -6507,17 +6651,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
mentiondownButton.addView(mentiondownButtonCounter, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 23, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
mentiondownButton.setContentDescription(LocaleController.getString("AccDescrMentionDown", R.string.AccDescrMentionDown));
- contentView.addView(fragmentLocationContextView = new FragmentContextView(context, this, true, themeDelegate), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
- contentView.addView(fragmentContextView = new FragmentContextView(context, this, false, themeDelegate) {
- @Override
- protected void playbackSpeedChanged(float value) {
- if (Math.abs(value - 1.0f) < 0.001f || Math.abs(value - 1.8f) < 0.001f) {
- undoView.showWithAction(0, Math.abs(value - 1.0f) > 0.001f ? UndoView.ACTION_PLAYBACK_SPEED_ENABLED : UndoView.ACTION_PLAYBACK_SPEED_DISABLED, value, null, null);
+
+ if (!inMenuMode) {
+ fragmentLocationContextView = new FragmentContextView(context, this, true, themeDelegate);
+ fragmentContextView = new FragmentContextView(context, this, false, themeDelegate) {
+ @Override
+ protected void playbackSpeedChanged(float value) {
+ if (Math.abs(value - 1.0f) < 0.001f || Math.abs(value - 1.8f) < 0.001f) {
+ undoView.showWithAction(0, Math.abs(value - 1.0f) > 0.001f ? UndoView.ACTION_PLAYBACK_SPEED_ENABLED : UndoView.ACTION_PLAYBACK_SPEED_DISABLED, value, null, null);
+ }
}
- }
- }, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
- fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
- fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
+ };
+ contentView.addView(fragmentLocationContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
+ contentView.addView(fragmentContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
+
+ fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
+ fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
+ }
if (chatMode != 0) {
fragmentContextView.setSupportsCalls(false);
@@ -6748,6 +6898,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int lastSize;
+ @Override
+ public int getContentViewHeight() {
+ return contentView.getHeight();
+ }
+
+ @Override
+ public int measureKeyboardHeight() {
+ return contentView.measureKeyboardHeight();
+ }
+
+ @Override
+ public TLRPC.TL_channels_sendAsPeers getSendAsPeers() {
+ return sendAsPeersObj;
+ }
+
@Override
public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
if (chatListItemAnimator != null) {
@@ -6807,6 +6972,7 @@ 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);
}
@@ -6817,6 +6983,7 @@ 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 {
@@ -6878,6 +7045,7 @@ 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) {
@@ -7454,7 +7622,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
AndroidUtilities.hideKeyboard(searchItem.getSearchField());
- showDialog(AlertsCreator.createCalendarPickerDialog(getParentActivity(), 1375315200000L, this::jumpToDate, themeDelegate).create());
+ showDialog(AlertsCreator.createCalendarPickerDialog(getParentActivity(), 1375315200000L, new MessagesStorage.IntCallback() {
+ @Override
+ public void run(int param) {
+ jumpToDate(param);
+ }
+ }, themeDelegate).create());
});
searchCalendarButton.setContentDescription(LocaleController.getString("JumpToDate", R.string.JumpToDate));
@@ -7656,7 +7829,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
image = context.getResources().getDrawable(R.drawable.input_forward).mutate();
image.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarActionModeDefaultIcon), PorterDuff.Mode.MULTIPLY));
forwardButton.setCompoundDrawablesWithIntrinsicBounds(image, null, null, null);
- forwardButton.setOnClickListener(v -> openForward());
+ forwardButton.setOnClickListener(v -> openForward(false));
bottomMessagesActionContainer.addView(forwardButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP));
contentView.addView(searchContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
@@ -7693,7 +7866,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatScrollHelper.setAnimationCallback(chatScrollHelperCallback);
try {
- if (currentEncryptedChat != null && Build.VERSION.SDK_INT >= 23 && (SharedConfig.passcodeHash.length() == 0 || SharedConfig.allowScreenCapture)) {
+ if (currentEncryptedChat != null && Build.VERSION.SDK_INT >= 23 && (SharedConfig.passcodeHash.length() == 0 || SharedConfig.allowScreenCapture) ||
+ getMessagesController().isChatNoForwards(currentChat) && getOtherSameChatsDiff() >= 0) {
AndroidUtilities.setFlagSecure(this, true);
}
} catch (Throwable e) {
@@ -8336,7 +8510,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (progressView == null) {
return;
}
- if (fragmentOpened && BuildVars.DEBUG_VERSION) {
+ if (fragmentOpened) {
if (show == animateTo) {
return;
}
@@ -8697,7 +8871,44 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
contentView.removeView(videoPlayerContainer);
}
- private void openForward() {
+ private void openForward(boolean fromActionBar) {
+ if (getMessagesController().isChatNoForwards(currentChat)) {
+ // We should update text if user changed locale without re-opening chat activity
+ String str = ChatObject.isChannel(currentChat) && !currentChat.megagroup ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) :
+ LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup);
+ if (fromActionBar) {
+ if (fwdRestrictedTopHint == null) {
+ SizeNotifierFrameLayout frameLayout = (SizeNotifierFrameLayout) fragmentView;
+ int index = frameLayout.indexOfChild(chatActivityEnterView);
+ if (index == -1) {
+ return;
+ }
+ fwdRestrictedTopHint = new HintView(getParentActivity(), 7, true);
+ frameLayout.addView(fwdRestrictedTopHint, index + 1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 12, 0, 12, 0));
+ fwdRestrictedTopHint.setAlpha(0.0f);
+ fwdRestrictedTopHint.setVisibility(View.INVISIBLE);
+ }
+
+ fwdRestrictedTopHint.setText(str);
+ fwdRestrictedTopHint.showForView(actionBar.getActionMode().getItem(forward), true);
+ } else {
+ if (fwdRestrictedBottomHint == null) {
+ SizeNotifierFrameLayout frameLayout = (SizeNotifierFrameLayout) fragmentView;
+ int index = frameLayout.indexOfChild(chatActivityEnterView);
+ if (index == -1) {
+ return;
+ }
+ fwdRestrictedBottomHint = new HintView(getParentActivity(), 9);
+ frameLayout.addView(fwdRestrictedBottomHint, index + 1, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 12, 0, 12, 0));
+ fwdRestrictedBottomHint.setAlpha(0.0f);
+ fwdRestrictedBottomHint.setVisibility(View.INVISIBLE);
+ }
+
+ fwdRestrictedBottomHint.setText(str);
+ fwdRestrictedBottomHint.showForView(forwardButton, true);
+ }
+ return;
+ }
int hasPoll = 0;
boolean hasInvoice = false;
for (int a = 0; a < 2; a++) {
@@ -8879,7 +9090,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return groupedMessages;
}
- private void jumpToDate(int date) {
+ public void jumpToDate(int date) {
if (messages.isEmpty()) {
return;
}
@@ -9389,6 +9600,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scheduledOrNoSoundHint.hide();
}
}
+ if (fwdRestrictedBottomHint != null) {
+ fwdRestrictedBottomHint.hide();
+ }
+ if (fwdRestrictedTopHint != null) {
+ fwdRestrictedTopHint.hide();
+ }
if (noSoundHintView != null) {
noSoundHintView.hide();
}
@@ -9598,7 +9815,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void showTextSelectionHint(MessageObject messageObject) {
- if (getParentActivity() == null) {
+ if (getParentActivity() == null || getMessagesController().isChatNoForwards(messageObject.getChatId())) {
return;
}
CharSequence text;
@@ -9990,7 +10207,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void checkScrollForLoad(boolean scroll) {
- if (chatLayoutManager == null || paused) {
+ if (chatLayoutManager == null || paused || chatAdapter.isFrozen) {
return;
}
int firstVisibleItem = chatLayoutManager.findFirstVisibleItemPosition();
@@ -10563,7 +10780,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && messageObjectToReply.isForwardedChannelPost()) {
chat = getMessagesController().getChat(messageObjectToReply.messageOwner.fwd_from.from_id.channel_id);
} else {
- chat = getMessagesController().getChat(messageObjectToReply.messageOwner.peer_id.channel_id);
+ chat = getMessagesController().getChat(-messageObjectToReply.getSenderId());
}
if (chat == null) {
return;
@@ -11335,7 +11552,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
currentPinnedMessageId = findClosest(pinnedMessageIds, forceNextPinnedMessageId != 0 ? forceNextPinnedMessageId : maxVisibleId, currentPinnedMessageIndex);
- if (!loadingPinnedMessagesList && !pinnedEndReached && !pinnedMessageIds.isEmpty() && currentPinnedMessageIndex[0] > pinnedMessageIds.size() - 2) {
+ if (!inMenuMode && !loadingPinnedMessagesList && !pinnedEndReached && !pinnedMessageIds.isEmpty() && currentPinnedMessageIndex[0] > pinnedMessageIds.size() - 2) {
getMediaDataController().loadPinnedMessages(dialog_id, pinnedMessageIds.get(pinnedMessageIds.size() - 1), 0);
loadingPinnedMessagesList = true;
}
@@ -12307,14 +12524,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!messageObject.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat)) {
cantDeleteMessagesCount--;
}
- if (chatMode == MODE_SCHEDULED || !messageObject.canForwardMessage()) {
+ boolean noforwards = getMessagesController().isChatNoForwards(currentChat);
+ if (chatMode == MODE_SCHEDULED || !messageObject.canForwardMessage() || noforwards) {
cantForwardMessagesCount--;
} else {
canForwardMessagesCount--;
}
- if (messageObject.isMusic()) {
+ if (messageObject.isMusic() && !noforwards) {
canSaveMusicCount--;
- } else if (messageObject.isDocument()) {
+ } else if (messageObject.isDocument() && !noforwards) {
canSaveDocumentsCount--;
} else {
cantSaveMessagesCount--;
@@ -12343,14 +12561,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!messageObject.canDeleteMessage(chatMode == MODE_SCHEDULED, currentChat)) {
cantDeleteMessagesCount++;
}
- if (chatMode == MODE_SCHEDULED || !messageObject.canForwardMessage()) {
+ boolean noforwards = getMessagesController().isChatNoForwards(currentChat);
+ if (chatMode == MODE_SCHEDULED || !messageObject.canForwardMessage() || noforwards) {
cantForwardMessagesCount++;
} else {
canForwardMessagesCount++;
}
- if (messageObject.isMusic()) {
+ if (messageObject.isMusic() && !noforwards) {
canSaveMusicCount++;
- } else if (messageObject.isDocument()) {
+ } else if (messageObject.isDocument() && !noforwards) {
canSaveDocumentsCount++;
} else {
cantSaveMessagesCount++;
@@ -12377,15 +12596,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ActionBarMenuItem editItem = actionBar.createActionMode().getItem(edit);
ActionBarMenuItem forwardItem = actionBar.createActionMode().getItem(forward);
+ boolean noforwards = getMessagesController().isChatNoForwards(currentChat);
if (prevCantForwardCount == 0 && cantForwardMessagesCount != 0 || prevCantForwardCount != 0 && cantForwardMessagesCount == 0) {
forwardButtonAnimation = new AnimatorSet();
ArrayList animators = new ArrayList<>();
if (forwardItem != null) {
- forwardItem.setEnabled(cantForwardMessagesCount == 0);
+ forwardItem.setEnabled(cantForwardMessagesCount == 0 || noforwards);
animators.add(ObjectAnimator.ofFloat(forwardItem, View.ALPHA, cantForwardMessagesCount == 0 ? 1.0f : 0.5f));
+
+ if (noforwards) {
+ if (forwardItem.getBackground() != null) forwardItem.setBackground(null);
+ } else if (forwardItem.getBackground() == null) {
+ forwardItem.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 5));
+ }
}
if (forwardButton != null) {
- forwardButton.setEnabled(cantForwardMessagesCount == 0);
+ forwardButton.setEnabled(cantForwardMessagesCount == 0 || noforwards);
+ if (noforwards) {
+ if (forwardButton.getBackground() != null) forwardButton.setBackground(null);
+ } else if (forwardButton.getBackground() == null) {
+ forwardButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
+ }
animators.add(ObjectAnimator.ofFloat(forwardButton, View.ALPHA, cantForwardMessagesCount == 0 ? 1.0f : 0.5f));
}
forwardButtonAnimation.playTogether(animators);
@@ -12399,11 +12630,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
forwardButtonAnimation.start();
} else {
if (forwardItem != null) {
- forwardItem.setEnabled(cantForwardMessagesCount == 0);
+ forwardItem.setEnabled(cantForwardMessagesCount == 0 || noforwards);
forwardItem.setAlpha(cantForwardMessagesCount == 0 ? 1.0f : 0.5f);
+ if (noforwards) {
+ if (forwardItem.getBackground() != null) forwardButton.setBackground(null);
+ } else if (forwardItem.getBackground() == null) {
+ forwardItem.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
+ }
}
if (forwardButton != null) {
- forwardButton.setEnabled(cantForwardMessagesCount == 0);
+ forwardButton.setEnabled(cantForwardMessagesCount == 0 || noforwards);
+ if (noforwards) {
+ if (forwardButton.getBackground() != null) forwardButton.setBackground(null);
+ } else if (forwardButton.getBackground() == null) {
+ forwardButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_actionBarActionModeDefaultSelector), 3));
+ }
forwardButton.setAlpha(cantForwardMessagesCount == 0 ? 1.0f : 0.5f);
}
}
@@ -12414,7 +12655,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int copyVisible = copyItem.getVisibility();
int starVisible = starItem.getVisibility();
- copyItem.setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
+ copyItem.setVisibility(!noforwards && selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE);
starItem.setVisibility(getMediaDataController().canAddStickerToFavorites() && (selectedMessagesCanStarIds[0].size() + selectedMessagesCanStarIds[1].size()) == selectedCount ? View.VISIBLE : View.GONE);
int newCopyVisible = copyItem.getVisibility();
int newStarVisible = starItem.getVisibility();
@@ -13089,15 +13330,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
forwardEndReached[0] = forwardEndReached[1] = true;
firstLoading = false;
showProgressView(false);
- if (!fragmentOpened) {
- chatListView.setAnimateEmptyView(false, 1);
- chatListView.setEmptyView(emptyViewContainer);
- chatListView.setAnimateEmptyView(true, 1);
- } else {
- chatListView.setEmptyView(emptyViewContainer);
+ if (chatListView != null) {
+ if (!fragmentOpened) {
+ chatListView.setAnimateEmptyView(false, 1);
+ chatListView.setEmptyView(emptyViewContainer);
+ chatListView.setAnimateEmptyView(true, 1);
+ } else {
+ chatListView.setEmptyView(emptyViewContainer);
+ }
+ chatAdapter.notifyDataSetChanged();
}
- chatAdapter.notifyDataSetChanged();
resumeDelayedFragmentAnimation();
MessageObject messageObject = messArr.get(0);
getMessagesController().markDialogAsRead(dialog_id, messageObject.getId(), messageObject.getId(), messageObject.messageOwner.date, false, 0, 0, true, 0);
@@ -13778,6 +14021,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (scrollToMessage != null) {
addSponsoredMessages(!isFirstLoading);
+ loadSendAsPeers();
int yOffset;
boolean bottom = true;
if (startLoadFromMessageOffset != Integer.MAX_VALUE) {
@@ -13925,6 +14169,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (isThreadChat()) {
invalidateMessagesVisiblePart();
}
+ if (startLoadFromDate != 0) {
+ int dateObjectIndex = -1;
+ 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 (dateObjectIndex > 0) {
+ chatLayoutManager.scrollToPositionWithOffset(chatAdapter.messagesStartRow + dateObjectIndex, (int) (AndroidUtilities.dp(4)), false);
+ }
+ }
}
if (messages.isEmpty() && currentEncryptedChat == null && currentUser != null && currentUser.bot && botUser == null) {
botUser = "";
@@ -13950,6 +14206,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
showFloatingDateView(false);
}
addSponsoredMessages(!isFirstLoading);
+ loadSendAsPeers();
checkScrollForLoad(false);
if (postponedScroll) {
@@ -14063,6 +14320,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
avatarContainer.updateOnlineCount();
avatarContainer.updateSubtitle();
}
+ } else if (id == NotificationCenter.updateDefaultSendAsPeer) {
+ long chatId = (long) args[0];
+ if (chatId == dialog_id) {
+ chatActivityEnterView.updateSendAsButton();
+ }
} else if (id == NotificationCenter.updateInterfaces) {
int updateMask = (Integer) args[0];
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
@@ -14094,16 +14356,32 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateSubtitle = true;
}
if ((updateMask & MessagesController.UPDATE_MASK_CHAT) != 0 && currentChat != null) {
+ boolean fwdBefore = getMessagesController().isChatNoForwards(currentChat);
TLRPC.Chat chat = getMessagesController().getChat(currentChat.id);
if (chat == null) {
return;
}
currentChat = chat;
+ boolean fwdChanged = getMessagesController().isChatNoForwards(currentChat) != fwdBefore;
updateSubtitle = !isThreadChat();
updateBottomOverlay();
if (chatActivityEnterView != null) {
chatActivityEnterView.setDialogId(dialog_id, currentAccount);
}
+
+ if (fwdChanged) {
+ try {
+ if (Build.VERSION.SDK_INT >= 23) {
+ if (currentEncryptedChat != null && SharedConfig.passcodeHash.length() == 0) {
+ AndroidUtilities.setFlagSecure(this, true);
+ } else if (getOtherSameChatsDiff() >= 0) {
+ AndroidUtilities.setFlagSecure(this, (getMessagesController().isChatNoForwards(currentChat)));
+ }
+ }
+ } catch (Throwable e) {
+ FileLog.e(e);
+ }
+ }
}
if (avatarContainer != null && updateSubtitle) {
avatarContainer.updateSubtitle(true);
@@ -14134,6 +14412,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
checkWaitingForReplies();
}
+ } else if (id == NotificationCenter.didLoadSendAsPeers) {
+ loadSendAsPeers();
} else if (id == NotificationCenter.didLoadSponsoredMessages) {
addSponsoredMessages(true);
} else if (id == NotificationCenter.closeChats) {
@@ -14179,14 +14459,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Integer count = (Integer) args[2];
obj.messageOwner.replies.replies += count;
if (count > 0) {
- TLRPC.Peer peer;
- if (ChatObject.shouldSendAnonymously(currentChat)) {
- peer = new TLRPC.TL_peerChannel();
- peer.channel_id = currentChat.id;
- } else {
- peer = new TLRPC.TL_peerUser();
- peer.user_id = getUserConfig().getClientUserId();
- }
+ TLRPC.Peer peer = getMessagesController().getPeer(ChatObject.getSendAsPeerId(currentChat, getMessagesController().getChatFull(currentChat.id)));
for (int c = 0, N = obj.messageOwner.replies.recent_repliers.size(); c < N; c++) {
if (MessageObject.getPeerId(obj.messageOwner.replies.recent_repliers.get(c)) == MessageObject.getPeerId(peer)) {
obj.messageOwner.replies.recent_repliers.remove(c);
@@ -14557,6 +14830,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && fragmentContextView != null) {
fragmentContextView.checkCall(openAnimationStartTime == 0 || SystemClock.elapsedRealtime() < openAnimationStartTime + 150);
}
+ if (chatActivityEnterView != null) {
+ chatActivityEnterView.updateSendAsButton();
+ chatActivityEnterView.updateFieldHint(false);
+ }
+ if (chatAdapter != null) {
+ chatAdapter.notifyDataSetChanged();
+ }
if (prevLinkedChatId != chatInfo.linked_chat_id) {
if (prevLinkedChatId != 0) {
TLRPC.Chat chat = getMessagesController().getChat(prevLinkedChatId);
@@ -14586,7 +14866,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
avatarContainer.updateOnlineCount();
avatarContainer.updateSubtitle();
}
- if (!loadingPinnedMessagesList && !pinnedMessageIds.isEmpty() && chatInfo.pinned_msg_id > pinnedMessageIds.get(0)) {
+ if (!inMenuMode && !loadingPinnedMessagesList && !pinnedMessageIds.isEmpty() && chatInfo.pinned_msg_id > pinnedMessageIds.get(0)) {
getMediaDataController().loadPinnedMessages(dialog_id, 0, chatInfo.pinned_msg_id);
loadingPinnedMessagesList = true;
}
@@ -15566,7 +15846,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
getMediaDataController().loadReplyMessagesForMessages(new ArrayList<>(pinnedMessageObjects.values()), dialog_id, false, null);
- if (!loadingPinnedMessagesList && totalPinnedMessagesCount == 0 && !pinnedEndReached) {
+ if (!inMenuMode && !loadingPinnedMessagesList && totalPinnedMessagesCount == 0 && !pinnedEndReached) {
getMediaDataController().loadPinnedMessages(dialog_id, 0, pinnedMessageIds.isEmpty() ? 0 : pinnedMessageIds.get(0));
loadingPinnedMessagesList = true;
}
@@ -15604,7 +15884,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
checkActionBarMenu(false);
- if (!loadingPinnedMessagesList && !pinnedMessageIds.isEmpty() && userInfo.pinned_msg_id > pinnedMessageIds.get(0)) {
+ if (!inMenuMode && !loadingPinnedMessagesList && !pinnedMessageIds.isEmpty() && userInfo.pinned_msg_id > pinnedMessageIds.get(0)) {
getMediaDataController().loadPinnedMessages(dialog_id, 0, userInfo.pinned_msg_id);
loadingPinnedMessagesList = true;
}
@@ -15776,6 +16056,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}, true, themeDelegate);
}
+ private void loadSendAsPeers() {
+ if (sendAsPeersObj != null || currentChat == null || !ChatObject.canSendAsPeers(currentChat) || chatActivityEnterView == null) {
+ return;
+ }
+ sendAsPeersObj = getMessagesController().getSendAsPeers(dialog_id);
+ if (sendAsPeersObj != null) {
+ chatActivityEnterView.updateSendAsButton();
+ }
+ }
+
private boolean sponsoredMessagesAdded;
private void addSponsoredMessages(boolean animated) {
if (sponsoredMessagesAdded || chatMode != 0 || !ChatObject.isChannel(currentChat) || currentChat.megagroup || currentChat.gigagroup || !forwardEndReached[0]) {
@@ -17861,7 +18151,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updatePinnedListButton(boolean animated) {
- if (isThreadChat() || pinnedListButton == null) {
+ if (isThreadChat() || pinnedListButton == null || inMenuMode) {
return;
}
boolean show = pinnedMessageIds.size() > 1;
@@ -17943,7 +18233,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updatePinnedMessageView(boolean animated, int animateToNext) {
- if (pinnedMessageView == null || chatMode != 0) {
+ if (pinnedMessageView == null || chatMode != 0 || inMenuMode) {
return;
}
int pinned_msg_id;
@@ -18454,7 +18744,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updateTopPanel(boolean animated) {
- if (topChatPanelView == null || chatMode != 0) {
+ if (topChatPanelView == null || chatMode != 0 || inMenuMode) {
return;
}
@@ -18477,6 +18767,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean showAdd = preferences.getBoolean("dialog_bar_add" + did, false);
boolean showArchive = preferences.getBoolean("dialog_bar_archived" + dialog_id, false);
boolean showGeo = preferences.getBoolean("dialog_bar_location" + did, false);
+ String chatWithAdmin = preferences.getString("dialog_bar_chat_with_admin_title" + did, null);
+ boolean chatWithAdminChannel = preferences.getBoolean("dialog_bar_chat_with_channel" + did, false);
+ int chatWithAdminDate = preferences.getInt("dialog_bar_chat_with_date" + did, 0);
boolean showAddMembersToGroup = preferences.getBoolean("dialog_bar_invite" + did, false);
if (showAddMembersToGroup) {
@@ -18491,7 +18784,34 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
addToContactsButtonArchive = false;
TLRPC.User user = currentUser != null ? getMessagesController().getUser(currentUser.id) : null;
- if (showAddMembersToGroup) {
+ boolean isChatWithAdmin = false;
+ if (user != null && !TextUtils.isEmpty(chatWithAdmin)) {
+ isChatWithAdmin = true;
+ if (chatWithAdminTextView == null) {
+ chatWithAdminTextView = new TextView(topChatPanelView.getContext());
+ chatWithAdminTextView.setGravity(Gravity.CENTER_VERTICAL);
+ chatWithAdminTextView.setPadding(AndroidUtilities.dp(14), 0, AndroidUtilities.dp(46), 0);
+ chatWithAdminTextView.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), 2));
+ topChatPanelView.addView(chatWithAdminTextView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 0, 1));
+ chatWithAdminTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ chatWithAdminTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ chatWithAdminTextView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ AlertsCreator.showChatWithAdmin(ChatActivity.this, user, chatWithAdmin, chatWithAdminChannel, chatWithAdminDate);
+ }
+ });
+ }
+ String str;
+ if (chatWithAdminChannel) {
+ str = LocaleController.formatString("ChatWithGroupAdmin", R.string.ChatWithGroupAdmin, user.first_name, chatWithAdmin);
+ } else {
+ str = LocaleController.formatString("ChatWithChannelAdmin", R.string.ChatWithChannelAdmin, user.first_name, chatWithAdmin);
+ }
+ reportSpamButton.setVisibility(View.GONE);
+ addToContactsButton.setVisibility(View.GONE);
+ chatWithAdminTextView.setText(AndroidUtilities.replaceTags(str));
+ } else if (showAddMembersToGroup) {
String str = LocaleController.getString("GroupAddMembers", R.string.GroupAddMembers);
if (str != null) {
str = str.toUpperCase();
@@ -18574,7 +18894,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
addContactItem.setVisibility(View.GONE);
}
}
- if (userBlocked || addToContactsButton.getVisibility() == View.GONE && reportSpamButton.getVisibility() == View.GONE) {
+
+ if (chatWithAdminTextView != null) {
+ chatWithAdminTextView.setVisibility(isChatWithAdmin ? View.VISIBLE : View.GONE);
+ }
+ if (userBlocked || (addToContactsButton.getVisibility() == View.GONE && reportSpamButton.getVisibility() == View.GONE && (chatWithAdminTextView == null || chatWithAdminTextView.getVisibility() == View.GONE))) {
show = false;
}
@@ -19563,7 +19887,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedObjectGroup = groupedMessages;
if (type == -1) {
- if (selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) {
+ if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
icons.add(R.drawable.msg_copy);
@@ -19625,9 +19949,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
items.add(LocaleController.getString("Retry", R.string.Retry));
options.add(0);
icons.add(R.drawable.msg_retry);
- items.add(LocaleController.getString("Copy", R.string.Copy));
- options.add(3);
- icons.add(R.drawable.msg_copy);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ items.add(LocaleController.getString("Copy", R.string.Copy));
+ options.add(3);
+ icons.add(R.drawable.msg_copy);
+ }
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(1);
icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.msg_delete);
@@ -19654,7 +19980,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(8);
icons.add(R.drawable.msg_reply);
}
- if (selectedObject.type == 0 || selectedObject.isDice() || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) {
+ if ((selectedObject.type == 0 || selectedObject.isDice() || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
icons.add(R.drawable.msg_copy);
@@ -19692,79 +20018,85 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(26);
icons.add(R.drawable.msg_pollstop);
}
- } else if (selectedObject.isMusic()) {
+ } else if (selectedObject.isMusic() && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
options.add(10);
icons.add(R.drawable.msg_download);
- } else if (selectedObject.isDocument()) {
+ } else if (selectedObject.isDocument() && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
options.add(10);
icons.add(R.drawable.msg_download);
}
}
- } else if (type == 3) {
+ } else if (type == 3 && !getMessagesController().isChatNoForwards(currentChat)) {
if (selectedObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && MessageObject.isNewGifDocument(selectedObject.messageOwner.media.webpage.document)) {
items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
options.add(11);
icons.add(R.drawable.msg_gif);
}
} else if (type == 4) {
- if (selectedObject.isVideo()) {
- if (!selectedObject.needDrawBluredPreview()) {
- items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
- options.add(4);
- icons.add(R.drawable.msg_gallery);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ if (selectedObject.isVideo()) {
+ if (!selectedObject.needDrawBluredPreview()) {
+ items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
+ options.add(4);
+ icons.add(R.drawable.msg_gallery);
+ items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
+ options.add(6);
+ icons.add(R.drawable.msg_shareout);
+ }
+ } else if (selectedObject.isMusic()) {
+ items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
+ options.add(10);
+ icons.add(R.drawable.msg_download);
items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
options.add(6);
icons.add(R.drawable.msg_shareout);
- }
- } else if (selectedObject.isMusic()) {
- items.add(LocaleController.getString("SaveToMusic", R.string.SaveToMusic));
- options.add(10);
- icons.add(R.drawable.msg_download);
- items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
- options.add(6);
- icons.add(R.drawable.msg_shareout);
- } else if (selectedObject.getDocument() != null) {
- if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
- items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
- options.add(11);
- icons.add(R.drawable.msg_gif);
- }
- items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
- options.add(10);
- icons.add(R.drawable.msg_download);
- items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
- options.add(6);
- icons.add(R.drawable.msg_shareout);
- } else {
- if (!selectedObject.needDrawBluredPreview()) {
- items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
- options.add(4);
- icons.add(R.drawable.msg_gallery);
+ } else if (selectedObject.getDocument() != null) {
+ if (MessageObject.isNewGifDocument(selectedObject.getDocument())) {
+ items.add(LocaleController.getString("SaveToGIFs", R.string.SaveToGIFs));
+ options.add(11);
+ icons.add(R.drawable.msg_gif);
+ }
+ items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
+ options.add(10);
+ icons.add(R.drawable.msg_download);
+ items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
+ options.add(6);
+ icons.add(R.drawable.msg_shareout);
+ } else {
+ if (!selectedObject.needDrawBluredPreview()) {
+ items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
+ options.add(4);
+ icons.add(R.drawable.msg_gallery);
+ }
}
}
} else if (type == 5) {
items.add(LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile));
options.add(5);
icons.add(R.drawable.msg_language);
- items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
- options.add(10);
- icons.add(R.drawable.msg_download);
- items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
- options.add(6);
- icons.add(R.drawable.msg_shareout);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
+ options.add(10);
+ icons.add(R.drawable.msg_download);
+ items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
+ options.add(6);
+ icons.add(R.drawable.msg_shareout);
+ }
} else if (type == 10) {
items.add(LocaleController.getString("ApplyThemeFile", R.string.ApplyThemeFile));
options.add(5);
icons.add(R.drawable.msg_theme);
- items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
- options.add(10);
- icons.add(R.drawable.msg_download);
- items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
- options.add(6);
- icons.add(R.drawable.msg_shareout);
- } else if (type == 6) {
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ items.add(LocaleController.getString("SaveToDownloads", R.string.SaveToDownloads));
+ options.add(10);
+ icons.add(R.drawable.msg_download);
+ items.add(LocaleController.getString("ShareFile", R.string.ShareFile));
+ options.add(6);
+ icons.add(R.drawable.msg_shareout);
+ }
+ } else if (type == 6 && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(7);
icons.add(R.drawable.msg_gallery);
@@ -19808,9 +20140,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
icons.add(R.drawable.msg_addcontact);
}
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
- items.add(LocaleController.getString("Copy", R.string.Copy));
- options.add(16);
- icons.add(R.drawable.msg_copy);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ items.add(LocaleController.getString("Copy", R.string.Copy));
+ options.add(16);
+ icons.add(R.drawable.msg_copy);
+ }
items.add(LocaleController.getString("Call", R.string.Call));
options.add(17);
icons.add(R.drawable.msg_callback);
@@ -19829,7 +20163,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
icons.add(R.drawable.msg_unfave);
}
}
- if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && !selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16) {
+ if (!selectedObject.isSponsored() && chatMode != MODE_SCHEDULED && !selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16 && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("Forward", R.string.Forward));
options.add(2);
icons.add(R.drawable.msg_forward);
@@ -19875,7 +20209,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(8);
icons.add(R.drawable.msg_reply);
}
- if (selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) {
+ if ((selectedObject.type == 0 || selectedObject.isAnimatedEmoji() || getMessageCaption(selectedObject, selectedObjectGroup) != null) && !getMessagesController().isChatNoForwards(currentChat)) {
items.add(LocaleController.getString("Copy", R.string.Copy));
options.add(3);
icons.add(R.drawable.msg_copy);
@@ -19889,7 +20223,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
options.add(27);
icons.add(R.drawable.msg_viewreplies);
}
- if (type == 4) {
+ if (type == 4 && !getMessagesController().isChatNoForwards(currentChat)) {
if (selectedObject.isVideo()) {
items.add(LocaleController.getString("SaveToGallery", R.string.SaveToGallery));
options.add(4);
@@ -19940,9 +20274,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
icons.add(R.drawable.msg_addcontact);
}
if (!TextUtils.isEmpty(selectedObject.messageOwner.media.phone_number)) {
- items.add(LocaleController.getString("Copy", R.string.Copy));
- options.add(16);
- icons.add(R.drawable.msg_copy);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ items.add(LocaleController.getString("Copy", R.string.Copy));
+ options.add(16);
+ icons.add(R.drawable.msg_copy);
+ }
items.add(LocaleController.getString("Call", R.string.Call));
options.add(17);
icons.add(R.drawable.msg_callback);
@@ -20066,7 +20402,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
scrimPopupContainerLayout.setOrientation(LinearLayout.VERTICAL);
- boolean showMessageSeen = currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < 7 * 86400) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count < 50 && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest);
+ boolean showMessageSeen = !isInScheduleMode() && currentChat != null && message.isOutOwner() && message.isSent() && !message.isEditing() && !message.isSending() && !message.isSendError() && !message.isContentUnread() && !message.isUnread() && (ConnectionsManager.getInstance(currentAccount).getCurrentTime() - message.messageOwner.date < 7 * 86400) && (ChatObject.isMegagroup(currentChat) || !ChatObject.isChannel(currentChat)) && chatInfo != null && chatInfo.participants_count < 50 && !(message.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByRequest) && (v instanceof ChatMessageCell);
+ boolean showNoForwards = getMessagesController().isChatNoForwards(currentChat) && message.messageOwner.action == null && message.isSent() && !message.isEditing() && chatMode != MODE_SCHEDULED;
MessageSeenView messageSeenView = null;
if (showMessageSeen) {
messageSeenView = new MessageSeenView(contentView.getContext(), currentAccount, message, currentChat);
@@ -20237,7 +20574,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
scrimPopupContainerLayout.addView(messageSeenLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 60));
}
- scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, showMessageSeen ? -8 : 0, 0, 0));
+ scrimPopupContainerLayout.addView(popupLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, showMessageSeen ? -8 : 0, 0, showNoForwards ? -8 : 0));
+
+ if (showNoForwards) {
+ popupLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
+ boolean isChannel = ChatObject.isChannel(currentChat) && !currentChat.megagroup;
+ TextView tv = new TextView(contentView.getContext());
+ tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ tv.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
+ tv.setText(isChannel ? LocaleController.getString("ForwardsRestrictedInfoChannel", R.string.ForwardsRestrictedInfoChannel) :
+ LocaleController.getString("ForwardsRestrictedInfoGroup", R.string.ForwardsRestrictedInfoGroup));
+ tv.setMaxWidth(popupLayout.getMeasuredWidth() - AndroidUtilities.dp(38));
+
+ Drawable shadowDrawable2 = ContextCompat.getDrawable(contentView.getContext(), R.drawable.popup_fixed_alert).mutate();
+ shadowDrawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY));
+
+ FrameLayout fl = new FrameLayout(contentView.getContext());
+ fl.setBackground(shadowDrawable2);
+ fl.addView(tv, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 11, 11, 11, 11));
+ scrimPopupContainerLayout.addView(fl, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ }
+
scrimPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
@Override
public void dismiss() {
@@ -21544,6 +21901,7 @@ 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) {
@@ -22163,8 +22521,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
if (url instanceof URLSpanMono) {
- ((URLSpanMono) url).copyToClipboard();
- getUndoView().showWithAction(0, UndoView.ACTION_TEXT_COPIED, null);
+ if (!getMessagesController().isChatNoForwards(currentChat)) {
+ ((URLSpanMono) url).copyToClipboard();
+ getUndoView().showWithAction(0, UndoView.ACTION_TEXT_COPIED, null);
+ }
} else if (url instanceof URLSpanUserMention) {
TLRPC.User user = getMessagesController().getUser(Utilities.parseLong(((URLSpanUserMention) url).getURL()));
if (user != null) {
@@ -22279,7 +22639,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
final int finalTimestamp = timestamp;
ChatMessageCell finalCell = cell;
MessageObject finalMessageObject = messageObject;
- builder.setItems(new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
+ builder.setItems(getMessagesController().isChatNoForwards(currentChat) ? new CharSequence[] {LocaleController.getString("Open", R.string.Open)} : new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
if (which == 0) {
if (str.startsWith("video?")) {
didPressMessageUrl(url, false, finalMessageObject, finalCell);
@@ -22345,7 +22705,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (longPress) {
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity(), false, themeDelegate);
builder.setTitle(urlFinal);
- builder.setItems(new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
+ builder.setItems(getMessagesController().isChatNoForwards(currentChat) ? new CharSequence[] {LocaleController.getString("Open", R.string.Open)} : new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
if (which == 0) {
processExternalUrl(1, urlFinal, false);
} else if (which == 1) {
@@ -22497,6 +22857,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int messagesStartRow;
private int messagesEndRow;
+ public boolean isFrozen;
+ public ArrayList frozenMessages = new ArrayList<>();
+
public ChatActivityAdapter(Context context) {
mContext = context;
isBot = currentUser != null && currentUser.bot;
@@ -22520,6 +22883,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void updateRowsInternal() {
rowCount = 0;
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
if (!messages.isEmpty()) {
if (!forwardEndReached[0] || mergeDialogId != 0 && !forwardEndReached[1]) {
loadingDownRow = rowCount++;
@@ -22575,6 +22939,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return 1;
}
}
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
+
if (position >= messagesStartRow && position < messagesEndRow) {
return messages.get(position - messagesStartRow).stableId;
} else if (position == botInfoRow || position == botInfoEmptyRow) {
@@ -22598,674 +22964,681 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
view = new ChatMessageCell(mContext, true, themeDelegate);
}
ChatMessageCell chatMessageCell = (ChatMessageCell) view;
- chatMessageCell.setDelegate(new ChatMessageCell.ChatMessageCellDelegate() {
+ if (!inPreviewMode) {
+ 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);
}
- showInfoHint(messageObject, stringBuilder, 1);
+ cell.showHintButton(false, true, type);
}
- 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);
- } 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);
+ @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 {
- openOriginalReplyChat(messageObject);
+ message = cell.getMessageObject();
}
- } else {
- ArrayList arrayList = null;
- if (messageObject.getGroupId() != 0) {
- MessageObject.GroupedMessages groupedMessages = groupedMessagesMap.get(messageObject.getGroupId());
- if (groupedMessages != null) {
- arrayList = groupedMessages.messages;
- }
+ if (message == null) {
+ return false;
}
- 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();
+ return message.getId() == commentLoadingMessageId;
}
- }
- @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()) {
+ @Override
+ public void didPressSideButton(ChatMessageCell cell) {
if (getParentActivity() == null) {
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 (chatActivityEnterView != null) {
+ chatActivityEnterView.closeKeyboard();
}
- 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;
+ 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 (lastDiff != 0) {
- chatListView.smoothScrollBy(0, (int) lastDiff);
- pollHintCell = cell;
- return;
+ 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();
}
- 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 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;
- }
-
- @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);
- 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);
- 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);
- } catch (Exception e) {
- FileLog.e(e);
- alertUserOpenError(message);
+ @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);
}
- } else if (message.type == 4) {
- if (!AndroidUtilities.isGoogleMapsInstalled(ChatActivity.this)) {
+ 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 (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);
+ 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 {
- LocationActivity fragment = new LocationActivity(currentEncryptedChat == null ? 3 : 0);
- fragment.setDelegate(ChatActivity.this);
- fragment.setMessageObject(message);
+ 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);
}
- } 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;
- }
+ }
+
+ 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));
}
- if (locFile == null) {
- File f = FileLoader.getPathToMessage(message.messageOwner);
- if (f.exists()) {
- locFile = f;
- }
+ }
+ }
+
+ 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);
}
- Theme.ThemeInfo themeInfo = Theme.applyThemeFile(locFile, message.getDocumentName(), null, true);
- if (themeInfo != null) {
- presentFragment(new ThemePreviewActivity(themeInfo));
+ 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;
- } else {
- scrollToPositionOnRecreate = -1;
}
+ 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;
+ }
+ }
+ pollHintView.showForMessageCell(cell, showCount, x, y, true);
+ } else {
+ getSendMessagesHelper().sendVote(cell.getMessageObject(), buttons, null);
}
- 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 didPressCancelSendButton(ChatMessageCell cell) {
+ MessageObject message = cell.getMessageObject();
+ if (message.messageOwner.send_state != 0) {
+ getSendMessagesHelper().cancelSendingMessage(message);
}
- if (!handled) {
+ }
+
+ @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;
+ }
+
+ @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);
+ 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);
try {
- AndroidUtilities.openForView(message, getParentActivity(), themeDelegate);
+ 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 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 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);
} else {
- args.putLong("user_id", peerId);
+ LocationActivity fragment = new LocationActivity(currentEncryptedChat == null ? 3 : 0);
+ fragment.setDelegate(ChatActivity.this);
+ fragment.setMessageObject(message);
+ presentFragment(fragment);
}
- if (messageObject.sponsoredChannelPost != 0) {
- args.putInt("message_id", messageObject.sponsoredChannelPost);
+ } 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.botStartParam != null) {
- args.putString("inline_query", messageObject.botStartParam);
+ 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 (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);
+ if (!handled) {
+ try {
+ AndroidUtilities.openForView(message, getParentActivity(), themeDelegate);
+ } catch (Exception e) {
+ FileLog.e(e);
+ alertUserOpenError(message);
+ }
}
}
}
- }
- @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 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);
+ }
+ }
+ }
}
- 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;
+
+ @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);
}
- 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);
+ @Override
+ public String getAdminRank(long uid) {
+ if (ChatObject.isChannel(currentChat) && currentChat.megagroup) {
+ return getMessagesController().getAdminRank(currentChat.id, uid);
+ }
+ return null;
}
- return null;
- }
- @Override
- public boolean shouldRepeatSticker(MessageObject message) {
- return !alredyPlayedStickers.containsKey(message);
- }
-
- @Override
- public void setShouldNotRepeatSticker(MessageObject message) {
- alredyPlayedStickers.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;
+ @Override
+ public boolean shouldRepeatSticker(MessageObject message) {
+ return !alreadyPlayedStickers.containsKey(message);
}
- fireworksOverlay.start();
- fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
- }
- @Override
- public PinchToZoomHelper getPinchToZoomHelper() {
- return pinchToZoomHelper;
- }
+ @Override
+ public void setShouldNotRepeatSticker(MessageObject message) {
+ alreadyPlayedStickers.put(message, true);
+ }
- @Override
- public boolean keyboardIsOpened() {
- return contentView.getKeyboardHeight() + chatEmojiViewPadding >= AndroidUtilities.dp(20);
- }
+ @Override
+ public TextSelectionHelper.ChatListTextSelectionHelper getTextSelectionHelper() {
+ return textSelectionHelper;
+ }
- public boolean isLandscape() {
- return contentView.getMeasuredWidth() > contentView.getMeasuredHeight();
- }
- });
+ @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() {
+
+ });
+ }
if (currentEncryptedChat == null) {
chatMessageCell.setAllowAssistant(true);
}
@@ -23376,6 +23749,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ChatLoadingCell loadingCell = (ChatLoadingCell) holder.itemView;
loadingCell.setProgressVisible(loadsCount > 1);
} else if (position >= messagesStartRow && position < messagesEndRow) {
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
+
MessageObject message = messages.get(position - messagesStartRow);
View view = holder.itemView;
@@ -23757,6 +24132,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
if (position >= messagesStartRow && position < messagesEndRow) {
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
return messages.get(position - messagesStartRow).contentType;
} else if (position == botInfoRow) {
return 3;
@@ -23854,6 +24230,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int position = holder.getAdapterPosition();
if (position >= messagesStartRow && position < messagesEndRow) {
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
+
MessageObject message = messages.get(position - messagesStartRow);
View view = holder.itemView;
if (message != null && message.messageOwner != null && message.messageOwner.media_unread && message.messageOwner.mentioned) {
@@ -23889,6 +24267,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
int lastVisibleItem = RecyclerView.NO_POSITION;
int top = 0;
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
+
if (!wasManualScroll && unreadMessageObject != null) {
int n = chatListView.getChildCount();
for (int i = 0; i < n; i++) {
@@ -23937,6 +24317,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
+ ArrayList messages = isFrozen ? frozenMessages : ChatActivity.this.messages;
+
int index = messages.indexOf(messageObject);
if (index == -1) {
return null;
@@ -24670,10 +25052,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelHint));
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, null, Theme.key_chat_messagePanelSend));
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, 24, null, Theme.key_chat_messagePanelSend));
- themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"emojiButton1"}, null, null, null, Theme.key_chat_messagePanelIcons));
- themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"emojiButton1"}, null, null, null, Theme.key_listSelector));
- themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"emojiButton2"}, null, null, null, Theme.key_chat_messagePanelIcons));
- themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"emojiButton2"}, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"botButton"}, null, null, null, Theme.key_chat_messagePanelIcons));
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, ThemeDescription.FLAG_USEBACKGROUNDDRAWABLE | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{ChatActivityEnterView.class}, new String[]{"botButton"}, null, null, null, Theme.key_listSelector));
themeDescriptions.add(new ThemeDescription(chatActivityEnterView, 0, new Class[]{ChatActivityEnterView.class}, new String[]{"notifyButton"}, null, null, null, Theme.key_chat_messagePanelIcons));
@@ -25414,7 +25792,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Theme.applyTheme(activeTheme, false, isDark);
} else {
- currentColors = chatTheme.getCurrentColors(currentAccount, isDark ? 1 : 0);
+ currentColors = chatTheme.createColors(currentAccount, isDark ? 1 : 0);
backgroundDrawable = getBackgroundDrawableFromTheme(chatTheme, prevPhase);
if (patternAlphaAnimator != null) {
@@ -25678,7 +26056,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
Drawable drawable;
if (chatTheme.showAsDefaultStub) {
Theme.ThemeInfo themeInfo = EmojiThemes.getDefaultThemeInfo(isDark);
- HashMap currentColors = chatTheme.getCurrentColors(currentAccount, isDark ? 1 : 0);
+ HashMap currentColors = chatTheme.getPreviewColors(currentAccount, isDark ? 1 : 0);
String wallpaperLink = chatTheme.getWallpaperLink(isDark ? 1 : 0);
Theme.BackgroundDrawableSettings settings = Theme.createBackgroundDrawable(themeInfo, currentColors, wallpaperLink, prevPhase);
drawable = settings.wallpaper;
@@ -25693,7 +26071,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MotionBackgroundDrawable motionDrawable = new MotionBackgroundDrawable();
motionDrawable.setPatternBitmap(chatTheme.getWallpaper(isDark ? 1 : 0).settings.intensity);
- motionDrawable.setColors(backgroundColor, gradientColor1, gradientColor2, gradientColor3, true);
+ motionDrawable.setColors(backgroundColor, gradientColor1, gradientColor2, gradientColor3, 0,true);
motionDrawable.setPhase(prevPhase);
int patternColor = motionDrawable.getPatternColor();
final boolean isDarkTheme = isDark;
@@ -25732,4 +26110,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return color;
}
}
+
+ @Override
+ protected boolean allowPresentFragment() {
+ return !inPreviewMode;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java
index bd8117181..91dc0d96a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditActivity.java
@@ -1343,10 +1343,11 @@ public class ChatEditActivity extends BaseFragment implements ImageUpdater.Image
typeCell.setTextAndValue(LocaleController.getString("TypeLocationGroup", R.string.TypeLocationGroup), link, historyCell != null && historyCell.getVisibility() == View.VISIBLE || linkedCell != null && linkedCell.getVisibility() == View.VISIBLE);
} else {
String type;
+ boolean isRestricted = currentChat.noforwards;
if (isChannel) {
- type = isPrivate ? LocaleController.getString("TypePrivate", R.string.TypePrivate) : LocaleController.getString("TypePublic", R.string.TypePublic);
+ type = isPrivate ? isRestricted ? LocaleController.getString("TypePrivateRestrictedForwards", R.string.TypePrivateRestrictedForwards) : LocaleController.getString("TypePrivate", R.string.TypePrivate) : LocaleController.getString("TypePublic", R.string.TypePublic);
} else {
- type = isPrivate ? LocaleController.getString("TypePrivateGroup", R.string.TypePrivateGroup) : LocaleController.getString("TypePublicGroup", R.string.TypePublicGroup);
+ type = isPrivate ? isRestricted ? LocaleController.getString("TypePrivateGroupRestrictedForwards", R.string.TypePrivateGroupRestrictedForwards) : LocaleController.getString("TypePrivateGroup", R.string.TypePrivateGroup) : LocaleController.getString("TypePublicGroup", R.string.TypePublicGroup);
}
if (isChannel) {
typeCell.setTextAndValue(LocaleController.getString("ChannelType", R.string.ChannelType), type, historyCell != null && historyCell.getVisibility() == View.VISIBLE || linkedCell != null && linkedCell.getVisibility() == View.VISIBLE);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
index ec6c659b6..bb5ae288c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatEditTypeActivity.java
@@ -21,6 +21,7 @@ import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.LinearLayout;
import android.widget.ScrollView;
+import android.widget.Toast;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
@@ -43,6 +44,7 @@ import org.telegram.ui.Cells.LoadingCell;
import org.telegram.ui.Cells.RadioButtonCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCell;
+import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.EditTextBoldCursor;
@@ -81,12 +83,19 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
private TextSettingsCell textCell;
private TextSettingsCell textCell2;
+ // Saving content restrictions block
+ private LinearLayout saveContainer;
+ private HeaderCell saveHeaderCell;
+ private TextCheckCell saveRestrictCell;
+ private TextInfoPrivacyCell saveRestrictInfoCell;
+
private boolean isPrivate;
private TLRPC.Chat currentChat;
private TLRPC.ChatFull info;
private long chatId;
private boolean isChannel;
+ private boolean isSaveRestricted;
private boolean canCreatePublic = true;
private boolean loadingAdminedChannels;
@@ -133,6 +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;
if (isForcePublic && TextUtils.isEmpty(currentChat.username) || isPrivate && currentChat.creator) {
TLRPC.TL_channels_checkUsername req = new TLRPC.TL_channels_checkUsername();
req.username = "1";
@@ -399,6 +409,32 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
manageLinksInfoCell = new TextInfoPrivacyCell(context);
linearLayout.addView(manageLinksInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ saveContainer = new LinearLayout(context);
+ saveContainer.setOrientation(LinearLayout.VERTICAL);
+ linearLayout.addView(saveContainer);
+
+ saveHeaderCell = new HeaderCell(context, 23);
+ saveHeaderCell.setHeight(46);
+ saveHeaderCell.setText(LocaleController.getString("SavingContentTitle", R.string.SavingContentTitle));
+ saveHeaderCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
+ saveContainer.addView(saveHeaderCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ saveRestrictCell = new TextCheckCell(context);
+ saveRestrictCell.setBackgroundDrawable(Theme.getSelectorDrawable(true));
+ saveRestrictCell.setTextAndCheck(LocaleController.getString("RestrictSavingContent", R.string.RestrictSavingContent), isSaveRestricted, false);
+ saveRestrictCell.setOnClickListener(v -> {
+ isSaveRestricted = !isSaveRestricted;
+ ((TextCheckCell) v).setChecked(isSaveRestricted);
+ });
+ saveContainer.addView(saveRestrictCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ saveRestrictInfoCell = new TextInfoPrivacyCell(context);
+ if (isChannel && !ChatObject.isMegagroup(currentChat)) {
+ saveRestrictInfoCell.setText(LocaleController.getString("RestrictSavingContentInfoChannel", R.string.RestrictSavingContentInfoChannel));
+ } else {
+ saveRestrictInfoCell.setText(LocaleController.getString("RestrictSavingContentInfoGroup", R.string.RestrictSavingContentInfoGroup));
+ }
+
+ saveContainer.addView(saveRestrictInfoCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+
if (!isPrivate && currentChat.username != null) {
ignoreTextChanges = true;
usernameTextView.setText(currentChat.username);
@@ -434,6 +470,9 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
}
private void processDone() {
+ if (isPrivate && currentChat.noforwards != isSaveRestricted) {
+ getMessagesController().toggleChatNoForwards(chatId, currentChat.noforwards = isSaveRestricted);
+ }
if (trySetUsername()) {
finishFragment();
}
@@ -577,6 +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);
manageLinksTextView.setVisibility(View.VISIBLE);
manageLinksInfoCell.setVisibility(View.VISIBLE);
linkContainer.setPadding(0, 0, 0, isPrivate ? 0 : AndroidUtilities.dp(7));
@@ -769,9 +809,15 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
themeDescriptions.add(new ThemeDescription(linkContainer, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(headerCell, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(headerCell2, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
+ themeDescriptions.add(new ThemeDescription(saveHeaderCell, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText));
+ themeDescriptions.add(new ThemeDescription(saveRestrictCell, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
+ themeDescriptions.add(new ThemeDescription(saveRestrictCell, 0, new Class[]{TextCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
+ themeDescriptions.add(new ThemeDescription(saveRestrictCell, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrack));
+ themeDescriptions.add(new ThemeDescription(saveRestrictCell, 0, new Class[]{TextCheckCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_switchTrackChecked));
+
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText8));
themeDescriptions.add(new ThemeDescription(checkTextView, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGreenText));
@@ -784,6 +830,10 @@ public class ChatEditTypeActivity extends BaseFragment implements NotificationCe
themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
themeDescriptions.add(new ThemeDescription(manageLinksInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
+ themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
+ themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
+ themeDescriptions.add(new ThemeDescription(saveRestrictInfoCell, ThemeDescription.FLAG_CHECKTAG, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteRedText4));
+
themeDescriptions.add(new ThemeDescription(adminedInfoCell, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(adminnedChannelsLayout, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
themeDescriptions.add(new ThemeDescription(loadingAdminedCell, 0, new Class[]{LoadingCell.class}, new String[]{"progressBar"}, null, null, null, Theme.key_progressCircle));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatLinkActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatLinkActivity.java
index d956f7ddf..f3a2162a5 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatLinkActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatLinkActivity.java
@@ -120,7 +120,7 @@ public class ChatLinkActivity extends BaseFragment implements NotificationCenter
}
private void setSticker() {
- TLRPC.TL_messages_stickerSet set = MediaDataController.getInstance(currentAccount).getStickerSetByName(stickerSetName);
+ TLRPC.messages_StickerSet set = MediaDataController.getInstance(currentAccount).getStickerSetByName(stickerSetName);
if (set == null) {
set = MediaDataController.getInstance(currentAccount).getStickerSetByEmojiOrName(stickerSetName);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
index a3f1d21a0..f81833a9c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
@@ -2828,9 +2828,11 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
peerObject = object;
} else if (object instanceof TLRPC.ChannelParticipant) {
long peerId = MessageObject.getPeerId(((TLRPC.ChannelParticipant) object).peer);
- if (peerId > 0) {
+ if (peerId >= 0) {
TLRPC.User user = getMessagesController().getUser(peerId);
- un = user.username;
+ if (user != null) {
+ un = user.username;
+ }
peerObject = user;
} else {
TLRPC.Chat chat = getMessagesController().getChat(-peerId);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CodeFieldContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/CodeFieldContainer.java
new file mode 100644
index 000000000..631ae6c91
--- /dev/null
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CodeFieldContainer.java
@@ -0,0 +1,287 @@
+package org.telegram.ui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.text.Editable;
+import android.text.InputType;
+import android.text.TextWatcher;
+import android.util.TypedValue;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.widget.LinearLayout;
+
+import androidx.core.graphics.ColorUtils;
+
+import org.telegram.PhoneFormat.PhoneFormat;
+import org.telegram.messenger.AndroidUtilities;
+import org.telegram.ui.ActionBar.Theme;
+import org.telegram.ui.Components.EditTextBoldCursor;
+import org.telegram.ui.Components.LayoutHelper;
+
+public class CodeFieldContainer extends LinearLayout {
+
+ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ Paint bitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ float strokeWidth;
+ public boolean ignoreOnTextChange;
+
+ public CodeNumberField[] codeField;
+
+ public CodeFieldContainer(Context context) {
+ super(context);
+ paint.setStyle(Paint.Style.STROKE);
+ setOrientation(HORIZONTAL);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ paint.setStrokeWidth(strokeWidth = AndroidUtilities.dp(1.5f));
+ }
+
+ @Override
+ protected void dispatchDraw(Canvas canvas) {
+ for (int i = 0; i < getChildCount(); i++) {
+ View child = getChildAt(i);
+ if (child instanceof CodeNumberField) {
+ CodeNumberField codeField = (CodeNumberField) child;
+ if (child.isFocused() && codeField.focusedProgress != 1f) {
+ codeField.focusedProgress += 16f / 150f;
+ if (codeField.focusedProgress > 1f) {
+ codeField.focusedProgress = 1f;
+ } else {
+ invalidate();
+ }
+ } else if (!child.isFocused() && codeField.focusedProgress != 0) {
+ codeField.focusedProgress -= 16f / 150f;
+ if (codeField.focusedProgress < 0f) {
+ codeField.focusedProgress = 0f;
+ } else {
+ invalidate();
+ }
+ }
+ paint.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteInputField), Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), codeField.focusedProgress));
+ AndroidUtilities.rectTmp.set(child.getLeft(), child.getTop(), child.getRight(), child.getBottom());
+ AndroidUtilities.rectTmp.inset(strokeWidth, strokeWidth);
+ canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
+ }
+ }
+ super.dispatchDraw(canvas);
+ }
+
+ @Override
+ protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
+ if (child instanceof CodeNumberField) {
+ CodeNumberField field = (CodeNumberField) child;
+ canvas.save();
+ float progress = ((CodeNumberField) child).enterAnimation;
+ AndroidUtilities.rectTmp.set(child.getX(), child.getY(), child.getX() + child.getMeasuredWidth(), child.getY() + child.getMeasuredHeight());
+ AndroidUtilities.rectTmp.inset(strokeWidth, strokeWidth);
+ canvas.clipRect(AndroidUtilities.rectTmp);
+ if (field.replaceAnimation) {
+ float s = progress * 0.5f + 0.5f;
+ child.setAlpha(progress);
+ canvas.scale(s, s, field.getX() + field.getMeasuredWidth() / 2f, field.getY() + field.getMeasuredHeight() / 2f);
+ } else {
+ child.setAlpha(1f);
+ canvas.translate(0, child.getMeasuredHeight() * (1f - progress));
+ }
+ super.drawChild(canvas, child, drawingTime);
+ canvas.restore();
+
+ float exitProgress = field.exitAnimation;
+ if (exitProgress < 1f) {
+ canvas.save();
+ float s = (1f - exitProgress) * 0.5f + 0.5f;
+ canvas.scale(s, s, field.getX() + field.getMeasuredWidth() / 2f, field.getY() + field.getMeasuredHeight() / 2f);
+ bitmapPaint.setAlpha((int) (255 * (1f - exitProgress)));
+ canvas.drawBitmap(field.exitBitmap, field.getX(), field.getY(), bitmapPaint);
+ canvas.restore();
+ }
+ return true;
+ }
+ return super.drawChild(canvas, child, drawingTime);
+ }
+
+ public void setNumbersCount(int length, int currentType) {
+ if (codeField == null || codeField.length != length) {
+ codeField = new CodeNumberField[length];
+ for (int a = 0; a < length; a++) {
+ final int num = a;
+ codeField[a] = new CodeNumberField(getContext()) {
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
+ return false;
+ }
+ int keyCode = event.getKeyCode();
+ if (event.getAction() == KeyEvent.ACTION_UP) {
+ if (keyCode == KeyEvent.KEYCODE_DEL && codeField[num].length() == 1) {
+ codeField[num].startExitAnimation();
+ codeField[num].setText("");
+ return true;
+ } else if (keyCode == KeyEvent.KEYCODE_DEL && codeField[num].length() == 0 && num > 0) {
+ codeField[num - 1].setSelection(codeField[num - 1].length());
+ for (int i = 0; i < num; i++) {
+ if (i == num - 1) {
+ codeField[num - 1].requestFocus();
+ } else {
+ codeField[i].clearFocus();
+ }
+ }
+ codeField[num - 1].startExitAnimation();
+ codeField[num - 1].setText("");
+ return true;
+ } else {
+ if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
+ String str = Integer.toString(keyCode - KeyEvent.KEYCODE_0);
+ if (codeField[num].getText() != null && str.equals(codeField[num].getText().toString())) {
+ if (num >= length - 1) {
+ processNextPressed();
+ } else {
+ codeField[num + 1].requestFocus();
+ }
+ return true;
+ }
+ if (codeField[num].length() > 0) {
+ codeField[num].startExitAnimation();
+ }
+ codeField[num].setText(str);
+ }
+ return true;
+ }
+ } else {
+ return isFocused();
+ }
+ }
+ };
+
+ codeField[a].setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ codeField[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ codeField[a].setMaxLines(1);
+ codeField[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ codeField[a].setPadding(0, 0, 0, 0);
+ codeField[a].setGravity(Gravity.CENTER);
+ if (currentType == 3) {
+ codeField[a].setEnabled(false);
+ codeField[a].setInputType(InputType.TYPE_NULL);
+ codeField[a].setVisibility(GONE);
+ } else {
+ codeField[a].setInputType(InputType.TYPE_CLASS_PHONE);
+ }
+ int width;
+ int height;
+ int gapSize;
+ if (currentType == LoginActivity.AUTH_TYPE_MISSED_CALL) {
+ width = 28;
+ height = 34;
+ gapSize = 5;
+ } else {
+ width = 34;
+ height = 42;
+ gapSize = 7;
+ }
+ addView(codeField[a], LayoutHelper.createLinear(width, height, Gravity.CENTER_HORIZONTAL, 0, 0, a != length - 1 ? gapSize: 0, 0));
+ codeField[a].addTextChangedListener(new TextWatcher() {
+
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (ignoreOnTextChange) {
+ return;
+ }
+ int len = s.length();
+ if (len >= 1) {
+ boolean next = false;
+ int n = num;
+ if (len > 1) {
+ String text = s.toString();
+ ignoreOnTextChange = true;
+ for (int a = 0; a < Math.min(length - num, len); a++) {
+ if (a == 0) {
+ s.replace(0, len, text.substring(a, a + 1));
+ } else {
+ n++;
+ codeField[num + a].setText(text.substring(a, a + 1));
+ }
+ }
+ ignoreOnTextChange = false;
+ }
+
+
+ if (n != length - 1) {
+ codeField[n + 1].setSelection(codeField[n + 1].length());
+ codeField[n + 1].requestFocus();
+ }
+ if ((n == length - 1 || n == length - 2 && len >= 2) && getCode().length() == length) {
+ processNextPressed();
+ }
+ }
+ }
+ });
+ codeField[a].setOnEditorActionListener((textView, i, keyEvent) -> {
+ if (i == EditorInfo.IME_ACTION_NEXT) {
+ processNextPressed();
+ return true;
+ }
+ return false;
+ });
+ }
+ } else {
+ for (int a = 0; a < codeField.length; a++) {
+ codeField[a].setText("");
+ }
+ }
+ }
+
+ protected void processNextPressed() {
+
+ }
+
+ public String getCode() {
+ if (codeField == null) {
+ return "";
+ }
+ StringBuilder codeBuilder = new StringBuilder();
+ for (int a = 0; a < codeField.length; a++) {
+ codeBuilder.append(PhoneFormat.stripExceptNumbers(codeField[a].getText().toString()));
+ }
+ return codeBuilder.toString();
+ }
+
+ public void setCode(String savedCode) {
+ codeField[0].setText(savedCode);
+ }
+
+ public void setText(String code) {
+ setText(code, false);
+ }
+
+ public void setText(String code, boolean fromPaste) {
+ int startFrom = 0;
+ if (fromPaste) {
+ for (int i = 0; i < codeField.length; i++) {
+ if (codeField[i].isFocused()) {
+ startFrom = i;
+ break;
+ }
+ }
+ }
+ for (int i = startFrom; i < Math.min(codeField.length, startFrom + code.length()); i++) {
+ codeField[i].setText(Character.toString(code.charAt(i - startFrom)));
+ }
+ }
+
+}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CodeNumberField.java b/TMessagesProj/src/main/java/org/telegram/ui/CodeNumberField.java
new file mode 100644
index 000000000..f7dabf979
--- /dev/null
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CodeNumberField.java
@@ -0,0 +1,238 @@
+package org.telegram.ui;
+
+import android.animation.ValueAnimator;
+import android.content.ClipData;
+import android.content.ClipDescription;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.text.Editable;
+import android.text.Layout;
+import android.text.StaticLayout;
+import android.text.TextWatcher;
+import android.view.ActionMode;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.OvershootInterpolator;
+import android.widget.TextView;
+
+import androidx.core.content.ContextCompat;
+
+import org.checkerframework.checker.regex.qual.Regex;
+import org.telegram.messenger.AndroidUtilities;
+import org.telegram.ui.ActionBar.Theme;
+import org.telegram.ui.Components.EditTextBoldCursor;
+import org.telegram.ui.Components.StaticLayoutEx;
+
+public class CodeNumberField extends EditTextBoldCursor {
+
+ float focusedProgress;
+ float enterAnimation = 1f;
+ float exitAnimation = 1f;
+ boolean replaceAnimation;
+ Bitmap exitBitmap;
+ Canvas exitCanvas;
+
+ ValueAnimator enterAnimator;
+ ValueAnimator exitAnimator;
+
+ ActionMode actionMode;
+
+ public CodeNumberField(Context context) {
+ super(context);
+ setBackground(null);
+ setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ setMovementMethod(null);
+ addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ startEnterAnimation(charSequence.length() != 0);
+ hideActionMode();
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+
+ }
+ });
+
+ }
+
+ public void startExitAnimation() {
+ if (getMeasuredHeight() == 0 || getMeasuredWidth() == 0 || getLayout() == null) {
+ return;
+ }
+ if (exitBitmap == null || exitBitmap.getHeight() != getMeasuredHeight() || exitBitmap.getWidth() != getMeasuredWidth()) {
+ if (exitBitmap != null) {
+ exitBitmap.recycle();
+ }
+ exitBitmap = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888);
+ exitCanvas = new Canvas(exitBitmap);
+ }
+ exitBitmap.eraseColor(Color.TRANSPARENT);
+
+ StaticLayout staticLayout = new StaticLayout(getText(), getLayout().getPaint(), (int) Math.ceil(getLayout().getPaint().measureText(String.valueOf(getText()))), Layout.Alignment.ALIGN_NORMAL, getLineSpacingMultiplier(), getLineSpacingExtra(), getIncludeFontPadding());
+ exitCanvas.save();
+ exitCanvas.translate((getMeasuredWidth() - staticLayout.getWidth()) / 2f, (getMeasuredHeight() - staticLayout.getHeight()) / 2f);
+ staticLayout.draw(exitCanvas);
+ exitCanvas.restore();
+
+ exitAnimation = 0f;
+ exitAnimator = ValueAnimator.ofFloat(exitAnimation, 1f);
+ exitAnimator.addUpdateListener(valueAnimator1 -> {
+ exitAnimation = (float) valueAnimator1.getAnimatedValue();
+ invalidate();
+ if (getParent() != null) {
+ ((ViewGroup) getParent()).invalidate();
+ }
+ });
+ exitAnimator.setDuration(220);
+ exitAnimator.start();
+ }
+
+ public void startEnterAnimation(boolean replace) {
+ replaceAnimation = replace;
+ enterAnimation = 0f;
+ enterAnimator = ValueAnimator.ofFloat(enterAnimation, 1f);
+ enterAnimator.addUpdateListener(valueAnimator1 -> {
+ enterAnimation = (float) valueAnimator1.getAnimatedValue();
+ invalidate();
+ if (getParent() != null) {
+ ((ViewGroup) getParent()).invalidate();
+ }
+ });
+ if (!replaceAnimation) {
+ enterAnimator.setInterpolator(new OvershootInterpolator(1.5f));
+ enterAnimator.setDuration(350);
+ } else {
+ enterAnimator.setDuration(220);
+ }
+ enterAnimator.start();
+ }
+
+ @Override
+ public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
+ ((ViewGroup) getParent()).invalidate();
+ return super.requestFocus(direction, previouslyFocusedRect);
+ }
+
+
+ boolean pressed = false;
+ float startX = 0;
+ float startY = 0;
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ pressed = true;
+ startX = event.getX();
+ startY = event.getY();
+ }
+ if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
+ CodeFieldContainer codeFieldContainer = null;
+ if (getParent() instanceof CodeFieldContainer) {
+ codeFieldContainer = (CodeFieldContainer) getParent();
+ }
+ if (event.getAction() == MotionEvent.ACTION_UP && pressed) {
+ if (isFocused() && codeFieldContainer != null) {
+ ClipboardManager clipboard = ContextCompat.getSystemService(getContext(), ClipboardManager.class);
+ if (clipboard == null) {
+ return false;
+ }
+ clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
+ ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
+ int i = -1;
+ String text = item.getText().toString();
+ try {
+ i = Integer.parseInt(text);
+ } catch (Exception e) {
+
+ }
+
+ if (i > 0) {
+ startActionMode(new ActionMode.Callback() {
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ menu.add(Menu.NONE, android.R.id.paste, 0, android.R.string.paste);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.paste:
+ pasteFromClipboard();
+ hideActionMode();
+ return true;
+ }
+ return true;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+
+ }
+ });
+ }
+ } else {
+ requestFocus();
+ }
+ setSelection(0);
+ AndroidUtilities.showKeyboard(this);
+ }
+ pressed = false;
+ }
+ return pressed;
+ }
+
+ private void pasteFromClipboard() {
+ CodeFieldContainer codeFieldContainer = null;
+ if (getParent() instanceof CodeFieldContainer) {
+ codeFieldContainer = (CodeFieldContainer) getParent();
+ }
+ if (codeFieldContainer != null) {
+ ClipboardManager clipboard = ContextCompat.getSystemService(getContext(), ClipboardManager.class);
+ if (clipboard == null) {
+ return;
+ }
+ clipboard.getPrimaryClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN);
+ ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
+ int i = -1;
+ String text = item.getText().toString();
+ try {
+ i = Integer.parseInt(text);
+ } catch (Exception e) {
+
+ }
+ if (i > 0) {
+ codeFieldContainer.setText(text, true);
+ }
+ }
+ }
+
+ @Override
+ protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
+ super.onFocusChanged(focused, direction, previouslyFocusedRect);
+ if (!isFocused()) {
+ hideActionMode();
+ }
+ }
+}
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 3fc1b225d..c1c4edc23 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
@@ -1487,6 +1487,80 @@ public class AlertsCreator {
}
}
+ public static void createClearDaysDialogAlert(BaseFragment fragment, int days, TLRPC.User user, MessagesStorage.BooleanCallback onProcessRunnable, Theme.ResourcesProvider resourcesProvider) {
+ if (fragment == null || fragment.getParentActivity() == null || user == null) {
+ return;
+ }
+ int account = fragment.getCurrentAccount();
+
+ Context context = fragment.getParentActivity();
+ AlertDialog.Builder builder = new AlertDialog.Builder(context, resourcesProvider);
+ long selfUserId = UserConfig.getInstance(account).getClientUserId();
+
+ CheckBoxCell[] cell = new CheckBoxCell[1];
+
+ TextView messageTextView = new TextView(context);
+ messageTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
+ messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+ messageTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
+
+ FrameLayout frameLayout = new FrameLayout(context) {
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ if (cell[0] != null) {
+ setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight() + cell[0].getMeasuredHeight());
+ }
+ }
+ };
+ builder.setView(frameLayout);
+
+ TextView textView = new TextView(context);
+ textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ textView.setLines(1);
+ textView.setMaxLines(1);
+ textView.setSingleLine(true);
+ textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
+ textView.setEllipsize(TextUtils.TruncateAt.END);
+
+ textView.setText(LocaleController.formatPluralString("DeleteDays", days));
+
+ frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 11, 24, 0));
+ frameLayout.addView(messageTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 48, 24, 18));
+
+ messageTextView.setText(LocaleController.getString("DeleteHistoryByDaysMessage", R.string.DeleteHistoryByDaysMessage));
+ final boolean[] deleteForAll = new boolean[]{false};
+
+ if (user.id != selfUserId) {
+ cell[0] = new CheckBoxCell(context, 1, resourcesProvider);
+ cell[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
+ cell[0].setText(LocaleController.formatString("DeleteMessagesOptionAlso", R.string.DeleteMessagesOptionAlso, UserObject.getFirstName(user)), "", false, false);
+
+ cell[0].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
+ frameLayout.addView(cell[0], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 0));
+
+ cell[0].setChecked(false, false);
+ cell[0].setOnClickListener(v -> {
+ CheckBoxCell cell1 = (CheckBoxCell) v;
+ deleteForAll[0] = !deleteForAll[0];
+ cell1.setChecked(deleteForAll[0], true);
+ });
+ }
+
+ builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialogInterface, i) -> {
+ onProcessRunnable.run(deleteForAll[0]);
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ AlertDialog alertDialog = builder.create();
+ fragment.showDialog(alertDialog);
+ TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
+ if (button != null) {
+ button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
+ }
+ }
+
public static void createCallDialogAlert(BaseFragment fragment, TLRPC.User user, boolean videoCall) {
if (fragment == null || fragment.getParentActivity() == null || user == null || UserObject.isDeleted(user) || UserConfig.getInstance(fragment.getCurrentAccount()).getClientUserId() == user.id) {
return;
@@ -1831,6 +1905,43 @@ public class AlertsCreator {
}
+ public static void showChatWithAdmin(BaseFragment fragment, TLRPC.User user, String chatWithAdmin, boolean isChannel, int chatWithAdminDate) {
+ if (fragment.getParentActivity() == null) {
+ return;
+ }
+ BottomSheet.Builder builder = new BottomSheet.Builder(fragment.getParentActivity());
+ builder.setTitle(isChannel ? LocaleController.getString("ChatWithAdminChannelTitle", R.string.ChatWithAdminChannelTitle) : LocaleController.getString("ChatWithAdminGroupTitle", R.string.ChatWithAdminGroupTitle), true);
+ LinearLayout linearLayout = new LinearLayout(fragment.getParentActivity());
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
+ TextView messageTextView = new TextView(fragment.getParentActivity());
+ linearLayout.addView(messageTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 24, 16, 24, 24));
+ messageTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
+ messageTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+
+ messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ChatWithAdminMessage", R.string.ChatWithAdminMessage, chatWithAdmin, LocaleController.formatDateAudio(chatWithAdminDate, false))));
+
+
+ TextView buttonTextView = new TextView(fragment.getParentActivity());
+ 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("IUnderstand", R.string.IUnderstand));
+
+ buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
+ buttonTextView.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
+
+ linearLayout.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, 0, 24, 15, 16, 24));
+
+
+ builder.setCustomView(linearLayout);
+ BottomSheet bottomSheet = builder.show();
+
+ buttonTextView.setOnClickListener((v) -> {
+ bottomSheet.dismiss();
+ });
+ }
+
public interface BlockDialogCallback {
void run(boolean report, boolean delete);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
index 355318046..1f3de449a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
@@ -1857,6 +1857,18 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
} else {
optionsButton.setVisibility(View.VISIBLE);
}
+ if (MessagesController.getInstance(currentAccount).isChatNoForwards(messageObject.getChatId())) {
+ optionsButton.hideSubItem(1);
+ optionsButton.hideSubItem(2);
+ optionsButton.hideSubItem(5);
+ optionsButton.setAdditionalYOffset(-AndroidUtilities.dp(16));
+ } else {
+ optionsButton.showSubItem(1);
+ optionsButton.showSubItem(2);
+ optionsButton.showSubItem(5);
+ optionsButton.setAdditionalYOffset(-AndroidUtilities.dp(157));
+ }
+
checkIfMusicDownloaded(messageObject);
updateProgress(messageObject, !sameMessageObject);
updateCover(messageObject, !sameMessageObject);
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 71b6628d9..82eccf8c0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
@@ -16,12 +16,14 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
+import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipDescription;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -34,6 +36,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.RectF;
+import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.net.Uri;
@@ -55,6 +58,7 @@ import android.text.style.ImageSpan;
import android.util.Property;
import android.util.TypedValue;
import android.view.ActionMode;
+import android.view.DisplayCutout;
import android.view.Gravity;
import android.view.HapticFeedbackConstants;
import android.view.KeyEvent;
@@ -63,6 +67,8 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
@@ -92,6 +98,7 @@ import androidx.core.view.inputmethod.InputContentInfoCompat;
import androidx.customview.widget.ExploreByTouchHelper;
import androidx.recyclerview.widget.ChatListItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
@@ -138,6 +145,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.atomic.AtomicReference;
public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate {
@@ -211,6 +219,28 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
default boolean hasForwardingMessages() {
return false;
}
+
+ /**
+ * @return Height of the content view
+ */
+ default int getContentViewHeight() {
+ return 0;
+ }
+
+ /**
+ * @return Measured keyboard height
+ */
+ default int measureKeyboardHeight() {
+ return 0;
+ }
+
+ /**
+ * @return A list of available peers to send messages as
+ */
+ @Nullable
+ default TLRPC.TL_channels_sendAsPeers getSendAsPeers() {
+ return null;
+ }
}
private final static int RECORD_STATE_ENTER = 0;
@@ -244,6 +274,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
public BotCommandsMenuContainer botCommandsMenuContainer;
private BotCommandsMenuView.BotCommandsAdapter botCommandsAdapter;
+ // Send as... stuff
+ private SenderSelectView senderSelectView;
+ private ActionBarPopupWindow senderSelectPopupWindow;
+ private Runnable onEmojiSearchClosed;
+ private int popupX, popupY;
+ private Runnable onKeyboardClosed;
+
private ValueAnimator searchAnimator;
private float searchToOpenProgress;
@@ -325,10 +362,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
private ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout;
private ImageView cancelBotButton;
private ImageView[] emojiButton = new ImageView[2];
- @SuppressWarnings("FieldCanBeLocal")
- private ImageView emojiButton1;
- @SuppressWarnings("FieldCanBeLocal")
- private ImageView emojiButton2;
private ImageView expandStickersButton;
private EmojiView emojiView;
private AnimatorSet panelAnimation;
@@ -1777,9 +1810,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
emojiButton[a].setAlpha(0.0f);
emojiButton[a].setScaleX(0.1f);
emojiButton[a].setScaleY(0.1f);
- emojiButton2 = emojiButton[a];
- } else {
- emojiButton1 = emojiButton[a];
}
}
setEmojiButtonImage(false, false);
@@ -2412,6 +2442,527 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
attachButton.setContentDescription(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
}
+ senderSelectView = new SenderSelectView(getContext());
+ senderSelectView.setOnClickListener(v -> {
+ if (getTranslationY() != 0) {
+ onEmojiSearchClosed = () -> senderSelectView.callOnClick();
+ hidePopup(true, true);
+ return;
+ }
+ if (delegate.measureKeyboardHeight() > AndroidUtilities.dp(20)) {
+ int totalHeight = delegate.getContentViewHeight();
+ int keyboard = delegate.measureKeyboardHeight();
+ if (keyboard <= AndroidUtilities.dp(20)) {
+ totalHeight += keyboard;
+ }
+ if (emojiViewVisible) {
+ totalHeight -= getEmojiPadding();
+ }
+
+ if (totalHeight < AndroidUtilities.dp(200)) {
+ onKeyboardClosed = () -> senderSelectView.callOnClick();
+ closeKeyboard();
+ return;
+ }
+ }
+ if (delegate.getSendAsPeers() != null) {
+ if (senderSelectPopupWindow != null) {
+ senderSelectPopupWindow.setPauseNotifications(false);
+ senderSelectPopupWindow.dismiss();
+ return;
+ }
+ MessagesController controller = MessagesController.getInstance(currentAccount);
+ TLRPC.ChatFull chatFull = controller.getChatFull(-dialog_id);
+ if (chatFull == null) {
+ return;
+ }
+
+ List peers = delegate.getSendAsPeers().peers;
+
+ ViewGroup fl = parentFragment.getParentLayout();
+ FrameLayout scrimPopupContainerLayout = new FrameLayout(getContext()) {
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && senderSelectPopupWindow != null && senderSelectPopupWindow.isShowing()) {
+ senderSelectPopupWindow.dismiss();
+ }
+ return super.dispatchKeyEvent(event);
+ }
+ };
+ scrimPopupContainerLayout.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
+ Drawable shadowDrawable2 = ContextCompat.getDrawable(getContext(), R.drawable.popup_fixed_alert).mutate();
+ shadowDrawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), PorterDuff.Mode.MULTIPLY));
+ scrimPopupContainerLayout.setBackground(shadowDrawable2);
+
+ View dim = new View(getContext());
+ dim.setBackgroundColor(0x33000000);
+
+ int maxHeight = AndroidUtilities.dp(450);
+ LinearLayout rc = new LinearLayout(getContext()) {
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.min(MeasureSpec.getSize(heightMeasureSpec), maxHeight), MeasureSpec.getMode(heightMeasureSpec)));
+ }
+ };
+ rc.setOrientation(LinearLayout.VERTICAL);
+ TextView headerText = new TextView(parent.getContext());
+ headerText.setTextColor(Theme.getColor(Theme.key_dialogTextBlue));
+ headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ headerText.setText(LocaleController.getString("SendMessageAsTitle", R.string.SendMessageAsTitle));
+ headerText.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"), Typeface.BOLD);
+ int dp = AndroidUtilities.dp(18);
+ headerText.setPadding(dp, AndroidUtilities.dp(13), dp, AndroidUtilities.dp(13));
+ rc.addView(headerText);
+
+ View shadow = new View(getContext());
+ shadow.setAlpha(0);
+ FrameLayout rfl = new FrameLayout(getContext());
+ RecyclerListView rv = new RecyclerListView(getContext());
+ LinearLayoutManager llm = new LinearLayoutManager(getContext());
+ AtomicReference animatorUpdateListenerRef = new AtomicReference<>();
+ AtomicReference animatorListenerRef = new AtomicReference<>();
+ AtomicReference animatorForSetRef = new AtomicReference<>();
+ rv.setLayoutManager(llm);
+ rv.setAdapter(new RecyclerListView.SelectionAdapter() {
+ @Override
+ public boolean isEnabled(RecyclerView.ViewHolder holder) {
+ return true;
+ }
+
+ final Object avatar = new Object(), title = new Object(), subtitle = new Object();
+
+
+ @NonNull
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ FrameLayout fl = new FrameLayout(parent.getContext());
+ LinearLayout ll = new LinearLayout(parent.getContext());
+ ll.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ ll.setOrientation(LinearLayout.HORIZONTAL);
+ ll.setGravity(Gravity.CENTER_VERTICAL);
+ int dp = AndroidUtilities.dp(14);
+ ll.setPadding(dp, dp / 2, dp, dp / 2);
+
+ SimpleAvatarView avatar = new SimpleAvatarView(parent.getContext());
+ avatar.setTag(this.avatar);
+ ll.addView(avatar, LayoutHelper.createLinear(44, 44));
+
+ LinearLayout ll2 = new LinearLayout(ll.getContext());
+ ll2.setOrientation(LinearLayout.VERTICAL);
+
+ TextView title = new TextView(parent.getContext());
+ title.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
+ title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+ title.setTag(this.title);
+ title.setMaxLines(1);
+ title.setEllipsize(TextUtils.TruncateAt.END);
+ ll2.addView(title);
+
+ TextView subtitle = new TextView(parent.getContext());
+ subtitle.setTextColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), 0x66));
+ subtitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ subtitle.setTag(this.subtitle);
+ subtitle.setMaxLines(1);
+ subtitle.setEllipsize(TextUtils.TruncateAt.END);
+ ll2.addView(subtitle);
+
+ ll.addView(ll2, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1f, 12, 0, 0, 0));
+
+ View v = new View(parent.getContext());
+ fl.addView(ll);
+ fl.addView(v);
+
+ return new RecyclerListView.Holder(fl);
+ }
+
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ TLRPC.Peer peer = peers.get(position);
+ long peerId = 0;
+
+ if (peer.channel_id != 0) {
+ peerId = -peer.channel_id;
+ }
+ if (peerId == 0 && peer.user_id != 0) {
+ peerId = peer.user_id;
+ }
+
+ SimpleAvatarView avatar = holder.itemView.findViewWithTag(this.avatar);
+ TextView title = holder.itemView.findViewWithTag(this.title);
+ TextView subtitle = holder.itemView.findViewWithTag(this.subtitle);
+
+ if (peerId < 0) {
+ TLRPC.Chat chat = controller.getChat(-peerId);
+ if (chat != null) {
+ title.setText(chat.title);
+ subtitle.setText(LocaleController.formatPluralString(ChatObject.isChannel(chat) && !chat.megagroup ? "Subscribers" : "Members", chat.participants_count));
+ avatar.setAvatar(chat);
+ }
+ avatar.setSelected(chatFull.default_send_as != null && chatFull.default_send_as.channel_id == peer.channel_id, false);
+ } else {
+ TLRPC.User user = controller.getUser(peerId);
+ if (user != null) {
+ title.setText(user.first_name + (user.last_name != null ? " " + user.last_name : ""));
+ subtitle.setText(LocaleController.getString("VoipGroupPersonalAccount", R.string.VoipGroupPersonalAccount));
+ avatar.setAvatar(user);
+ }
+ avatar.setSelected(chatFull.default_send_as != null && chatFull.default_send_as.user_id == peer.user_id, false);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return peers.size();
+ }
+ });
+ rv.setOnItemClickListener((view, position) -> {
+ if (senderSelectPopupWindow == null)
+ return;
+ TLRPC.Peer peer = peers.get(position);
+ if (chatFull != null) {
+ chatFull.default_send_as = peer;
+ updateSendAsButton();
+ }
+
+ parentFragment.getMessagesController().setDefaultSendAs(dialog_id, peer.user_id != 0 ? peer.user_id : -peer.channel_id);
+
+ int[] loc = new int[2];
+ SimpleAvatarView sAvatar = (SimpleAvatarView) ((ViewGroup)((ViewGroup) view).getChildAt(0)).getChildAt(0);
+ boolean wasSelected = sAvatar.isSelected();
+ sAvatar.getLocationInWindow(loc);
+ sAvatar.setSelected(true, true);
+
+ SimpleAvatarView avatar = new SimpleAvatarView(getContext());
+ if (peer.channel_id != 0) {
+ TLRPC.Chat chat = controller.getChat(peer.channel_id);
+ if (chat != null) {
+ avatar.setAvatar(chat);
+ }
+ } else if (peer.user_id != 0) {
+ TLRPC.User user = controller.getUser(peer.user_id);
+ if (user != null) {
+ avatar.setAvatar(user);
+ }
+ }
+ for (int i = 0; i < rv.getChildCount(); i++) {
+ View ch = rv.getChildAt(i);
+ if (i != position) {
+ ((SimpleAvatarView) ((ViewGroup)((ViewGroup) ch).getChildAt(0)).getChildAt(0)).setSelected(false, true);
+ }
+ }
+
+ Dialog d = new Dialog(getContext(), R.style.TransparentDialogNoAnimation);
+ FrameLayout aFrame = new FrameLayout(getContext());
+ aFrame.addView(avatar, LayoutHelper.createFrame(44, 44, Gravity.LEFT));
+ d.setContentView(aFrame);
+ d.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
+ d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
+ d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
+ d.getWindow().getAttributes().windowAnimations = 0;
+ d.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
+ d.getWindow().setStatusBarColor(0);
+ d.getWindow().setNavigationBarColor(0);
+
+ int color = Theme.getColor(Theme.key_actionBarDefault, null, true);
+ AndroidUtilities.setLightStatusBar(d.getWindow(), color == Color.WHITE);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ int color2 = Theme.getColor(Theme.key_windowBackgroundGray, null, true);
+ float brightness = AndroidUtilities.computePerceivedBrightness(color2);
+ AndroidUtilities.setLightNavigationBar(d.getWindow(), brightness >= 0.721f);
+ }
+ }
+ float offX = 0, offY = 0;
+ if (AndroidUtilities.isTablet()) {
+ parentFragment.getFragmentView().getLocationInWindow(location);
+ popupX += location[0];
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ WindowInsets wi = getRootWindowInsets();
+ popupX += wi.getSystemWindowInsetLeft();
+ }
+
+ senderSelectView.getLocationInWindow(location);
+ float eX = location[0], eY = location[1];
+
+ float off = wasSelected ? AndroidUtilities.dp(5) : 0;
+ float sX = loc[0] + popupX + off + AndroidUtilities.dp(4) + offX, sY = loc[1] + popupY + off + offY;
+ avatar.setTranslationX(sX);
+ avatar.setTranslationY(sY);
+
+ float sSc = wasSelected ? 34f / 44f : 1, eSc = senderSelectView.getLayoutParams().width / (float)AndroidUtilities.dp(44);
+ avatar.setPivotX(0);
+ avatar.setPivotY(0);
+ avatar.setScaleX(sSc);
+ avatar.setScaleY(sSc);
+
+ animatorListenerRef.set(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ avatar.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
+ @Override
+ public void onDraw() {
+ avatar.post(()->{
+ avatar.getViewTreeObserver().removeOnDrawListener(this);
+ sAvatar.setHideAvatar(true);
+ });
+ }
+ });
+ d.show();
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ senderSelectView.setProgress(0, false);
+ senderSelectView.setScaleX(1);
+ senderSelectView.setScaleY(1);
+ senderSelectView.setAlpha(1);
+ senderSelectView.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
+ @Override
+ public void onDraw() {
+ senderSelectView.post(()->{
+ senderSelectView.getViewTreeObserver().removeOnDrawListener(this);
+ d.dismiss();
+ });
+ }
+ });
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ onAnimationEnd(animation);
+ }
+ });
+ animatorUpdateListenerRef.set(animation -> {
+ float f = (float) animation.getAnimatedValue();
+
+ float selSc = 0.5f + f * 0.5f;
+ senderSelectView.setScaleX(selSc);
+ senderSelectView.setScaleY(selSc);
+ senderSelectView.setAlpha(f);
+ });
+ ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(350);
+ float pos = (rv.getY() + rv.getMeasuredHeight() - loc[1]) / (float)AndroidUtilities.dp(58);
+ float mAmplitude = 0.18f - pos * 0.009f,
+ mFrequency = 5.7f - pos * 0.325f;
+ anim.setInterpolator(time -> (float) (-1 * Math.pow(Math.E, -time / mAmplitude) *
+ Math.cos(mFrequency * time) + 1));
+ anim.addUpdateListener(animation -> {
+ float val = (float) animation.getAnimatedValue();
+ avatar.setTranslationX(sX + (eX - sX) * val);
+ avatar.setTranslationY(sY + (eY - sY) * val);
+ float sc = sSc + (eSc - sSc) * val;
+ avatar.setScaleX(sc);
+ avatar.setScaleY(sc);
+ });
+ animatorForSetRef.set(anim);
+
+ senderSelectPopupWindow.dismiss();
+ });
+ int shadowDuration = 150;
+ rv.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ Boolean isVisible;
+
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ boolean v = llm.findFirstCompletelyVisibleItemPosition() == 0;
+ if (isVisible == null || v != isVisible) {
+ shadow.animate().cancel();
+ if (v) {
+ shadow.animate().alpha(0).setDuration(shadowDuration).start();
+ } else {
+ shadow.animate().alpha(1).setDuration(shadowDuration).start();
+ }
+ isVisible = v;
+ }
+ }
+ });
+ rv.setOverScrollMode(OVER_SCROLL_NEVER);
+ rfl.addView(rv);
+
+ Drawable d = Theme.getThemedDrawable(getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
+ shadow.setBackground(d);
+ rfl.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 4));
+
+ rc.addView(rfl, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ scrimPopupContainerLayout.addView(rc);
+
+ senderSelectPopupWindow = new ActionBarPopupWindow(scrimPopupContainerLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
+ private void dismissSuper() {
+ super.dismiss();
+ }
+
+ @Override
+ public void dismiss() {
+ if (senderSelectPopupWindow != this) {
+ fl.removeView(dim);
+ super.dismiss();
+ return;
+ }
+
+ float scStart = 0.25f;
+
+ scrimPopupContainerLayout.setPivotX(AndroidUtilities.dp(8));
+ scrimPopupContainerLayout.setPivotY(scrimPopupContainerLayout.getMeasuredHeight() - AndroidUtilities.dp(8));
+ rc.setPivotX(0);
+ rc.setPivotY(0);
+
+ scrimPopupContainerLayout.setScaleX(1);
+ scrimPopupContainerLayout.setScaleY(1);
+ rc.setAlpha(1);
+
+ dim.setAlpha(1);
+ AnimatorSet animatorSet = new AnimatorSet();
+ ValueAnimator anim = ValueAnimator.ofFloat(1, 0).setDuration(220);
+ anim.setInterpolator(CubicBezierInterpolator.EASE_OUT);
+ anim.addUpdateListener(animation -> {
+ float val = (float) animation.getAnimatedValue();
+ float sc = scStart + (1f - scStart) * val;
+ scrimPopupContainerLayout.setScaleX(sc);
+ scrimPopupContainerLayout.setScaleY(sc);
+ scrimPopupContainerLayout.setAlpha(val);
+ rc.setScaleX(1f / sc);
+ rc.setScaleY(1f / sc);
+ rc.setAlpha(sc);
+
+ dim.setAlpha(val);
+ });
+ animatorSet.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ fl.removeView(dim);
+ dismissSuper();
+ }
+ });
+
+ ValueAnimator anim2 = ValueAnimator.ofFloat(1, 0).setDuration(350);
+ anim2.setInterpolator(Easings.easeOutSine);
+ ValueAnimator.AnimatorUpdateListener l = animatorUpdateListenerRef.get();
+ if (l != null) {
+ anim2.addUpdateListener(l);
+ }
+ Animator.AnimatorListener l2 = animatorListenerRef.get();
+ if (l2 != null) {
+ anim2.addListener(l2);
+ }
+
+ animatorSet.playTogether(anim, anim2);
+
+ senderSelectPopupWindow = null;
+ if (l == null && l2 == null) senderSelectView.setProgress(0);
+
+ Animator secAnim = animatorForSetRef.get();
+ if (secAnim != null) {
+ animatorSet.playTogether(secAnim);
+ }
+ animatorSet.start();
+ }
+ };
+ senderSelectPopupWindow.setPauseNotifications(true);
+ senderSelectPopupWindow.setDismissAnimationDuration(220);
+ senderSelectPopupWindow.setOutsideTouchable(true);
+ senderSelectPopupWindow.setClippingEnabled(true);
+ senderSelectPopupWindow.setFocusable(true);
+ scrimPopupContainerLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
+ senderSelectPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
+ senderSelectPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
+ senderSelectPopupWindow.getContentView().setFocusableInTouchMode(true);
+ senderSelectPopupWindow.setAnimationEnabled(false);
+
+ TLRPC.Peer defPeer = chatFull.default_send_as != null ? chatFull.default_send_as : null;
+ if (defPeer != null) {
+ int itemHeight = AndroidUtilities.dp(14 + 44);
+ int totalRecyclerHeight = peers.size() * itemHeight;
+ for (int i = 0; i < peers.size(); i++) {
+ TLRPC.Peer p = peers.get(i);
+ if (p.channel_id != 0 && p.channel_id == defPeer.channel_id || p.user_id != 0 && p.user_id == defPeer.user_id ||
+ p.chat_id != 0 && p.chat_id == defPeer.chat_id) {
+ int off = 0;
+ if (i != peers.size() - 1 && rv.getMeasuredHeight() < totalRecyclerHeight) {
+ off = rv.getMeasuredHeight() % itemHeight;
+ }
+
+ llm.scrollToPositionWithOffset(i, off + AndroidUtilities.dp(7) + (totalRecyclerHeight - (peers.size() - 2) * itemHeight));
+ if (rv.computeVerticalScrollOffset() > 0) {
+ shadow.animate().cancel();
+ shadow.animate().alpha(1).setDuration(shadowDuration).start();
+ }
+ break;
+ }
+ }
+ }
+
+ int pad = -AndroidUtilities.dp(4);
+ int[] location = new int[2];
+ int popupX = pad;
+ if (AndroidUtilities.isTablet()) {
+ parentFragment.getFragmentView().getLocationInWindow(location);
+ popupX += location[0];
+ }
+ int totalHeight = delegate.getContentViewHeight();
+ int height = scrimPopupContainerLayout.getMeasuredHeight();
+ int keyboard = delegate.measureKeyboardHeight();
+ if (keyboard <= AndroidUtilities.dp(20)) {
+ totalHeight += keyboard;
+ }
+ if (emojiViewVisible) {
+ totalHeight -= getEmojiPadding();
+ }
+
+ int shadowPad = AndroidUtilities.dp(1);
+ int popupY;
+ if (height < totalHeight + pad * 2 - (parentFragment.isInBubbleMode() ? 0 : AndroidUtilities.statusBarHeight) - headerText.getMeasuredHeight()) {
+ ChatActivityEnterView.this.getLocationInWindow(location);
+ popupY = location[1] - height - pad - AndroidUtilities.dp(2);
+ fl.addView(dim, new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, popupY + pad + height + shadowPad + AndroidUtilities.dp(2)));
+ } else {
+ popupY = parentFragment.isInBubbleMode() ? 0 : AndroidUtilities.statusBarHeight;
+ int off = AndroidUtilities.dp(14);
+ rc.getLayoutParams().height = totalHeight - popupY - off - getHeightWithTopView();
+ fl.addView(dim, new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, off + popupY + rc.getLayoutParams().height + shadowPad));
+ }
+
+ float scStart = 0.25f;
+
+ scrimPopupContainerLayout.setPivotX(AndroidUtilities.dp(8));
+ scrimPopupContainerLayout.setPivotY(scrimPopupContainerLayout.getMeasuredHeight() - AndroidUtilities.dp(8));
+ rc.setPivotX(0);
+ rc.setPivotY(0);
+
+ scrimPopupContainerLayout.setScaleX(scStart);
+ scrimPopupContainerLayout.setScaleY(scStart);
+ rc.setAlpha(scStart);
+
+ dim.setAlpha(0);
+
+ ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(220);
+ anim.setInterpolator(CubicBezierInterpolator.EASE_OUT);
+ anim.addUpdateListener(animation -> {
+ float val = (float) animation.getAnimatedValue();
+ float sc = scStart + (1f - scStart) * val;
+ scrimPopupContainerLayout.setScaleX(sc);
+ scrimPopupContainerLayout.setScaleY(sc);
+ rc.setScaleX(1f / sc);
+ rc.setScaleY(1f / sc);
+ rc.setAlpha(sc);
+
+ dim.setAlpha(val);
+ });
+ anim.start();
+
+ senderSelectPopupWindow.showAtLocation(v, Gravity.LEFT | Gravity.TOP, this.popupX = popupX, this.popupY = popupY);
+ senderSelectView.setProgress(1);
+ }
+ });
+ senderSelectView.setVisibility(GONE);
+ frameLayout.addView(senderSelectView, LayoutHelper.createFrame(32, 32, Gravity.BOTTOM | Gravity.LEFT, 10, 8, 10, 8));
+
recordedAudioPanel = new FrameLayout(context);
recordedAudioPanel.setVisibility(audioToSend == null ? GONE : VISIBLE);
recordedAudioPanel.setFocusable(true);
@@ -3585,6 +4136,13 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return topView != null && topView.getVisibility() == VISIBLE;
}
+ public void onAdjustPanTransitionEnd() {
+ if (onKeyboardClosed != null) {
+ onKeyboardClosed.run();
+ onKeyboardClosed = null;
+ }
+ }
+
public void onAdjustPanTransitionStart(boolean keyboardVisible) {
if (keyboardVisible && showTopViewRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(showTopViewRunnable);
@@ -3682,6 +4240,10 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (sizeNotifierLayout != null) {
sizeNotifierLayout.setDelegate(null);
}
+ if (senderSelectPopupWindow != null) {
+ senderSelectPopupWindow.setPauseNotifications(false);
+ senderSelectPopupWindow.dismiss();
+ }
}
public void checkChannelRights() {
@@ -3704,10 +4266,23 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (senderSelectPopupWindow != null){
+ senderSelectPopupWindow.setPauseNotifications(false);
+ senderSelectPopupWindow.dismiss();
+ }
+ }
+
private Runnable hideKeyboardRunnable;
public void onPause() {
isPaused = true;
+ if (senderSelectPopupWindow != null) {
+ senderSelectPopupWindow.setPauseNotifications(false);
+ senderSelectPopupWindow.dismiss();
+ }
if (keyboardVisible) {
showKeyboardOnResume = true;
}
@@ -3781,6 +4356,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
updateScheduleButton(false);
checkRoundVideo();
updateFieldHint(false);
+ updateSendAsButton();
}
public void setChatInfo(TLRPC.ChatFull chatInfo) {
@@ -3832,7 +4408,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
return hasRecordVideo;
}
- private void updateFieldHint(boolean animated) {
+ public void updateFieldHint(boolean animated) {
if (replyingMessageObject != null && replyingMessageObject.messageOwner.reply_markup != null && !TextUtils.isEmpty(replyingMessageObject.messageOwner.reply_markup.placeholder)) {
messageEditText.setHintText(replyingMessageObject.messageOwner.reply_markup.placeholder, animated);
} else if (editingMessageObject != null) {
@@ -3844,8 +4420,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
boolean anonymously = false;
if (DialogObject.isChatDialog(dialog_id)) {
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-dialog_id);
+ TLRPC.ChatFull chatFull = accountInstance.getMessagesController().getChatFull(-dialog_id);
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
- anonymously = ChatObject.shouldSendAnonymously(chat);
+ anonymously = ChatObject.getSendAsPeerId(chat, chatFull) == chat.id;
}
if (anonymously) {
messageEditText.setHintText(LocaleController.getString("SendAnonymously", R.string.SendAnonymously));
@@ -4082,6 +4659,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
messageEditText.setAlpha(1f);
messageEditText.setTranslationX(0);
messageEditText.requestFocus();
+ updateSendAsButton();
}
});
@@ -5678,6 +6256,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
slideText.setCancelToProgress(0f);
delegate.onAudioVideoInterfaceUpdated();
+ updateSendAsButton();
}
}
});
@@ -5685,6 +6264,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
recordTimerView.stop();
}
delegate.onAudioVideoInterfaceUpdated();
+ updateSendAsButton();
}
@Override
@@ -5926,6 +6506,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
updateFieldRight(1);
}
updateFieldHint(false);
+ updateSendAsButton();
}
public ImageView getAttachButton() {
@@ -5949,9 +6530,6 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
public void updateColors() {
- if (emojiView != null) {
- emojiView.updateColors();
- }
if (sendPopupLayout != null) {
for (int a = 0, count = sendPopupLayout.getChildCount(); a < count; a++) {
final View view = sendPopupLayout.getChildAt(a);
@@ -5992,7 +6570,11 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
for (int i = 0; i < 2; ++i) {
emojiButton[i].setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
+ if (Build.VERSION.SDK_INT >= 21) {
+ emojiButton[i].setBackgroundDrawable(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector)));
+ }
}
+
}
private void updateRecordedDeleteIconColors() {
@@ -6215,6 +6797,108 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
}
+ public void updateSendAsButton() {
+ if (parentFragment == null) {
+ return;
+ }
+ TLRPC.ChatFull full = parentFragment.getMessagesController().getChatFull(-dialog_id);
+ TLRPC.Peer defPeer = full != null ? full.default_send_as : null;
+ if (defPeer == null && delegate.getSendAsPeers() != null && !delegate.getSendAsPeers().peers.isEmpty()) {
+ defPeer = delegate.getSendAsPeers().peers.get(0);
+ }
+ if (defPeer != null) {
+ if (defPeer.channel_id != 0) {
+ TLRPC.Chat ch = MessagesController.getInstance(currentAccount).getChat(defPeer.channel_id);
+ if (ch != null) senderSelectView.setAvatar(ch);
+ } else {
+ TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(defPeer.user_id);
+ if (user != null) senderSelectView.setAvatar(user);
+ }
+ }
+ 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);
+ int pad = AndroidUtilities.dp(2);
+ MarginLayoutParams params = (MarginLayoutParams) senderSelectView.getLayoutParams();
+ float sA = isVisible ? 0 : 1;
+ float sX = isVisible ? -senderSelectView.getLayoutParams().width - params.leftMargin - pad : 0;
+ float eA = isVisible ? 1 : 0;
+ float eX = isVisible ? 0 : -senderSelectView.getLayoutParams().width - params.leftMargin - pad;
+
+ if (wasVisible != isVisible) {
+ ValueAnimator a = (ValueAnimator) senderSelectView.getTag();
+ if (a != null) {
+ a.cancel();
+ senderSelectView.setTag(null);
+ }
+
+ if (parentFragment.getOtherSameChatsDiff() == 0 && parentFragment.fragmentOpened) {
+ ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(220);
+ anim.setInterpolator(CubicBezierInterpolator.DEFAULT);
+ anim.addUpdateListener(animation -> {
+ float val = (float) animation.getAnimatedValue();
+
+ senderSelectView.setAlpha(sA + (eA - sA) * val);
+ senderSelectView.setTranslationX(sX + (eX - sX) * val);
+ for (ImageView emoji : emojiButton)
+ emoji.setTranslationX(senderSelectView.getTranslationX());
+ messageEditText.setTranslationX(senderSelectView.getTranslationX());
+ });
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+ if (isVisible)
+ senderSelectView.setVisibility(VISIBLE);
+ senderSelectView.setAlpha(sA);
+ senderSelectView.setTranslationX(sX);
+ for (ImageView emoji : emojiButton)
+ emoji.setTranslationX(senderSelectView.getTranslationX());
+ messageEditText.setTranslationX(senderSelectView.getTranslationX());
+
+ if (botCommandsMenuButton.getTag() == null) {
+ animationParamsX.clear();
+ }
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (!isVisible) {
+ senderSelectView.setVisibility(GONE);
+ for (ImageView emoji : emojiButton)
+ emoji.setTranslationX(0);
+ messageEditText.setTranslationX(0);
+ }
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ if (isVisible) {
+ senderSelectView.setVisibility(VISIBLE);
+ } else {
+ senderSelectView.setVisibility(GONE);
+ }
+ senderSelectView.setAlpha(eA);
+ senderSelectView.setTranslationX(eX);
+ for (ImageView emoji : emojiButton)
+ emoji.setTranslationX(senderSelectView.getTranslationX());
+ messageEditText.setTranslationX(senderSelectView.getTranslationX());
+
+ requestLayout();
+ }
+ });
+ anim.start();
+ senderSelectView.setTag(anim);
+ } else {
+ senderSelectView.setVisibility(isVisible ? VISIBLE : GONE);
+ senderSelectView.setTranslationX(eX);
+ for (ImageView emoji : emojiButton)
+ emoji.setTranslationX(eX);
+ messageEditText.setTranslationX(eX);
+ senderSelectView.setAlpha(eA);
+ senderSelectView.setTag(null);
+ }
+ }
+ }
+
private void updateBotButton(boolean animated) {
if (botButton == null) {
return;
@@ -7160,12 +7844,16 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
}
public void hidePopup(boolean byBackButton) {
+ hidePopup(byBackButton, false);
+ }
+
+ public void hidePopup(boolean byBackButton, boolean forceAnimate) {
if (isPopupShowing()) {
if (currentPopupContentType == 1 && byBackButton && botButtonsMessageObject != null) {
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
preferences.edit().putInt("hidekeyboard_" + dialog_id, botButtonsMessageObject.getId()).commit();
}
- if (byBackButton && searchingType != 0) {
+ if (byBackButton && searchingType != 0 || forceAnimate) {
setSearchingTypeInternal(0, true);
if (emojiView != null) {
emojiView.closeSearch(true);
@@ -7804,6 +8492,10 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (keyboardVisible && isPopupShowing()) {
showPopup(0, currentPopupContentType);
}
+ if (onEmojiSearchClosed != null) {
+ onEmojiSearchClosed.run();
+ onEmojiSearchClosed = null;
+ }
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
}
});
@@ -8406,6 +9098,12 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
((MarginLayoutParams) emojiButton[i].getLayoutParams()).leftMargin = AndroidUtilities.dp(10) + botCommandsMenuButton.getMeasuredWidth();
}
((MarginLayoutParams) messageEditText.getLayoutParams()).leftMargin = AndroidUtilities.dp(57) + botCommandsMenuButton.getMeasuredWidth();
+ } else if (senderSelectView != null && senderSelectView.getVisibility() == View.VISIBLE) {
+ senderSelectView.measure(widthMeasureSpec, heightMeasureSpec);
+ for (int i = 0; i < emojiButton.length; i++) {
+ ((MarginLayoutParams) emojiButton[i].getLayoutParams()).leftMargin = AndroidUtilities.dp(16) + senderSelectView.getLayoutParams().width;
+ }
+ ((MarginLayoutParams) messageEditText.getLayoutParams()).leftMargin = AndroidUtilities.dp(63) + senderSelectView.getLayoutParams().width;
} else {
for (int i = 0; i < emojiButton.length; i++) {
((MarginLayoutParams) emojiButton[i].getLayoutParams()).leftMargin = AndroidUtilities.dp(3);
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 da3dd4329..6c6f4bdcf 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertDocumentLayout.java
@@ -13,14 +13,20 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
+import android.app.Application;
+import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
+import android.os.storage.StorageManager;
+import android.provider.Settings;
import android.text.TextUtils;
import android.util.SparseArray;
import android.view.Gravity;
@@ -29,10 +35,12 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.EditText;
import android.widget.FrameLayout;
+import android.widget.TextView;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
+import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
@@ -57,6 +65,7 @@ import org.telegram.ui.Cells.GraySectionCell;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.SharedDocumentCell;
+import org.telegram.ui.Cells.TextCheckBoxCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.FilteredSearchView;
import org.telegram.ui.PhotoPickerActivity;
@@ -327,10 +336,40 @@ public class ChatAttachAlertDocumentLayout extends ChatAttachAlert.AttachAlertLa
ListItem item = (ListItem) object;
File file = item.file;
boolean isExternalStorageManager = false;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
- isExternalStorageManager = Environment.isExternalStorageManager();
- }
- if (file == null) {
+// 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) {
+ delegate.startDocumentSelectActivity();
+ /*} 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)));
+
+ TextCheckBoxCell textCheckBoxCell = new TextCheckBoxCell(context, true, true);
+ textCheckBoxCell.setTextAndCheck(LocaleController.getString("DontAskAgain", R.string.DontAskAgain), false, false);
+ textCheckBoxCell.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ textCheckBoxCell.setChecked(!textCheckBoxCell.isChecked());
+ }
+ });
+ builder.setView(textCheckBoxCell);
+
+ builder.setPositiveButton(LocaleController.getString("Allow", R.string.Allow), (i1, i2) -> {
+ Uri uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID);
+ context.startActivity(new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri));
+ });
+ builder.setNegativeButton(LocaleController.getString("UseFileManger", R.string.UseFileManger), (i1, i2) -> {
+ if (textCheckBoxCell.isChecked()) {
+ SharedConfig.setDontAskManageStorage(true);
+ }
+ delegate.startDocumentSelectActivity();
+ });
+ builder.show();
+ }*/
+ } else if (file == null) {
if (item.icon == R.drawable.files_gallery) {
HashMap