diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle
index bd6343f3b..e03a85d66 100644
--- a/TMessagesProj/build.gradle
+++ b/TMessagesProj/build.gradle
@@ -82,7 +82,7 @@ android {
defaultConfig {
minSdkVersion 19
- targetSdkVersion 31
+ targetSdkVersion 33
versionName "8.9.0"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
diff --git a/TMessagesProj/config/debug/AndroidManifest.xml b/TMessagesProj/config/debug/AndroidManifest.xml
index b7f49c6f5..7d6dc8b3c 100644
--- a/TMessagesProj/config/debug/AndroidManifest.xml
+++ b/TMessagesProj/config/debug/AndroidManifest.xml
@@ -13,6 +13,7 @@
+
diff --git a/TMessagesProj/config/debug/AndroidManifest_SDK23.xml b/TMessagesProj/config/debug/AndroidManifest_SDK23.xml
index f6464b533..5c958dc8b 100644
--- a/TMessagesProj/config/debug/AndroidManifest_SDK23.xml
+++ b/TMessagesProj/config/debug/AndroidManifest_SDK23.xml
@@ -13,6 +13,7 @@
+
diff --git a/TMessagesProj/config/release/AndroidManifest.xml b/TMessagesProj/config/release/AndroidManifest.xml
index 457658f4a..a6281473a 100644
--- a/TMessagesProj/config/release/AndroidManifest.xml
+++ b/TMessagesProj/config/release/AndroidManifest.xml
@@ -13,6 +13,7 @@
+
diff --git a/TMessagesProj/config/release/AndroidManifest_SDK23.xml b/TMessagesProj/config/release/AndroidManifest_SDK23.xml
index f52960f1e..9cab3db1c 100644
--- a/TMessagesProj/config/release/AndroidManifest_SDK23.xml
+++ b/TMessagesProj/config/release/AndroidManifest_SDK23.xml
@@ -13,6 +13,7 @@
+
diff --git a/TMessagesProj/config/release/AndroidManifest_standalone.xml b/TMessagesProj/config/release/AndroidManifest_standalone.xml
index 66638636e..344cba957 100644
--- a/TMessagesProj/config/release/AndroidManifest_standalone.xml
+++ b/TMessagesProj/config/release/AndroidManifest_standalone.xml
@@ -13,6 +13,7 @@
+
diff --git a/TMessagesProj/jni/gifvideo.cpp b/TMessagesProj/jni/gifvideo.cpp
index b5a460b49..68ef0738e 100644
--- a/TMessagesProj/jni/gifvideo.cpp
+++ b/TMessagesProj/jni/gifvideo.cpp
@@ -122,7 +122,7 @@ typedef struct VideoInfo {
} else {
attached = false;
}
- DEBUG_DELREF("gifvideocpp stream");
+ DEBUG_DELREF("gifvideo.cpp stream");
jniEnv->DeleteGlobalRef(stream);
if (attached) {
javaVm->DetachCurrentThread();
diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp
index dff83fdbf..e6716b5b0 100644
--- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp
+++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp
@@ -3057,7 +3057,7 @@ void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround, bool
if ((!workaround && !updatingDcSettings) || (workaround && !updatingDcSettingsWorkaround)) {
return;
}
- if (!workaround && updatingDcSettingsAgain) {
+ if (!workaround && updatingDcSettingsAgain && updatingDcSettingsAgainDcNum == dcNum) {
updatingDcSettingsAgain = false;
for (auto & datacenter : datacenters) {
datacenter.second->resetInitVersion();
diff --git a/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp b/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp
index b2bb47369..11b9cf935 100644
--- a/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp
+++ b/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp
@@ -924,7 +924,7 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_onStreamP
return;
}
auto context = (AndroidContext *) instance->_platformContext.get();
- std::shared_ptr task;
+ std::shared_ptr task = nullptr;
auto q = (VideoChannelDescription::Quality) quality;
if (videoChannel != 0) {
for (auto videoTaskIter = context->videoStreamTasks.begin(); videoTaskIter != context->videoStreamTasks.end(); videoTaskIter++) {
diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index 755fed8aa..12ff1899e 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -30,6 +30,9 @@
+
+
+
@@ -53,6 +56,7 @@
+
diff --git a/TMessagesProj/src/main/java/com/google/android/exoplayer2/util/Util.java b/TMessagesProj/src/main/java/com/google/android/exoplayer2/util/Util.java
index ed042272a..89242e5e9 100644
--- a/TMessagesProj/src/main/java/com/google/android/exoplayer2/util/Util.java
+++ b/TMessagesProj/src/main/java/com/google/android/exoplayer2/util/Util.java
@@ -97,6 +97,7 @@ import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayDeque;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
@@ -2844,13 +2845,31 @@ public final class Util {
@RequiresApi(api = Build.VERSION_CODES.M)
private static boolean requestExternalStoragePermission(Activity activity) {
- if (activity.checkSelfPermission(permission.READ_EXTERNAL_STORAGE)
- != PackageManager.PERMISSION_GRANTED) {
- activity.requestPermissions(
- new String[] {permission.READ_EXTERNAL_STORAGE}, /* requestCode= */ 0);
- return true;
+ if (Build.VERSION.SDK_INT >= 33) {
+ ArrayList permissions = new ArrayList<>();
+ if (activity.checkSelfPermission(permission.READ_MEDIA_VIDEO) != PackageManager.PERMISSION_GRANTED) {
+ permissions.add(permission.READ_MEDIA_VIDEO);
+ }
+ if (activity.checkSelfPermission(permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED) {
+ permissions.add(permission.READ_MEDIA_IMAGES);
+ }
+ if (activity.checkSelfPermission(permission.READ_MEDIA_AUDIO) != PackageManager.PERMISSION_GRANTED) {
+ permissions.add(permission.READ_MEDIA_AUDIO);
+ }
+ if (!permissions.isEmpty()) {
+ activity.requestPermissions(permissions.toArray(new String[0]), /* requestCode= */ 0);
+ return true;
+ }
+ return false;
+ } else {
+ if (activity.checkSelfPermission(permission.READ_EXTERNAL_STORAGE)
+ != PackageManager.PERMISSION_GRANTED) {
+ activity.requestPermissions(
+ new String[]{permission.READ_EXTERNAL_STORAGE}, /* requestCode= */ 0);
+ return true;
+ }
+ return false;
}
- return false;
}
@RequiresApi(api = Build.VERSION_CODES.N)
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
index 2a9849f91..c7f31914a 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
@@ -8,6 +8,7 @@
package org.telegram.messenger;
+import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
@@ -112,6 +113,7 @@ import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils;
+import androidx.core.widget.NestedScrollView;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
@@ -157,6 +159,8 @@ import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.Components.URLSpanReplacement;
import org.telegram.ui.Components.UndoView;
import org.telegram.ui.LaunchActivity;
+import org.telegram.ui.Stories.PeerStoriesView;
+import org.telegram.ui.Stories.StoryMediaAreasView;
import org.telegram.ui.ThemePreviewActivity;
import org.telegram.ui.WallpapersListActivity;
@@ -454,6 +458,10 @@ public class AndroidUtilities {
}
public static SpannableStringBuilder replaceSingleTag(String str, int colorKey, int type, Runnable runnable) {
+ return replaceSingleTag(str, colorKey, type, runnable, null);
+ }
+
+ public static SpannableStringBuilder replaceSingleTag(String str, int colorKey, int type, Runnable runnable, Theme.ResourcesProvider resourcesProvider) {
int startIndex = str.indexOf("**");
int endIndex = str.indexOf("**", startIndex + 1);
str = str.replace("**", "");
@@ -473,7 +481,7 @@ public class AndroidUtilities {
super.updateDrawState(ds);
ds.setUnderlineText(false);
if (colorKey >= 0) {
- ds.setColor(Theme.getColor(colorKey));
+ ds.setColor(Theme.getColor(colorKey, resourcesProvider));
}
}
@@ -490,7 +498,7 @@ public class AndroidUtilities {
public void updateDrawState(TextPaint textPaint) {
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
int wasAlpha = textPaint.getAlpha();
- textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
+ textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText, resourcesProvider));
textPaint.setAlpha(wasAlpha);
}
}, index, index + len, 0);
@@ -573,18 +581,25 @@ public class AndroidUtilities {
}
public static boolean findClickableView(ViewGroup container, float x, float y) {
+ return findClickableView(container, x, y, null);
+ }
+
+ public static boolean findClickableView(ViewGroup container, float x, float y, View onlyThisView) {
if (container == null) {
return false;
}
for (int i = 0; i < container.getChildCount(); i++) {
View child = container.getChildAt(i);
- if (child.getVisibility() != View.VISIBLE) {
+ if (child.getVisibility() != View.VISIBLE || child instanceof PeerStoriesView && child != onlyThisView) {
+ continue;
+ }
+ if (child instanceof StoryMediaAreasView.AreaView && !((StoryMediaAreasView) container).hasSelected() && (x < dp(60) || x > container.getWidth() - dp(60))) {
continue;
}
child.getHitRect(AndroidUtilities.rectTmp2);
if (AndroidUtilities.rectTmp2.contains((int) x, (int) y) && child.isClickable()) {
return true;
- } else if (child instanceof ViewGroup && findClickableView((ViewGroup) child, x - child.getX(), y - child.getY())) {
+ } else if (child instanceof ViewGroup && findClickableView((ViewGroup) child, x - child.getX(), y - child.getY(), onlyThisView)) {
return true;
}
}
@@ -721,6 +736,36 @@ public class AndroidUtilities {
}
}
+ public static float[] getCoordinateInParent(ViewGroup parentView, View view) {
+ float x = 0, y = 0;
+ View child = view;
+ float yOffset = 0;
+ float xOffset = 0;
+ if (child != null && parentView != null) {
+ while (child != parentView) {
+ if (child == null) {
+ xOffset = 0;
+ yOffset = 0;
+ break;
+ }
+ yOffset += child.getY();
+ xOffset += child.getX();
+ if (child instanceof NestedScrollView) {
+ yOffset -= child.getScrollY();
+ xOffset -= child.getScrollX();
+ }
+ if (child.getParent() instanceof View) {
+ child = (View) child.getParent();
+ } else {
+ xOffset = 0;
+ yOffset = 0;
+ break;
+ }
+ }
+ }
+ return new float[] {xOffset, yOffset};
+ }
+
private static class LinkSpec {
String url;
int start;
@@ -2982,7 +3027,17 @@ public class AndroidUtilities {
}
private static File getAlbumDir(boolean secretChat) {
- if (secretChat || !BuildVars.NO_SCOPED_STORAGE || (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)) {
+ if (
+ secretChat ||
+ !BuildVars.NO_SCOPED_STORAGE ||
+ (
+ Build.VERSION.SDK_INT >= 33 &&
+ ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) != PackageManager.PERMISSION_GRANTED
+ ) || (
+ Build.VERSION.SDK_INT >= 23 && Build.VERSION.SDK_INT <= 33 &&
+ ApplicationLoader.applicationContext.checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
+ )
+ ) {
return FileLoader.getDirectory(FileLoader.MEDIA_DIR_IMAGE);
}
File storageDir = null;
@@ -5197,7 +5252,7 @@ public class AndroidUtilities {
}
public static boolean intersect1d(int x1, int x2, int y1, int y2) {
- return Math.max(x1, x2) >= Math.min(y1, y2) && Math.max(y1, y2) >= Math.min(x1, x2);
+ return Math.max(x1, x2) > Math.min(y1, y2) && Math.max(y1, y2) > Math.min(x1, x2);
}
public static String getSysInfoString(String path) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
index 6c9ff9cf5..5eaa3d40b 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java
@@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
- public static int BUILD_VERSION = 3721;
- public static String BUILD_VERSION_STRING = "9.7.6";
+ public static int BUILD_VERSION = 3793;
+ public static String BUILD_VERSION_STRING = "10.0.1";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatMessagesMetadataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatMessagesMetadataController.java
index e847d9222..fc73ae225 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatMessagesMetadataController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatMessagesMetadataController.java
@@ -177,11 +177,11 @@ public class ChatMessagesMetadataController {
public void onFragmentDestroy() {
for (int i = 0; i < reactionsRequests.size(); i++) {
- chatActivity.getConnectionsManager().cancelRequest(reactionsRequests.remove(i), false);
+ chatActivity.getConnectionsManager().cancelRequest(reactionsRequests.get(i), false);
}
reactionsRequests.clear();
for (int i = 0; i < extendedMediaRequests.size(); i++) {
- chatActivity.getConnectionsManager().cancelRequest(extendedMediaRequests.remove(i), false);
+ chatActivity.getConnectionsManager().cancelRequest(extendedMediaRequests.get(i), false);
}
extendedMediaRequests.clear();
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
index 3bfda0b4c..f35882672 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
@@ -2878,6 +2878,11 @@ public class ContactsController extends BaseController {
if (firstName != null) {
firstName = firstName.trim();
}
+ if (firstName != null && lastName == null && maxLength > 0 && firstName.contains(" ") ) {
+ int i = firstName.indexOf(" ");
+ lastName = firstName.substring(i + 1);
+ firstName = firstName.substring(0, i);
+ }
if (lastName != null) {
lastName = lastName.trim();
}
@@ -2885,7 +2890,7 @@ public class ContactsController extends BaseController {
if (LocaleController.nameDisplayOrder == 1) {
if (firstName != null && firstName.length() > 0) {
if (maxLength > 0 && firstName.length() > maxLength + 2) {
- return firstName.substring(0, maxLength);
+ return firstName.substring(0, maxLength) + "…";
}
result.append(firstName);
if (lastName != null && lastName.length() > 0) {
@@ -2898,14 +2903,14 @@ public class ContactsController extends BaseController {
}
} else if (lastName != null && lastName.length() > 0) {
if (maxLength > 0 && lastName.length() > maxLength + 2) {
- return lastName.substring(0, maxLength);
+ return lastName.substring(0, maxLength) + "…";
}
result.append(lastName);
}
} else {
if (lastName != null && lastName.length() > 0) {
if (maxLength > 0 && lastName.length() > maxLength + 2) {
- return lastName.substring(0, maxLength);
+ return lastName.substring(0, maxLength) + "…";
}
result.append(lastName);
if (firstName != null && firstName.length() > 0) {
@@ -2918,7 +2923,7 @@ public class ContactsController extends BaseController {
}
} else if (firstName != null && firstName.length() > 0) {
if (maxLength > 0 && firstName.length() > maxLength + 2) {
- return firstName.substring(0, maxLength);
+ return firstName.substring(0, maxLength) + "…";
}
result.append(firstName);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java
index 5058d08f3..885a008a5 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java
@@ -1326,6 +1326,13 @@ public class DatabaseMigrationHelper {
version = 127;
}
+ if (version == 127) {
+ database.executeFast("ALTER TABLE stories ADD COLUMN custom_params BLOB default NULL").stepThis().dispose();
+
+ database.executeFast("PRAGMA user_version = 128").stepThis().dispose();
+ version = 128;
+ }
+
return version;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java b/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java
index f118c0e92..a08da5ab1 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java
@@ -84,6 +84,15 @@ public class DispatchQueue extends Thread {
return postRunnable(runnable, 0);
}
+ public boolean postToFrontRunnable(Runnable runnable) {
+ try {
+ syncLatch.await();
+ } catch (Exception e) {
+ FileLog.e(e, false);
+ }
+ return handler.postAtFrontOfQueue(runnable);
+ }
+
public boolean postRunnable(Runnable runnable, long delay) {
try {
syncLatch.await();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java
index c09f367f1..e5b7f4b11 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java
@@ -280,18 +280,22 @@ public class FilePathDatabase {
CountDownLatch syncLatch = new CountDownLatch(1);
long time = System.currentTimeMillis();
- postRunnable(() -> {
+ long[] threadTime = new long[1];
+ postToFrontRunnable(() -> {
+ long threadTimeLocal = System.currentTimeMillis();
ensureDatabaseCreated();
try {
for (int i = 0; i < arrayListFinal.size(); i++) {
MessageObject messageObject = arrayListFinal.get(i);
messageObject.checkMediaExistance(false);
}
+ threadTime[0] = System.currentTimeMillis() - threadTimeLocal;
} catch (Throwable e) {
FileLog.e(e);
} finally {
syncLatch.countDown();
}
+
});
try {
@@ -300,7 +304,7 @@ public class FilePathDatabase {
FileLog.e(e);
}
- FileLog.d("checkMediaExistance size=" + messageObjects.size() + " time=" + (System.currentTimeMillis() - time));
+ FileLog.d("checkMediaExistance size=" + messageObjects.size() + " time=" + (System.currentTimeMillis() - time) + " thread_time=" + threadTime[0]);
if (BuildVars.DEBUG_VERSION) {
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
@@ -465,6 +469,11 @@ public class FilePathDatabase {
dispatchQueue.postRunnable(runnable);
}
+ private void postToFrontRunnable(Runnable runnable) {
+ ensureQueueExist();
+ dispatchQueue.postToFrontRunnable(runnable);
+ }
+
private void ensureQueueExist() {
if (dispatchQueue == null) {
synchronized (this) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileStreamLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileStreamLoadOperation.java
index 18f019fc4..f62f59fd2 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FileStreamLoadOperation.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileStreamLoadOperation.java
@@ -146,6 +146,9 @@ public class FileStreamLoadOperation extends BaseDataSource implements FileLoadO
}
File currentFileFast = loadOperation.getCurrentFileFast();
if (file == null || !Objects.equals(currentFile, currentFileFast)) {
+ if (BuildVars.LOGS_ENABLED) {
+ FileLog.d("check stream file " + currentFileFast);
+ }
if (file != null) {
try {
file.close();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java b/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java
index b814b97c6..4ee9d2213 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FilesMigrationService.java
@@ -284,12 +284,25 @@ public class FilesMigrationService extends Service {
public void migrateOldFolder() {
Activity activity = fragment.getParentActivity();
boolean canWrite = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
- boolean canRead = activity.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
+ boolean canRead = (
+ Build.VERSION.SDK_INT >= 33 && (
+ activity.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED &&
+ activity.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED &&
+ activity.checkSelfPermission(Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
+ ) ||
+ Build.VERSION.SDK_INT < 33 && activity.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
+ );
if (!canRead || !canWrite) {
ArrayList permissions = new ArrayList<>();
if (!canRead) {
- permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
+ if (Build.VERSION.SDK_INT >= 33) {
+ permissions.add(Manifest.permission.READ_MEDIA_IMAGES);
+ permissions.add(Manifest.permission.READ_MEDIA_VIDEO);
+ permissions.add(Manifest.permission.READ_MEDIA_AUDIO);
+ } else {
+ permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE);
+ }
}
if (!canWrite) {
permissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java
index 648a6a21a..5f4831780 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java
@@ -120,6 +120,11 @@ public class GoogleMapsProvider implements IMapsProvider {
return googleMap.getMaxZoomLevel();
}
+ @Override
+ public float getMinZoomLevel() {
+ return googleMap.getMinZoomLevel();
+ }
+
@SuppressLint("MissingPermission")
@Override
public void setMyLocationEnabled(boolean enabled) {
@@ -151,6 +156,11 @@ public class GoogleMapsProvider implements IMapsProvider {
});
}
+ @Override
+ public void setOnCameraIdleListener(Runnable callback) {
+ googleMap.setOnCameraIdleListener(callback::run);
+ }
+
@Override
public CameraPosition getCameraPosition() {
com.google.android.gms.maps.model.CameraPosition pos = googleMap.getCameraPosition();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/IMapsProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/IMapsProvider.java
index 0034510b0..75db0a089 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/IMapsProvider.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/IMapsProvider.java
@@ -37,8 +37,10 @@ public interface IMapsProvider {
void animateCamera(ICameraUpdate update, int duration, ICancelableCallback callback);
void moveCamera(ICameraUpdate update);
float getMaxZoomLevel();
+ float getMinZoomLevel();
void setMyLocationEnabled(boolean enabled);
IUISettings getUiSettings();
+ void setOnCameraIdleListener(Runnable callback);
void setOnCameraMoveStartedListener(OnCameraMoveStartedListener onCameraMoveStartedListener);
CameraPosition getCameraPosition();
void setOnMapLoadedCallback(Runnable callback);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java
index 9b48fddca..23ac4df39 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageReceiver.java
@@ -31,6 +31,8 @@ import android.view.View;
import androidx.annotation.Keep;
+import com.google.android.exoplayer2.util.Log;
+
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedFileDrawable;
@@ -76,6 +78,12 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return currentMediaDrawable;
}
+ public void updateStaticDrawableThump(Bitmap bitmap) {
+ staticThumbShader = null;
+ roundPaint.setShader(null);
+ setStaticDrawable(new BitmapDrawable(bitmap));
+ }
+
public interface ImageReceiverDelegate {
void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb, boolean memCache);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LinkifyPort.java b/TMessagesProj/src/main/java/org/telegram/messenger/LinkifyPort.java
index a2e3bf157..1e361830c 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/LinkifyPort.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/LinkifyPort.java
@@ -139,6 +139,25 @@ public class LinkifyPort {
"\uDB00\uDC00-\uDB3F\uDFFD" +
"\uDB44\uDC00-\uDB7F\uDFFD" +
"&&[^\u00A0[\u2000-\u200A]\u2028\u2029\u202F\u3000]]";
+ private static final String UCS_CHAR_FIXED = "[" +
+ "\u00A0-\uD7FF" +
+ "\uF900-\uFDCF" +
+ "\uFDF0-\uFFEF" +
+ // "\uD800\uDC00-\uD83F\uDFFD" +
+ "\uD840\uDC00-\uD87F\uDFFD" +
+ "\uD880\uDC00-\uD8BF\uDFFD" +
+ "\uD8C0\uDC00-\uD8FF\uDFFD" +
+ "\uD900\uDC00-\uD93F\uDFFD" +
+ "\uD940\uDC00-\uD97F\uDFFD" +
+ "\uD980\uDC00-\uD9BF\uDFFD" +
+ "\uD9C0\uDC00-\uD9FF\uDFFD" +
+ "\uDA00\uDC00-\uDA3F\uDFFD" +
+ "\uDA40\uDC00-\uDA7F\uDFFD" +
+ "\uDA80\uDC00-\uDABF\uDFFD" +
+ "\uDAC0\uDC00-\uDAFF\uDFFD" +
+ "\uDB00\uDC00-\uDB3F\uDFFD" +
+ "\uDB44\uDC00-\uDB7F\uDFFD" +
+ "&&[^\u00A0[\u2000-\u200A]\u2028\u2029\u202F\u3000]]";
private static final String IP_ADDRESS_STRING =
"((25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(25[0-5]|2[0-4]"
+ "[0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]"
@@ -146,7 +165,7 @@ public class LinkifyPort {
+ "|[1-9][0-9]|[0-9]))";
private static final String TLD_CHAR = "a-zA-Z" + UCS_CHAR;
private static final String PUNYCODE_TLD = "xn\\-\\-[\\w\\-]{0,58}\\w";
- private static final String LABEL_CHAR = "a-zA-Z0-9" + UCS_CHAR;
+ private static final String LABEL_CHAR = "a-zA-Z0-9" + UCS_CHAR_FIXED;
private static final String IRI_LABEL = "[" + LABEL_CHAR + "](?:[" + LABEL_CHAR + "_\\-]{0,61}[" + LABEL_CHAR + "]){0,1}";
private static String STRICT_TLD = "(?:" + IANA_TOP_LEVEL_DOMAINS + "|" + PUNYCODE_TLD + ")";
private static final String STRICT_HOST_NAME = "(?:(?:" + IRI_LABEL + "\\.)+" + STRICT_TLD + ")";
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
index 894b11e05..eee5cd401 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java
@@ -20,6 +20,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.TextUtils;
+import android.util.Log;
import android.util.SparseIntArray;
import androidx.collection.LongSparseArray;
@@ -997,7 +998,7 @@ public class LocationController extends BaseController implements NotificationCe
}
public interface LocationFetchCallback {
- void onLocationAddressAvailable(String address, String displayAddress, Location location);
+ void onLocationAddressAvailable(String address, String displayAddress, TLRPC.TL_messageMediaVenue city, TLRPC.TL_messageMediaVenue street, Location location);
}
private static HashMap callbacks = new HashMap<>();
@@ -1011,15 +1012,24 @@ public class LocationController extends BaseController implements NotificationCe
callbacks.remove(callback);
}
if (location == null) {
- callback.onLocationAddressAvailable(null, null, null);
+ callback.onLocationAddressAvailable(null, null, null, null, null);
return;
}
+ Locale locale;
+ try {
+ locale = LocaleController.getInstance().getCurrentLocale();
+ } catch (Exception ignore) {
+ locale = LocaleController.getInstance().getSystemDefaultLocale();
+ }
+ final Locale finalLocale = locale;
Utilities.globalQueue.postRunnable(fetchLocationRunnable = () -> {
- String name;
- String displayName;
+ String name, displayName, city, street, countryCode = null;
+ boolean onlyCountry = true;
+ TLRPC.TL_messageMediaVenue cityLocation = null;
+ TLRPC.TL_messageMediaVenue streetLocation = null;
try {
- Geocoder gcd = new Geocoder(ApplicationLoader.applicationContext, LocaleController.getInstance().getSystemDefaultLocale());
+ Geocoder gcd = new Geocoder(ApplicationLoader.applicationContext, finalLocale);
List addresses = gcd.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
if (addresses.size() > 0) {
Address address = addresses.get(0);
@@ -1028,6 +1038,74 @@ public class LocationController extends BaseController implements NotificationCe
StringBuilder nameBuilder = new StringBuilder();
StringBuilder displayNameBuilder = new StringBuilder();
+ StringBuilder cityBuilder = new StringBuilder();
+ StringBuilder streetBuilder = new StringBuilder();
+
+ String locality = null;
+ String feature = null;
+// String addressLine = null;
+// try {
+// addressLine = address.getAddressLine(0);
+// } catch (Exception ignore) {}
+// if (addressLine != null) {
+// String postalCode = address.getPostalCode();
+// if (postalCode != null) {
+// addressLine = addressLine.replace(" " + postalCode, "");
+// addressLine = addressLine.replace(postalCode, "");
+// }
+// String[] parts = addressLine.split(", ");
+// if (parts.length > 2) {
+// String _country = parts[parts.length - 1].replace(",", "").trim();
+// String _city = parts[parts.length - 2].replace(",", "").trim();
+//// if (_city.length() > 3) {
+//// locality = _city;
+//// }
+//// feature = parts[0].replace(",", "").trim();
+// }
+// }
+ if (TextUtils.isEmpty(locality)) {
+ locality = address.getLocality();
+ }
+ if (TextUtils.isEmpty(locality)) {
+ locality = address.getSubAdminArea();
+ }
+ if (TextUtils.isEmpty(locality)) {
+ locality = address.getAdminArea();
+ }
+
+// if (TextUtils.isEmpty(feature) && !TextUtils.equals(address.getFeatureName(), locality) && !TextUtils.equals(address.getFeatureName(), address.getCountryName())) {
+// feature = address.getFeatureName();
+// }
+ if (TextUtils.isEmpty(feature) && !TextUtils.equals(address.getThoroughfare(), locality) && !TextUtils.equals(address.getThoroughfare(), address.getCountryName())) {
+ feature = address.getThoroughfare();
+ }
+ if (TextUtils.isEmpty(feature) && !TextUtils.equals(address.getSubLocality(), locality) && !TextUtils.equals(address.getSubLocality(), address.getCountryName())) {
+ feature = address.getSubLocality();
+ }
+ if (TextUtils.isEmpty(feature) && !TextUtils.equals(address.getLocality(), locality) && !TextUtils.equals(address.getLocality(), address.getCountryName())) {
+ feature = address.getLocality();
+ }
+ if (!TextUtils.isEmpty(feature) && !TextUtils.equals(feature, locality) && !TextUtils.equals(feature, address.getCountryName())) {
+ if (streetBuilder.length() > 0) {
+ streetBuilder.append(", ");
+ }
+ streetBuilder.append(feature);
+ } else {
+ streetBuilder = null;
+ }
+ if (!TextUtils.isEmpty(locality)) {
+ if (cityBuilder.length() > 0) {
+ cityBuilder.append(", ");
+ }
+ cityBuilder.append(locality);
+ onlyCountry = false;
+ if (streetBuilder != null) {
+ if (streetBuilder.length() > 0) {
+ streetBuilder.append(", ");
+ }
+ streetBuilder.append(locality);
+ }
+ }
arg = address.getSubThoroughfare();
if (!TextUtils.isEmpty(arg)) {
@@ -1065,12 +1143,29 @@ public class LocationController extends BaseController implements NotificationCe
}
nameBuilder.append(arg);
}
+ countryCode = address.getCountryCode();
arg = address.getCountryName();
if (!TextUtils.isEmpty(arg)) {
if (nameBuilder.length() > 0) {
nameBuilder.append(", ");
}
nameBuilder.append(arg);
+ String shortCountry = arg;
+ final String lng = finalLocale.getLanguage();
+ if (("US".equals(address.getCountryCode()) || "AE".equals(address.getCountryCode())) && ("en".equals(lng) || "uk".equals(lng) || "ru".equals(lng)) || "GB".equals(address.getCountryCode()) && "en".equals(lng)) {
+ shortCountry = "";
+ String[] words = arg.split(" ");
+ for (String word : words) {
+ if (word.length() > 0)
+ shortCountry += word.charAt(0);
+ }
+ } else if ("US".equals(address.getCountryCode())) {
+ shortCountry = "USA";
+ }
+ if (cityBuilder.length() > 0) {
+ cityBuilder.append(", ");
+ }
+ cityBuilder.append(shortCountry);
}
arg = address.getCountryName();
@@ -1106,19 +1201,94 @@ public class LocationController extends BaseController implements NotificationCe
name = nameBuilder.toString();
displayName = displayNameBuilder.toString();
+ city = cityBuilder.toString();
+ street = streetBuilder == null ? null : streetBuilder.toString();
} else {
name = displayName = String.format(Locale.US, "Unknown address (%f,%f)", location.getLatitude(), location.getLongitude());
+ city = null;
+ street = null;
+ }
+ if (!TextUtils.isEmpty(city)) {
+ cityLocation = new TLRPC.TL_messageMediaVenue();
+ cityLocation.geo = new TLRPC.TL_geoPoint();
+ cityLocation.geo.lat = location.getLatitude();
+ cityLocation.geo._long = location.getLongitude();
+ cityLocation.query_id = -1;
+ cityLocation.title = city;
+ cityLocation.icon = onlyCountry ? "https://ss3.4sqi.net/img/categories_v2/building/government_capitolbuilding_64.png" : "https://ss3.4sqi.net/img/categories_v2/travel/hotel_64.png";
+ cityLocation.emoji = countryCodeToEmoji(countryCode);
+ cityLocation.address = onlyCountry ? LocaleController.getString("Country", R.string.Country) : LocaleController.getString("PassportCity", R.string.PassportCity);
+ }
+ if (!TextUtils.isEmpty(street)) {
+ streetLocation = new TLRPC.TL_messageMediaVenue();
+ streetLocation.geo = new TLRPC.TL_geoPoint();
+ streetLocation.geo.lat = location.getLatitude();
+ streetLocation.geo._long = location.getLongitude();
+ streetLocation.query_id = -1;
+ streetLocation.title = street;
+ streetLocation.icon = "pin";
+ streetLocation.address = LocaleController.getString("PassportStreet1", R.string.PassportStreet1);
+ }
+ if (cityLocation == null && streetLocation == null && location != null) {
+ String ocean = detectOcean(location.getLongitude(), location.getLatitude());
+ if (ocean != null) {
+ cityLocation = new TLRPC.TL_messageMediaVenue();
+ cityLocation.geo = new TLRPC.TL_geoPoint();
+ cityLocation.geo.lat = location.getLatitude();
+ cityLocation.geo._long = location.getLongitude();
+ cityLocation.query_id = -1;
+ cityLocation.title = ocean;
+ cityLocation.icon = "pin";
+ cityLocation.emoji = "🌊";
+ cityLocation.address = "Ocean";
+ }
}
} catch (Exception ignore) {
name = displayName = String.format(Locale.US, "Unknown address (%f,%f)", location.getLatitude(), location.getLongitude());
+ city = null;
+ street = null;
}
final String nameFinal = name;
final String displayNameFinal = displayName;
+ final TLRPC.TL_messageMediaVenue finalCityLocation = cityLocation;
+ final TLRPC.TL_messageMediaVenue finalStreetLocation = streetLocation;
AndroidUtilities.runOnUIThread(() -> {
callbacks.remove(callback);
- callback.onLocationAddressAvailable(nameFinal, displayNameFinal, location);
+ callback.onLocationAddressAvailable(nameFinal, displayNameFinal, finalCityLocation, finalStreetLocation, location);
});
}, 300);
callbacks.put(callback, fetchLocationRunnable);
}
+
+ public static String countryCodeToEmoji(String code) {
+ if (code == null) {
+ return null;
+ }
+ code = code.toUpperCase();
+ final int count = code.codePointCount(0, code.length());
+ if (count > 2) {
+ return null;
+ }
+ StringBuilder flag = new StringBuilder();
+ for (int j = 0; j < count; ++j) {
+ flag.append(Character.toChars(Character.codePointAt(code, j) - 0x41 + 0x1F1E6));
+ }
+ return flag.toString();
+ }
+
+ public static String detectOcean(double x, double y) {
+ if (y > 65) {
+ return "Arctic Ocean";
+ }
+ if (x > -88 && x < 40 && y > 0 || x > -60 && x < 20 && y <= 0) {
+ return "Atlantic Ocean";
+ }
+ if (y <= 30 && x >= 20 && x < 150) {
+ return "Indian Ocean";
+ }
+ if ((x > 106 || x < -60) && y > 0 || (x > 150 || x < -60) && y <= 0) {
+ return "Pacific Ocean";
+ }
+ return null;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
index 260962ed3..3cd122e16 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java
@@ -918,8 +918,16 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
int count = 0;
Cursor cursor = null;
try {
- if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
+ final Context context = ApplicationLoader.applicationContext;
+ if (
+ Build.VERSION.SDK_INT >= 33 && (
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
+ ) ||
+ context.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
+ ) {
+ cursor = MediaStore.Images.Media.query(context.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
if (cursor != null) {
if (cursor.moveToNext()) {
count += cursor.getInt(0);
@@ -934,8 +942,16 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
}
try {
- if (ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
+ final Context context = ApplicationLoader.applicationContext;
+ if (
+ Build.VERSION.SDK_INT >= 33 && (
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
+ ) ||
+ context.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
+ ) {
+ cursor = MediaStore.Images.Media.query(context.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{"COUNT(_id)"}, null, null, null);
if (cursor != null) {
if (cursor.moveToNext()) {
count += cursor.getInt(0);
@@ -1773,8 +1789,32 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (raisedToBack == minCount || accelerometerVertical) {
lastAccelerometerDetected = System.currentTimeMillis();
}
- if (proximityTouched && (raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60) && !VoIPService.isAnyKindOfCallActive() && !manualRecording && !forbidRaiseToListen()) {
- if (SharedConfig.enabledRaiseTo(true) && playingMessageObject == null && recordStartRunnable == null && recordingAudio == null && !PhotoViewer.getInstance().isVisible() && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress) {
+ final boolean allowRecording = !manualRecording && playingMessageObject == null && SharedConfig.enabledRaiseTo(true) && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress;
+ final boolean allowListening = SharedConfig.enabledRaiseTo(false) && playingMessageObject != null && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo());
+ final boolean proximityDetected = proximityTouched;
+ final boolean accelerometerDetected = raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60;
+ final boolean alreadyPlaying = useFrontSpeaker || raiseToEarRecord;
+ final boolean wakelockAllowed = (
+// proximityDetected ||
+ accelerometerDetected ||
+ alreadyPlaying
+ ) && !forbidRaiseToListen() && !VoIPService.isAnyKindOfCallActive() && (allowRecording || allowListening) && !PhotoViewer.getInstance().isVisible();
+ if (proximityWakeLock != null) {
+ final boolean held = proximityWakeLock.isHeld();
+ if (held && !wakelockAllowed) {
+ if (BuildVars.LOGS_ENABLED) {
+ FileLog.d("wake lock releasing (proximityDetected=" + proximityDetected + ", accelerometerDetected=" + accelerometerDetected + ", alreadyPlaying=" + alreadyPlaying + ")");
+ }
+ proximityWakeLock.release();
+ } else if (!held && wakelockAllowed) {
+ if (BuildVars.LOGS_ENABLED) {
+ FileLog.d("wake lock acquiring (proximityDetected=" + proximityDetected + ", accelerometerDetected=" + accelerometerDetected + ", alreadyPlaying=" + alreadyPlaying + ")");
+ }
+ proximityWakeLock.acquire();
+ }
+ }
+ if (proximityTouched && wakelockAllowed) {
+ if (allowRecording && recordStartRunnable == null && recordingAudio == null) {
if (!raiseToEarRecord) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("start record");
@@ -1788,40 +1828,40 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (useFrontSpeaker) {
setUseFrontSpeaker(true);
}
- ignoreOnPause = true;
- if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
- proximityWakeLock.acquire();
- }
+// ignoreOnPause = true;
+// if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
+// proximityWakeLock.acquire();
+// }
}
- } else if (SharedConfig.enabledRaiseTo(false) && playingMessageObject != null && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) {
+ } else if (allowListening) {
if (!useFrontSpeaker) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("start listen");
}
- if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
- proximityWakeLock.acquire();
- }
+// if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
+// proximityWakeLock.acquire();
+// }
setUseFrontSpeaker(true);
startAudioAgain(false);
- ignoreOnPause = true;
+// ignoreOnPause = true;
}
}
raisedToBack = 0;
raisedToTop = 0;
raisedToTopSign = 0;
countLess = 0;
- } else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null || ignoreAccelerometerGestures()) && !VoIPService.isAnyKindOfCallActive()) {
- if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()) && SharedConfig.enabledRaiseTo(false)) {
+ } else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null) && !VoIPService.isAnyKindOfCallActive()) {
+ if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && allowListening) {
if (!useFrontSpeaker && !manualRecording && !forbidRaiseToListen()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("start listen by proximity only");
}
- if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
- proximityWakeLock.acquire();
- }
+// if (proximityHasDifferentValues && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
+// proximityWakeLock.acquire();
+// }
setUseFrontSpeaker(true);
startAudioAgain(false);
- ignoreOnPause = true;
+// ignoreOnPause = true;
}
}
} else if (!proximityTouched && !manualRecording) {
@@ -1832,9 +1872,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
stopRecording(2, false, 0);
raiseToEarRecord = false;
ignoreOnPause = false;
- if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) {
- proximityWakeLock.release();
- }
+// if (!ignoreAccelerometerGestures() && proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) {
+// proximityWakeLock.release();
+// }
} else if (useFrontSpeaker) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("stop listen");
@@ -1842,9 +1882,9 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
useFrontSpeaker = false;
startAudioAgain(true);
ignoreOnPause = false;
- if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) {
- proximityWakeLock.release();
- }
+// if (!ignoreAccelerometerGestures() && proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) {
+// proximityWakeLock.release();
+// }
}
}
if (timeSinceRaise != 0 && raisedToBack == minCount && Math.abs(System.currentTimeMillis() - timeSinceRaise) > 1000) {
@@ -1990,7 +2030,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
sensorManager.unregisterListener(MediaController.this, proximitySensor);
});
- if (proximityHasDifferentValues && proximityWakeLock != null && proximityWakeLock.isHeld()) {
+ if (proximityWakeLock != null && proximityWakeLock.isHeld()) {
proximityWakeLock.release();
}
}
@@ -2072,14 +2112,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
stopProgressTimer();
lastProgress = 0;
isPaused = false;
- if (!useFrontSpeaker && !SharedConfig.enabledRaiseTo(true)) {
- ChatActivity chat = raiseChat;
- stopRaiseToEarSensors(raiseChat, false, false);
- raiseChat = chat;
- }
- if (proximityWakeLock != null && proximityWakeLock.isHeld() && !proximityTouched) {
- proximityWakeLock.release();
- }
+ boolean playingNext = false;
if (playingMessageObject != null) {
if (downloadingCurrentMessage) {
FileLoader.getInstance(playingMessageObject.currentAccount).cancelLoadFile(playingMessageObject.getDocument());
@@ -2108,10 +2141,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
voiceMessagesPlaylistMap = null;
}
}
- boolean next = false;
if (voiceMessagesPlaylist != null && index < voiceMessagesPlaylist.size()) {
MessageObject nextVoiceMessage = voiceMessagesPlaylist.get(index);
playMessage(nextVoiceMessage);
+ playingNext = true;
if (!nextVoiceMessage.isRoundVideo() && pipRoundVideoView != null) {
pipRoundVideoView.close(true);
pipRoundVideoView = null;
@@ -2133,6 +2166,11 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
ApplicationLoader.applicationContext.stopService(intent);
}
}
+ if (!playingNext && byVoiceEnd && !SharedConfig.enabledRaiseTo(true)) {
+ ChatActivity chat = raiseChat;
+ stopRaiseToEarSensors(raiseChat, false, false);
+ raiseChat = chat;
+ }
}
public boolean isGoingToShowMessageObject(MessageObject messageObject) {
@@ -3483,9 +3521,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
startRaiseToEarSensors(raiseChat);
}
if (!ApplicationLoader.mainInterfacePaused && proximityWakeLock != null && !proximityWakeLock.isHeld() && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()) && SharedConfig.enabledRaiseTo(false)) {
- if (ignoreAccelerometerGestures()) {
- proximityWakeLock.acquire();
- }
+// proximityWakeLock.acquire();
}
startProgressTimer(playingMessageObject);
NotificationCenter.getInstance(messageObject.currentAccount).postNotificationName(NotificationCenter.messagePlayingDidStart, messageObject, oldMessageObject);
@@ -3546,10 +3582,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
return true;
}
-
- public static boolean ignoreAccelerometerGestures() {
- return Build.MANUFACTURER.equalsIgnoreCase("samsung");
- }
public void updateSilent(boolean value) {
isSilent = value;
@@ -4738,8 +4770,17 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
Cursor cursor = null;
try {
- if (Build.VERSION.SDK_INT < 23 || ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
- cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projectionPhotos, null, null, (Build.VERSION.SDK_INT > 28 ? MediaStore.Images.Media.DATE_MODIFIED : MediaStore.Images.Media.DATE_TAKEN) + " DESC");
+ final Context context = ApplicationLoader.applicationContext;
+ if (
+ Build.VERSION.SDK_INT < 23 ||
+ Build.VERSION.SDK_INT < 33 && context.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ||
+ Build.VERSION.SDK_INT >= 33 && (
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
+ )
+ ) {
+ cursor = MediaStore.Images.Media.query(context.getContentResolver(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projectionPhotos, null, null, (Build.VERSION.SDK_INT > 28 ? MediaStore.Images.Media.DATE_MODIFIED : MediaStore.Images.Media.DATE_TAKEN) + " DESC");
if (cursor != null) {
int imageIdColumn = cursor.getColumnIndex(MediaStore.Images.Media._ID);
int bucketIdColumn = cursor.getColumnIndex(MediaStore.Images.Media.BUCKET_ID);
@@ -4820,7 +4861,17 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
}
try {
- if (Build.VERSION.SDK_INT < 23 || ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
+
+ final Context context = ApplicationLoader.applicationContext;
+ if (
+ Build.VERSION.SDK_INT < 23 ||
+ Build.VERSION.SDK_INT < 33 && context.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED ||
+ Build.VERSION.SDK_INT >= 33 && (
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_IMAGES) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED ||
+ context.checkSelfPermission(Manifest.permission.READ_MEDIA_AUDIO) == PackageManager.PERMISSION_GRANTED
+ )
+ ) {
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projectionVideo, null, null, (Build.VERSION.SDK_INT > 28 ? MediaStore.Video.Media.DATE_MODIFIED : MediaStore.Video.Media.DATE_TAKEN) + " DESC");
if (cursor != null) {
int imageIdColumn = cursor.getColumnIndex(MediaStore.Video.Media._ID);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
index 5b28b1331..c916729ae 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java
@@ -5330,7 +5330,7 @@ public class MediaDataController extends BaseController {
}
}
- public void loadReplyMessagesForMessages(ArrayList messages, long dialogId, boolean scheduled, int threadMessageId, Runnable callback) {
+ public void loadReplyMessagesForMessages(ArrayList messages, long dialogId, boolean scheduled, int threadMessageId, Runnable callback, int classGuid) {
if (DialogObject.isEncryptedDialog(dialogId)) {
ArrayList replyMessages = new ArrayList<>();
LongSparseArray> replyMessageRandomOwners = new LongSparseArray<>();
@@ -5542,7 +5542,7 @@ public class MediaDataController extends BaseController {
AndroidUtilities.runOnUIThread(callback);
}
}
- });
+ }, classGuid);
if (replyMessageOwners.isEmpty()) {
requestsCount[0]--;
if (requestsCount[0] == 0) {
@@ -5617,7 +5617,7 @@ public class MediaDataController extends BaseController {
TLRPC.TL_messages_getScheduledMessages req = new TLRPC.TL_messages_getScheduledMessages();
req.peer = getMessagesController().getInputPeer(dialogId);
req.id = dialogReplyMessagesIds.valueAt(a);
- getConnectionsManager().sendRequest(req, (response, error) -> {
+ int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
for (int i = 0; i < messagesRes.messages.size(); i++) {
@@ -5679,11 +5679,14 @@ public class MediaDataController extends BaseController {
}
}
});
+ if (classGuid != 0) {
+ getConnectionsManager().bindRequestToGuid(reqId, classGuid);
+ }
} else if (channelId != 0) {
TLRPC.TL_channels_getMessages req = new TLRPC.TL_channels_getMessages();
req.channel = getMessagesController().getInputChannel(channelId);
req.id = dialogReplyMessagesIds.valueAt(a);
- getConnectionsManager().sendRequest(req, (response, error) -> {
+ int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
for (int i = 0; i < messagesRes.messages.size(); i++) {
@@ -5705,10 +5708,13 @@ public class MediaDataController extends BaseController {
}
}
});
+ if (classGuid != 0) {
+ getConnectionsManager().bindRequestToGuid(reqId, classGuid);
+ }
} else {
TLRPC.TL_messages_getMessages req = new TLRPC.TL_messages_getMessages();
req.id = dialogReplyMessagesIds.valueAt(a);
- getConnectionsManager().sendRequest(req, (response, error) -> {
+ int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
for (int i = 0; i < messagesRes.messages.size(); i++) {
@@ -5729,6 +5735,9 @@ public class MediaDataController extends BaseController {
}
}
});
+ if (classGuid != 0) {
+ getConnectionsManager().bindRequestToGuid(reqId, classGuid);
+ }
}
}
} else {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
index 120700542..30c7df376 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
@@ -4649,7 +4649,7 @@ public class MessageObject {
return FileLoader.MEDIA_DIR_CACHE;
}
- private static boolean containsUrls(CharSequence message) {
+ public static boolean containsUrls(CharSequence message) {
if (message == null || message.length() < 2 || message.length() > 1024 * 20) {
return false;
}
@@ -4835,10 +4835,12 @@ public class MessageObject {
}
String text = messageOwner.message;
ArrayList entities = messageOwner.entities;
+ boolean forceManualEntities = false;
if (type == TYPE_STORY) {
if (messageOwner.media != null && messageOwner.media.storyItem != null) {
text = messageOwner.media.storyItem.caption;
entities = messageOwner.media.storyItem.entities;
+ forceManualEntities = true;
} else {
text = "";
entities = new ArrayList<>();
@@ -4861,16 +4863,16 @@ public class MessageObject {
hasEntities = !entities.isEmpty();
}
- boolean useManualParse = !hasEntities && (
- eventId != 0 ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_old ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_layer68 ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_layer74 ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_old ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_layer68 ||
- getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_layer74 ||
- isOut() && messageOwner.send_state != MESSAGE_SEND_STATE_SENT ||
- messageOwner.id < 0
+ boolean useManualParse = forceManualEntities || !hasEntities && (
+ eventId != 0 ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_old ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_layer68 ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaPhoto_layer74 ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_old ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_layer68 ||
+ getMedia(messageOwner) instanceof TLRPC.TL_messageMediaDocument_layer74 ||
+ isOut() && messageOwner.send_state != MESSAGE_SEND_STATE_SENT ||
+ messageOwner.id < 0
);
if (useManualParse) {
@@ -7001,7 +7003,7 @@ public class MessageObject {
}
public boolean shouldAnimateSending() {
- return isSending() && (type == MessageObject.TYPE_ROUND_VIDEO || isVoice() || (isAnyKindOfSticker() && sendAnimationData != null) || (messageText != null && sendAnimationData != null));
+ return wasJustSent && (type == MessageObject.TYPE_ROUND_VIDEO || isVoice() || (isAnyKindOfSticker() && sendAnimationData != null) || (messageText != null && sendAnimationData != null));
}
public boolean hasAttachedStickers() {
@@ -7589,7 +7591,7 @@ public class MessageObject {
if (type == TYPE_EXTENDED_MEDIA_PREVIEW) {
TLRPC.TL_messageExtendedMediaPreview preview = (TLRPC.TL_messageExtendedMediaPreview) messageOwner.media.extended_media;
if (preview.thumb != null) {
- File file = FileLoader.getInstance(currentAccount).getPathToAttach(preview.thumb);
+ File file = FileLoader.getInstance(currentAccount).getPathToAttach(preview.thumb, useFileDatabaseQueue);
if (!mediaExists) {
mediaExists = file.exists() || preview.thumb instanceof TLRPC.TL_photoStrippedSize;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
index e93769d90..77c565936 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
@@ -27,6 +27,7 @@ import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
+import android.util.Log;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
@@ -72,7 +73,6 @@ import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PremiumPreviewFragment;
import org.telegram.ui.ProfileActivity;
import org.telegram.ui.Stories.StoriesController;
-import org.telegram.ui.Stories.recorder.DualCameraView;
import org.telegram.ui.TopicsFragment;
import java.io.File;
@@ -137,9 +137,13 @@ public class MessagesController extends BaseController implements NotificationCe
private SparseArray chatlistFoldersUpdates = new SparseArray<>();
public int largeQueueMaxActiveOperations = 2;
public int smallQueueMaxActiveOperations = 5;
+ public int stealthModeFuture;
+ public int stealthModePast;
+ public int stealthModeCooldown;
public StoriesController storiesController;
private boolean hasArchivedChats;
private boolean hasStories;
+ public long storiesChangelogUserId;
public static TLRPC.Peer getPeerFromInputPeer(TLRPC.InputPeer peer) {
if (peer.chat_id != 0) {
@@ -458,6 +462,7 @@ public class MessagesController extends BaseController implements NotificationCe
public boolean collectDeviceStats;
public boolean showFiltersTooltip;
public String venueSearchBot;
+ public String storyVenueSearchBot;
public String gifSearchBot;
public String imageSearchBot;
public String dcDomainName;
@@ -504,7 +509,8 @@ public class MessagesController extends BaseController implements NotificationCe
public int publicLinksLimitPremium;
public int captionLengthLimitDefault;
public int captionLengthLimitPremium;
- public int storyCaptionLengthLimit;
+ public int storyCaptionLengthLimitDefault;
+ public int storyCaptionLengthLimitPremium;
public int aboutLengthLimitDefault;
public int aboutLengthLimitPremium;
public int reactionsUserMaxDefault;
@@ -518,6 +524,10 @@ public class MessagesController extends BaseController implements NotificationCe
private int chatlistUpdatePeriod;
public int storyExpiringLimitDefault;
public int storyExpiringLimitPremium;
+ public int storiesSentWeeklyLimitDefault;
+ public int storiesSentWeeklyLimitPremium;
+ public int storiesSentMonthlyLimitDefault;
+ public int storiesSentMonthlyLimitPremium;
public int uploadMaxFileParts;
public int uploadMaxFilePartsPremium;
@@ -552,6 +562,7 @@ public class MessagesController extends BaseController implements NotificationCe
public int chatlistJoinedLimitDefault;
public int chatlistJoinedLimitPremium;
public String storiesPosting;
+ public String storiesEntities;
public int checkResetLangpack;
@@ -622,6 +633,7 @@ public class MessagesController extends BaseController implements NotificationCe
getMessagesStorage().saveDialogFiltersOrder();
getNotificationCenter().postNotificationName(NotificationCenter.dialogFiltersUpdated);
+ getStoriesController().onPremiumChanged();
}
public void lockFiltersInternal() {
@@ -1285,6 +1297,7 @@ public class MessagesController extends BaseController implements NotificationCe
promoPsaType = mainPreferences.getString("promo_psa_type", null);
proxyDialogAddress = mainPreferences.getString("proxyDialogAddress", null);
venueSearchBot = mainPreferences.getString("venueSearchBot", "foursquare");
+ storyVenueSearchBot = mainPreferences.getString("storyVenueSearchBot", "foursquare");
gifSearchBot = mainPreferences.getString("gifSearchBot", "gif");
imageSearchBot = mainPreferences.getString("imageSearchBot", "pic");
blockedCountry = mainPreferences.getBoolean("blockedCountry", false);
@@ -1327,7 +1340,8 @@ public class MessagesController extends BaseController implements NotificationCe
publicLinksLimitPremium = mainPreferences.getInt("publicLinksLimitPremium", 20);
captionLengthLimitDefault = mainPreferences.getInt("captionLengthLimitDefault", 1024);
captionLengthLimitPremium = mainPreferences.getInt("captionLengthLimitPremium", 4096);
- storyCaptionLengthLimit = mainPreferences.getInt("storyCaptionLengthLimit", 1024);
+ storyCaptionLengthLimitDefault = mainPreferences.getInt("storyCaptionLengthLimit", 200);
+ storyCaptionLengthLimitPremium = mainPreferences.getInt("storyCaptionLengthLimitPremium", 2048);
aboutLengthLimitDefault = mainPreferences.getInt("aboutLengthLimitDefault", 70);
aboutLengthLimitPremium = mainPreferences.getInt("aboutLengthLimitPremium", 140);
reactionsUserMaxDefault = mainPreferences.getInt("reactionsUserMaxDefault", 1);
@@ -1351,14 +1365,23 @@ public class MessagesController extends BaseController implements NotificationCe
checkResetLangpack = mainPreferences.getInt("checkResetLangpack", 0);
smallQueueMaxActiveOperations = mainPreferences.getInt("smallQueueMaxActiveOperations", 5);
largeQueueMaxActiveOperations = mainPreferences.getInt("largeQueueMaxActiveOperations", 2);
+ stealthModeFuture = mainPreferences.getInt("stories_stealth_future_period", 25 * 60);
+ storiesChangelogUserId = mainPreferences.getLong("stories_changelog_user_id", 777000);
+ stealthModePast = mainPreferences.getInt("stories_stealth_past_period", 5 * 60);
+ stealthModeCooldown = mainPreferences.getInt("stories_stealth_cooldown_period", 60 * 60);
boolean isTest = ConnectionsManager.native_isTestBackend(currentAccount) != 0;
chatlistInvitesLimitDefault = mainPreferences.getInt("chatlistInvitesLimitDefault", 3);
storyExpiringLimitDefault = mainPreferences.getInt("storyExpiringLimitDefault", 50);
storyExpiringLimitPremium = mainPreferences.getInt("storyExpiringLimitPremium", 100);
+ storiesSentWeeklyLimitDefault = mainPreferences.getInt("storiesSentWeeklyLimitDefault", 7);
+ storiesSentWeeklyLimitPremium = mainPreferences.getInt("storiesSentWeeklyLimitPremium", 70);
+ storiesSentMonthlyLimitDefault = mainPreferences.getInt("storiesSentMonthlyLimitDefault", 30);
+ storiesSentMonthlyLimitPremium = mainPreferences.getInt("storiesSentMonthlyLimitPremium", 300);
chatlistInvitesLimitPremium = mainPreferences.getInt("chatlistInvitesLimitPremium", isTest ? 5 : 20);
chatlistJoinedLimitDefault = mainPreferences.getInt("chatlistJoinedLimitDefault", 2);
chatlistJoinedLimitPremium = mainPreferences.getInt("chatlistJoinedLimitPremium", isTest ? 5 : 20);
- storiesPosting = mainPreferences.getString("storiesPosting", "premium");
+ storiesPosting = mainPreferences.getString("storiesPosting", "enabled");
+ storiesEntities = mainPreferences.getString("storiesEntities", "premium");
storiesExportNopublicLink = mainPreferences.getBoolean("storiesExportNopublicLink", false);
BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID);
if (mainPreferences.contains("dcDomainName2")) {
@@ -1499,9 +1522,7 @@ public class MessagesController extends BaseController implements NotificationCe
FileLog.e(e);
}
}
- if (BuildVars.DEBUG_VERSION) {
- AndroidUtilities.runOnUIThread(this::loadAppConfig, 2000);
- }
+ AndroidUtilities.runOnUIThread(this::loadAppConfig, 2000);
topicsController = new TopicsController(num);
cacheByChatsController = new CacheByChatsController(num);
@@ -2131,6 +2152,34 @@ public class MessagesController extends BaseController implements NotificationCe
for (int a = 0, N = object.value.size(); a < N; a++) {
TLRPC.TL_jsonObjectValue value = object.value.get(a);
switch (value.key) {
+ case "stories_changelog_user_id": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ storiesChangelogUserId = (long) ((TLRPC.TL_jsonNumber) value.value).value;
+ editor.putLong("stories_changelog_user_id", storiesChangelogUserId);
+ }
+ break;
+ }
+ case "stories_stealth_future_period": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ stealthModeFuture = (int) ((TLRPC.TL_jsonNumber) value.value).value;
+ editor.putInt("stories_stealth_future_period", stealthModeFuture);
+ }
+ break;
+ }
+ case "stories_stealth_past_period": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ stealthModePast = (int) ((TLRPC.TL_jsonNumber) value.value).value;
+ editor.putInt("stories_stealth_past_period", stealthModePast);
+ }
+ break;
+ }
+ case "stories_stealth_cooldown_period": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ stealthModeCooldown = (int) ((TLRPC.TL_jsonNumber) value.value).value;
+ editor.putInt("stories_stealth_cooldown_period", stealthModeCooldown);
+ }
+ break;
+ }
case "large_queue_max_active_operations_count": {
if (value.value instanceof TLRPC.TL_jsonNumber) {
largeQueueMaxActiveOperations = (int) ((TLRPC.TL_jsonNumber) value.value).value;
@@ -2982,12 +3031,23 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
- case "story_caption_length_limit": {
+ case "story_caption_length_limit_default": {
if (value.value instanceof TLRPC.TL_jsonNumber) {
TLRPC.TL_jsonNumber number = (TLRPC.TL_jsonNumber) value.value;
- if (number.value != storyCaptionLengthLimit) {
- storyCaptionLengthLimit = (int) number.value;
- editor.putInt("storyCaptionLengthLimit", storyCaptionLengthLimit);
+ if (number.value != storyCaptionLengthLimitDefault) {
+ storyCaptionLengthLimitDefault = (int) number.value;
+ editor.putInt("storyCaptionLengthLimit", storyCaptionLengthLimitDefault);
+ changed = true;
+ }
+ }
+ break;
+ }
+ case "story_caption_length_limit_premium": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ TLRPC.TL_jsonNumber number = (TLRPC.TL_jsonNumber) value.value;
+ if (number.value != storyCaptionLengthLimitPremium) {
+ storyCaptionLengthLimitPremium = (int) number.value;
+ editor.putInt("storyCaptionLengthLimitPremium", storyCaptionLengthLimitPremium);
changed = true;
}
}
@@ -3174,6 +3234,50 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
+ case "stories_sent_weekly_limit_default": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
+ if (num.value != storiesSentWeeklyLimitDefault) {
+ storiesSentWeeklyLimitDefault = (int) num.value;
+ editor.putInt("storiesSentWeeklyLimitDefault", storiesSentWeeklyLimitDefault);
+ changed = true;
+ }
+ }
+ break;
+ }
+ case "stories_sent_weekly_limit_premium": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
+ if (num.value != storiesSentWeeklyLimitPremium) {
+ storiesSentWeeklyLimitPremium = (int) num.value;
+ editor.putInt("storiesSentWeeklyLimitPremium", storiesSentWeeklyLimitPremium);
+ changed = true;
+ }
+ }
+ break;
+ }
+ case "stories_sent_monthly_limit_default": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
+ if (num.value != storiesSentMonthlyLimitDefault) {
+ storiesSentMonthlyLimitDefault = (int) num.value;
+ editor.putInt("storiesSentMonthlyLimitDefault", storiesSentMonthlyLimitDefault);
+ changed = true;
+ }
+ }
+ break;
+ }
+ case "stories_sent_monthly_limit_premium": {
+ if (value.value instanceof TLRPC.TL_jsonNumber) {
+ TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
+ if (num.value != storiesSentMonthlyLimitPremium) {
+ storiesSentMonthlyLimitPremium = (int) num.value;
+ editor.putInt("storiesSentMonthlyLimitPremium", storiesSentMonthlyLimitPremium);
+ changed = true;
+ }
+ }
+ break;
+ }
case "chatlist_invites_limit_premium": {
if (value.value instanceof TLRPC.TL_jsonNumber) {
TLRPC.TL_jsonNumber num = (TLRPC.TL_jsonNumber) value.value;
@@ -3209,14 +3313,24 @@ public class MessagesController extends BaseController implements NotificationCe
}
case "stories_posting": {
if (value.value instanceof TLRPC.TL_jsonString) {
- TLRPC.TL_jsonString bool = (TLRPC.TL_jsonString) value.value;
- if (!TextUtils.equals(bool.value, storiesPosting)) {
- storiesPosting = bool.value;
+ TLRPC.TL_jsonString str = (TLRPC.TL_jsonString) value.value;
+ if (!TextUtils.equals(str.value, storiesPosting)) {
+ storiesPosting = str.value;
editor.putString("storiesPosting", storiesPosting);
changed = storiesChanged = true;
}
}
}
+ case "stories_entities": {
+ if (value.value instanceof TLRPC.TL_jsonString) {
+ TLRPC.TL_jsonString str = (TLRPC.TL_jsonString) value.value;
+ if (!TextUtils.equals(str.value, storiesEntities)) {
+ storiesEntities = str.value;
+ editor.putString("storiesEntities", storiesEntities);
+ changed = true;
+ }
+ }
+ }
case "stories_export_nopublic_link": {
if (value.value instanceof TLRPC.TL_jsonBool) {
TLRPC.TL_jsonBool bool = (TLRPC.TL_jsonBool) value.value;
@@ -3227,6 +3341,16 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
}
+ case "stories_venue_search_username": {
+ if (value.value instanceof TLRPC.TL_jsonString) {
+ TLRPC.TL_jsonString str = (TLRPC.TL_jsonString) value.value;
+ if (!TextUtils.equals(storyVenueSearchBot, str.value)) {
+ storyVenueSearchBot = str.value;
+ editor.putString("storyVenueSearchBot", storyVenueSearchBot);
+ changed = true;
+ }
+ }
+ }
}
}
if (changed) {
@@ -3256,6 +3380,7 @@ public class MessagesController extends BaseController implements NotificationCe
private boolean savePremiumFeaturesPreviewOrder(SharedPreferences.Editor editor, ArrayList value) {
StringBuilder stringBuilder = new StringBuilder();
+ StringBuilder storiesBuilder = new StringBuilder();
premiumFeaturesTypesToPosition.clear();
for (int i = 0; i < value.size(); i++) {
String s = null;
@@ -3970,6 +4095,8 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
}
+ } else if (id == NotificationCenter.currentUserPremiumStatusChanged) {
+ loadAppConfig(false);
}
}
@@ -5729,7 +5856,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
};
- if ((!user.bot || !ChatObject.isChannelAndNotMegaGroup(chat)) && addingNew) {
+ if (!user.bot && addingNew) {
addUserToChat(chatId, user, 0, botHash, parentFragment, true, () -> getConnectionsManager().sendRequest(req, requestDelegate), onError);
} else {
getConnectionsManager().sendRequest(req, requestDelegate);
@@ -6896,10 +7023,10 @@ public class MessagesController extends BaseController implements NotificationCe
}
public void loadChannelParticipants(Long chatId) {
- loadChannelParticipants(chatId, null);
+ loadChannelParticipants(chatId, null, 32);
}
- public void loadChannelParticipants(Long chatId, Utilities.Callback whenDone) {
+ public void loadChannelParticipants(Long chatId, Utilities.Callback whenDone, int count) {
if (whenDone == null && (loadingFullParticipants.contains(chatId) || loadedFullParticipants.contains(chatId))) {
return;
}
@@ -6909,7 +7036,7 @@ public class MessagesController extends BaseController implements NotificationCe
req.channel = getInputChannel(chatId);
req.filter = new TLRPC.TL_channelParticipantsRecent();
req.offset = 0;
- req.limit = 32;
+ req.limit = count;
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (error == null) {
TLRPC.TL_channels_channelParticipants res = (TLRPC.TL_channels_channelParticipants) response;
@@ -8011,6 +8138,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
req.limit = count;
req.offset_id = max_id;
+ long time = System.currentTimeMillis();
int reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
if (response != null) {
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
@@ -8415,7 +8543,7 @@ public class MessagesController extends BaseController implements NotificationCe
} else {
getNotificationCenter().postNotificationName(NotificationCenter.messagesDidLoad, dialogId, count, objects, isCache, finalFirst_unread_final, last_message_id, unread_count, last_date, load_type, isEnd, classGuid, loadIndex, max_id, mentionsCount, mode);
}
- });
+ }, classGuid);
} else {
getNotificationCenter().postNotificationName(NotificationCenter.messagesDidLoad, dialogId, count, objects, isCache, first_unread_final, last_message_id, unread_count, last_date, load_type, isEnd, classGuid, loadIndex, max_id, mentionsCount, mode);
}
@@ -12227,17 +12355,21 @@ public class MessagesController extends BaseController implements NotificationCe
if (!guids.contains(guid)) {
guids.add(guid);
}
- boolean needGetDifference = false;
if (shortPollChannels.indexOfKey(chat.id) < 0) {
- needGetDifference = true;
+ if (needPollConsumer != null) {
+ AndroidUtilities.runOnUIThread(() -> {
+ needPollConsumer.accept(true);
+ });
+ }
getChannelDifference(chat.id, 3, 0, null);
+ } else {
+ if (needPollConsumer != null) {
+ AndroidUtilities.runOnUIThread(() -> {
+ needPollConsumer.accept(false);
+ });
+ }
}
- boolean finalNeedGetDifference = needGetDifference;
- if (needPollConsumer != null) {
- AndroidUtilities.runOnUIThread(() -> {
- needPollConsumer.accept(finalNeedGetDifference);
- });
- }
+
if (chat.megagroup) {
if (onlineGuids == null) {
onlineGuids = new ArrayList<>();
@@ -12750,7 +12882,7 @@ public class MessagesController extends BaseController implements NotificationCe
updateInterfaceWithMessages(dialogId, arr, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload);
});
- });
+ }, 0);
}
});
@@ -14723,6 +14855,7 @@ public class MessagesController extends BaseController implements NotificationCe
blockePeers.delete(id);
}
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad);
+ getStoriesController().updateBlockUser(id, finalUpdate.blocked_my_stories_from, false);
}));
} else if (baseUpdate instanceof TLRPC.TL_updateNotifySettings) {
if (updatesOnMainThread == null) {
@@ -14780,6 +14913,11 @@ public class MessagesController extends BaseController implements NotificationCe
}
pushMessages.add(obj);
}
+ } else if (baseUpdate instanceof TLRPC.TL_updateStoriesStealthMode) {
+ if (updatesOnMainThread == null) {
+ updatesOnMainThread = new ArrayList<>();
+ }
+ updatesOnMainThread.add(baseUpdate);
} else if (baseUpdate instanceof TLRPC.TL_updateDialogPinned) {
if (updatesOnMainThread == null) {
updatesOnMainThread = new ArrayList<>();
@@ -14912,7 +15050,7 @@ public class MessagesController extends BaseController implements NotificationCe
updatesOnMainThread = new ArrayList<>();
}
updatesOnMainThread.add(baseUpdate);
- } else if (baseUpdate instanceof TLRPC.TL_updateChat) {
+ } else if (baseUpdate instanceof TLRPC.TL_updateChat || baseUpdate instanceof TLRPC.TL_updateSentStoryReaction) {
if (updatesOnMainThread == null) {
updatesOnMainThread = new ArrayList<>();
}
@@ -15799,6 +15937,9 @@ public class MessagesController extends BaseController implements NotificationCe
}
int threadId = update.top_msg_id;
getMediaDataController().saveDraft(did, threadId, update.draft, null, true);
+ } else if (baseUpdate instanceof TLRPC.TL_updateStoriesStealthMode) {
+ TLRPC.TL_updateStoriesStealthMode storiesStealthModeUpdate = (TLRPC.TL_updateStoriesStealthMode) baseUpdate;
+ getStoriesController().setStealthMode(storiesStealthModeUpdate.stealth_mode);
} else if (baseUpdate instanceof TLRPC.TL_updateReadFeaturedStickers) {
getMediaDataController().markFeaturedStickersAsRead(false, false);
} else if (baseUpdate instanceof TLRPC.TL_updateReadFeaturedEmojiStickers) {
@@ -16096,6 +16237,8 @@ public class MessagesController extends BaseController implements NotificationCe
getNotificationCenter().postNotificationName(NotificationCenter.voiceTranscriptionUpdate, null, (Long) update.transcription_id, (String) update.text, null, (Boolean) !update.pending);
}
}
+ } else if (baseUpdate instanceof TLRPC.TL_updateSentStoryReaction) {
+ storiesController.updateStoryReaction(((TLRPC.TL_updateSentStoryReaction) baseUpdate).user_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).story_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).reaction);
}
}
if (editor != null) {
@@ -16235,7 +16378,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
}
- getMediaDataController().loadReplyMessagesForMessages(arrayList, dialogId, false, 0,null);
+ getMediaDataController().loadReplyMessagesForMessages(arrayList, dialogId, false, 0,null, 0);
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, dialogId, arrayList, false);
}
}
@@ -16967,7 +17110,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
}
- getMediaDataController().loadReplyMessagesForMessages(messages, dialogId, scheduled, 0, null);
+ getMediaDataController().loadReplyMessagesForMessages(messages, dialogId, scheduled, 0, null, 0);
getNotificationCenter().postNotificationName(NotificationCenter.didReceiveNewMessages, dialogId, messages, scheduled);
if (lastMessage == null || scheduled) {
@@ -18241,4 +18384,31 @@ public class MessagesController extends BaseController implements NotificationCe
return false;
}
}
+
+ public boolean storyEntitiesAllowed() {
+ switch (storiesEntities) {
+ case "premium":
+ return getUserConfig().isPremium();
+ case "enabled":
+ return true;
+ default:
+ case "disabled":
+ return false;
+ }
+ }
+
+ public boolean storyEntitiesAllowed(TLRPC.User user) {
+ if (user != null && user.id == storiesChangelogUserId) {
+ return true;
+ }
+ switch (storiesEntities) {
+ case "premium":
+ return user != null && user.premium;
+ case "enabled":
+ return true;
+ default:
+ case "disabled":
+ return false;
+ }
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
index f15a4aa04..2fd1bc172 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java
@@ -95,7 +95,7 @@ public class MessagesStorage extends BaseController {
}
}
- public final static int LAST_DB_VERSION = 127;
+ public final static int LAST_DB_VERSION = 128;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
@@ -202,6 +202,7 @@ public class MessagesStorage extends BaseController {
public MessagesStorage(int instance) {
super(instance);
storageQueue = new DispatchQueue("storageQueue_" + instance);
+ storageQueue.setPriority(8);
storageQueue.postRunnable(() -> openDatabase(1));
}
@@ -671,7 +672,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE TABLE emoji_groups(type INTEGER PRIMARY KEY, data BLOB)").stepThis().dispose();
database.executeFast("CREATE TABLE app_config(data BLOB)").stepThis().dispose();
- database.executeFast("CREATE TABLE stories (dialog_id INTEGER, story_id INTEGER, data BLOB, local_path TEXT, local_thumb_path TEXT, PRIMARY KEY (dialog_id, story_id));").stepThis().dispose();
+ database.executeFast("CREATE TABLE stories (dialog_id INTEGER, story_id INTEGER, data BLOB, local_path TEXT, local_thumb_path TEXT, custom_params BLOB, PRIMARY KEY (dialog_id, story_id));").stepThis().dispose();
database.executeFast("CREATE TABLE stories_counter (dialog_id INTEGER PRIMARY KEY, count INTEGER, max_read INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE profile_stories (dialog_id INTEGER, story_id INTEGER, data BLOB, PRIMARY KEY(dialog_id, story_id));").stepThis().dispose();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
index 0211c54e9..e297dc3bc 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationCenter.java
@@ -110,6 +110,7 @@ public class NotificationCenter {
public static final int paymentFinished = totalEvents++;
public static final int channelRightsUpdated = totalEvents++;
public static final int openArticle = totalEvents++;
+ public static final int articleClosed = totalEvents++;
public static final int updateMentionsCount = totalEvents++;
public static final int didUpdatePollResults = totalEvents++;
public static final int chatOnlineCountDidLoad = totalEvents++;
@@ -211,6 +212,8 @@ public class NotificationCenter {
public static final int didUpdatePremiumGiftStickers = totalEvents++;
public static final int didUpdatePremiumGiftFieldIcon = totalEvents++;
public static final int storiesEnabledUpdate = totalEvents++;
+ public static final int storiesBlocklistUpdate = totalEvents++;
+ public static final int storiesLimitUpdate = totalEvents++;
//global
public static final int pushMessagesUpdated = totalEvents++;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java
index f8250d34e..56d685a26 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java
@@ -868,7 +868,7 @@ public class PushListenerController {
break;
}
case "CHAT_DELETE_MEMBER": {
- messageText = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, args[0], args[1]);
+ messageText = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, args[0], args[1], args.length <= 2 ? "" : args[2]);
break;
}
case "CHAT_DELETE_YOU": {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
index 3e73d297f..ab1535634 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java
@@ -231,11 +231,13 @@ public class SharedConfig {
public static boolean searchMessagesAsListUsed;
public static boolean stickersReorderingHintUsed;
public static int dayNightWallpaperSwitchHint;
+ public static boolean storyReactionsLongPressHint;
public static boolean disableVoiceAudioEffects;
public static boolean forceDisableTabletMode;
public static boolean updateStickersOrderOnSend = true;
public static boolean bigCameraForRound;
public static boolean useSurfaceInStories;
+ public static int stealthModeSendMessageConfirm = 2;
private static int lastLocalId = -210000;
public static String storageCacheDir;
@@ -591,6 +593,7 @@ public class SharedConfig {
searchMessagesAsListHintShows = preferences.getInt("searchMessagesAsListHintShows", 0);
searchMessagesAsListUsed = preferences.getBoolean("searchMessagesAsListUsed", false);
stickersReorderingHintUsed = preferences.getBoolean("stickersReorderingHintUsed", false);
+ storyReactionsLongPressHint = preferences.getBoolean("storyReactionsLongPressHint", false);
textSelectionHintShows = preferences.getInt("textSelectionHintShows", 0);
scheduledOrNoSoundHintShows = preferences.getInt("scheduledOrNoSoundHintShows", 0);
forwardingOptionsHintShown = preferences.getBoolean("forwardingOptionsHintShown", false);
@@ -601,6 +604,7 @@ public class SharedConfig {
messageSeenHintCount = preferences.getInt("messageSeenCount", 3);
emojiInteractionsHintCount = preferences.getInt("emojiInteractionsHintCount", 3);
dayNightThemeSwitchHintCount = preferences.getInt("dayNightThemeSwitchHintCount", 3);
+ stealthModeSendMessageConfirm = preferences.getInt("stealthModeSendMessageConfirm", 2);
mediaColumnsCount = preferences.getInt("mediaColumnsCount", 3);
storiesColumnsCount = preferences.getInt("storiesColumnsCount", 3);
fastScrollHintCount = preferences.getInt("fastScrollHintCount", 3);
@@ -797,6 +801,7 @@ public class SharedConfig {
messageSeenHintCount = 3;
emojiInteractionsHintCount = 3;
dayNightThemeSwitchHintCount = 3;
+ stealthModeSendMessageConfirm = 2;
dayNightWallpaperSwitchHint = 0;
saveConfig();
}
@@ -825,6 +830,14 @@ public class SharedConfig {
editor.apply();
}
+ public static void setStoriesReactionsLongPressHintUsed(boolean value) {
+ storyReactionsLongPressHint = value;
+ SharedPreferences preferences = MessagesController.getGlobalMainSettings();
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("storyReactionsLongPressHint", storyReactionsLongPressHint);
+ editor.apply();
+ }
+
public static void increaseTextSelectionHintShowed() {
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
SharedPreferences.Editor editor = preferences.edit();
@@ -1423,6 +1436,12 @@ public class SharedConfig {
preferences.edit().putInt("dayNightThemeSwitchHintCount", dayNightThemeSwitchHintCount).apply();
}
+ public static void updateStealthModeSendMessageConfirm(int count) {
+ stealthModeSendMessageConfirm = count;
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
+ preferences.edit().putInt("stealthModeSendMessageConfirm", stealthModeSendMessageConfirm).apply();
+ }
+
public final static int PERFORMANCE_CLASS_LOW = 0;
public final static int PERFORMANCE_CLASS_AVERAGE = 1;
public final static int PERFORMANCE_CLASS_HIGH = 2;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TranslateController.java b/TMessagesProj/src/main/java/org/telegram/messenger/TranslateController.java
index 04548a583..8b4f0b8aa 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/TranslateController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/TranslateController.java
@@ -1016,4 +1016,255 @@ public class TranslateController extends BaseController {
private void resetTranslatingDialogsCache() {
MessagesController.getMainSettings(currentAccount).edit().remove("translating_dialog_languages2").remove("hidden_translation_at").apply();
}
+
+ private final HashSet detectingStories = new HashSet<>();
+ private final HashSet translatingStories = new HashSet<>();
+
+ // ensure dialogId in storyItem is valid
+ public void detectStoryLanguage(TLRPC.StoryItem storyItem) {
+ if (storyItem == null || storyItem.detectedLng != null || storyItem.caption == null || storyItem.caption.length() == 0 || !LanguageDetector.hasSupport()) {
+ return;
+ }
+
+ final StoryKey key = new StoryKey(storyItem);
+ if (detectingStories.contains(key)) {
+ return;
+ }
+ detectingStories.add(key);
+
+ LanguageDetector.detectLanguage(storyItem.caption, lng -> AndroidUtilities.runOnUIThread(() -> {
+ storyItem.detectedLng = lng;
+ getMessagesController().getStoriesController().getStoriesStorage().putStoryInternal(storyItem.dialogId, storyItem);
+ detectingStories.remove(key);
+ }), err -> AndroidUtilities.runOnUIThread(() -> {
+ storyItem.detectedLng = UNKNOWN_LANGUAGE;
+ getMessagesController().getStoriesController().getStoriesStorage().putStoryInternal(storyItem.dialogId, storyItem);
+ detectingStories.remove(key);
+ }));
+ }
+
+ public boolean canTranslateStory(TLRPC.StoryItem storyItem) {
+ return storyItem != null && !TextUtils.isEmpty(storyItem.caption) && !Emoji.fullyConsistsOfEmojis(storyItem.caption) && (
+ storyItem.detectedLng == null && storyItem.translatedText != null && TextUtils.equals(storyItem.translatedLng, TranslateAlert2.getToLanguage()) ||
+ storyItem.detectedLng != null && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(storyItem.detectedLng)
+ );
+ }
+
+ public void translateStory(TLRPC.StoryItem storyItem, Runnable done) {
+ if (storyItem == null) {
+ return;
+ }
+
+ final StoryKey key = new StoryKey(storyItem);
+
+ String toLang = TranslateAlert2.getToLanguage();
+
+ if (storyItem.translatedText != null && TextUtils.equals(storyItem.translatedLng, toLang)) {
+ if (done != null) {
+ done.run();
+ }
+ return;
+ }
+ if (translatingStories.contains(key)) {
+ if (done != null) {
+ done.run();
+ }
+ return;
+ }
+
+ translatingStories.add(key);
+
+ TLRPC.TL_messages_translateText req = new TLRPC.TL_messages_translateText();
+ req.flags |= 2;
+ final TLRPC.TL_textWithEntities text = new TLRPC.TL_textWithEntities();
+ text.text = storyItem.caption;
+ text.entities = storyItem.entities;
+ req.text.add(text);
+ req.to_lang = toLang;
+ getConnectionsManager().sendRequest(req, (res, err) -> {
+ if (res instanceof TLRPC.TL_messages_translateResult) {
+ ArrayList result = ((TLRPC.TL_messages_translateResult) res).result;
+ if (result.size() <= 0) {
+ AndroidUtilities.runOnUIThread(() -> {
+ storyItem.translatedLng = toLang;
+ storyItem.translatedText = null;
+ getMessagesController().getStoriesController().getStoriesStorage().putStoryInternal(storyItem.dialogId, storyItem);
+ translatingStories.remove(key);
+ if (done != null) {
+ done.run();
+ }
+ });
+ return;
+ }
+ final TLRPC.TL_textWithEntities textWithEntities = result.get(0);
+ AndroidUtilities.runOnUIThread(() -> {
+ storyItem.translatedLng = toLang;
+ storyItem.translatedText = TranslateAlert2.preprocess(text, textWithEntities);
+ getMessagesController().getStoriesController().getStoriesStorage().putStoryInternal(storyItem.dialogId, storyItem);
+ translatingStories.remove(key);
+ if (done != null) {
+ done.run();
+ }
+ });
+ } else {
+ AndroidUtilities.runOnUIThread(() -> {
+ storyItem.translatedLng = toLang;
+ storyItem.translatedText = null;
+ getMessagesController().getStoriesController().getStoriesStorage().putStoryInternal(storyItem.dialogId, storyItem);
+ translatingStories.remove(key);
+ if (done != null) {
+ done.run();
+ }
+ });
+ }
+ });
+ }
+
+ public boolean isTranslatingStory(TLRPC.StoryItem storyItem) {
+ if (storyItem == null) {
+ return false;
+ }
+ return translatingStories.contains(new StoryKey(storyItem));
+ }
+
+ private static class StoryKey {
+ public long dialogId;
+ public int storyId;
+
+ public StoryKey(TLRPC.StoryItem storyItem) {
+ dialogId = storyItem.dialogId;
+ storyId = storyItem.id;
+ }
+ }
+
+ private final HashSet detectingPhotos = new HashSet<>();
+ private final HashSet translatingPhotos = new HashSet<>();
+
+ public void detectPhotoLanguage(MessageObject messageObject, Utilities.Callback done) {
+ if (messageObject == null || messageObject.messageOwner == null || !LanguageDetector.hasSupport() || TextUtils.isEmpty(messageObject.messageOwner.message)) {
+ return;
+ }
+ if (!TextUtils.isEmpty(messageObject.messageOwner.originalLanguage)) {
+ if (done != null) {
+ done.run(messageObject.messageOwner.originalLanguage);
+ }
+ return;
+ }
+
+ MessageKey key = new MessageKey(messageObject);
+ if (detectingPhotos.contains(key)) {
+ return;
+ }
+ detectingPhotos.add(key);
+
+ LanguageDetector.detectLanguage(messageObject.messageOwner.message, lng -> AndroidUtilities.runOnUIThread(() -> {
+ messageObject.messageOwner.originalLanguage = lng;
+ getMessagesStorage().updateMessageCustomParams(key.dialogId, messageObject.messageOwner);
+ detectingPhotos.remove(key);
+ if (done != null) {
+ done.run(lng);
+ }
+ }), err -> AndroidUtilities.runOnUIThread(() -> {
+ messageObject.messageOwner.originalLanguage = UNKNOWN_LANGUAGE;
+ getMessagesStorage().updateMessageCustomParams(key.dialogId, messageObject.messageOwner);
+ detectingPhotos.remove(key);
+ if (done != null) {
+ done.run(UNKNOWN_LANGUAGE);
+ }
+ }));
+ }
+
+ public boolean canTranslatePhoto(MessageObject messageObject, String detectedLanguage) {
+ if (messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.originalLanguage != null) {
+ detectedLanguage = messageObject.messageOwner.originalLanguage;
+ }
+ return messageObject != null && messageObject.messageOwner != null && !TextUtils.isEmpty(messageObject.messageOwner.message) && (
+ detectedLanguage == null && messageObject.messageOwner.translatedText != null && TextUtils.equals(messageObject.messageOwner.translatedToLanguage, TranslateAlert2.getToLanguage()) ||
+ detectedLanguage != null && !RestrictedLanguagesSelectActivity.getRestrictedLanguages().contains(messageObject.messageOwner.originalLanguage)
+ ) && !messageObject.translated;
+ }
+
+ public void translatePhoto(MessageObject messageObject, Runnable done) {
+ if (messageObject == null || messageObject.messageOwner == null) {
+ return;
+ }
+
+ final MessageKey key = new MessageKey(messageObject);
+
+ String toLang = TranslateAlert2.getToLanguage();
+
+ if (messageObject.messageOwner.translatedText != null && TextUtils.equals(messageObject.messageOwner.translatedToLanguage, toLang)) {
+ if (done != null) {
+ done.run();
+ }
+ return;
+ }
+ if (translatingPhotos.contains(key)) {
+ if (done != null) {
+ done.run();
+ }
+ return;
+ }
+
+ translatingPhotos.add(key);
+
+ TLRPC.TL_messages_translateText req = new TLRPC.TL_messages_translateText();
+ req.flags |= 2;
+ final TLRPC.TL_textWithEntities text = new TLRPC.TL_textWithEntities();
+ text.text = messageObject.messageOwner.message;
+ text.entities = messageObject.messageOwner.entities;
+ if (text.entities == null) {
+ text.entities = new ArrayList<>();
+ }
+ req.text.add(text);
+ req.to_lang = toLang;
+ final long start = System.currentTimeMillis();
+ getConnectionsManager().sendRequest(req, (res, err) -> {
+ if (res instanceof TLRPC.TL_messages_translateResult) {
+ ArrayList result = ((TLRPC.TL_messages_translateResult) res).result;
+ if (result.size() <= 0) {
+ AndroidUtilities.runOnUIThread(() -> {
+ messageObject.messageOwner.translatedToLanguage = toLang;
+ messageObject.messageOwner.translatedText = null;
+ getMessagesStorage().updateMessageCustomParams(key.dialogId, messageObject.messageOwner);
+ translatingPhotos.remove(key);
+ if (done != null) {
+ AndroidUtilities.runOnUIThread(done, Math.max(0, 400L - (System.currentTimeMillis() - start)));
+ }
+ });
+ return;
+ }
+ final TLRPC.TL_textWithEntities textWithEntities = result.get(0);
+ AndroidUtilities.runOnUIThread(() -> {
+ messageObject.messageOwner.translatedToLanguage = toLang;
+ messageObject.messageOwner.translatedText = TranslateAlert2.preprocess(text, textWithEntities);
+ getMessagesStorage().updateMessageCustomParams(key.dialogId, messageObject.messageOwner);
+ translatingPhotos.remove(key);
+ if (done != null) {
+ AndroidUtilities.runOnUIThread(done, Math.max(0, 400L - (System.currentTimeMillis() - start)));
+ }
+ });
+ } else {
+ AndroidUtilities.runOnUIThread(() -> {
+ messageObject.messageOwner.translatedToLanguage = toLang;
+ messageObject.messageOwner.translatedText = null;
+ getMessagesStorage().updateMessageCustomParams(key.dialogId, messageObject.messageOwner);
+ translatingPhotos.remove(key);
+ if (done != null) {
+ AndroidUtilities.runOnUIThread(done, Math.max(0, 400L - (System.currentTimeMillis() - start)));
+ }
+ });
+ }
+ });
+ }
+
+ private static class MessageKey {
+ public long dialogId;
+ public int id;
+
+ public MessageKey(MessageObject msg) {
+ dialogId = msg.getDialogId();
+ id = msg.getId();
+ }
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/VideoEditedInfo.java b/TMessagesProj/src/main/java/org/telegram/messenger/VideoEditedInfo.java
index 8f7838a84..0eb03d41f 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/VideoEditedInfo.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/VideoEditedInfo.java
@@ -107,6 +107,7 @@ public class VideoEditedInfo {
public static final int TYPE_STICKER = 0;
public static final int TYPE_TEXT = 1;
public static final int TYPE_PHOTO = 2;
+ public static final int TYPE_LOCATION = 3;
public byte type;
public byte subType;
@@ -115,6 +116,7 @@ public class VideoEditedInfo {
public float rotation;
public float width;
public float height;
+ public float additionalWidth, additionalHeight;
public String text;
public ArrayList entities = new ArrayList<>();
public int color;
@@ -146,6 +148,12 @@ public class VideoEditedInfo {
public AnimatedFileDrawable animatedFileDrawable;
public Canvas roundRadiusCanvas;
+ public TLRPC.MediaArea mediaArea;
+ public TLRPC.MessageMedia mediaGeo;
+ public float density;
+
+ public int W, H;
+
public MediaEntity() {
}
@@ -185,6 +193,20 @@ public class VideoEditedInfo {
document = TLRPC.Document.TLdeserialize(data, magic, false);
}
}
+ if (type == TYPE_LOCATION) {
+ density = data.readFloat(false);
+ mediaArea = TLRPC.MediaArea.TLdeserialize(data, data.readInt32(false), false);
+ mediaGeo = TLRPC.MessageMedia.TLdeserialize(data, data.readInt32(false), false);
+ if (data.remaining() > 0) {
+ int magic = data.readInt32(false);
+ if (magic == 0xdeadbeef) {
+ String emoji = data.readString(false);
+ if (mediaGeo instanceof TLRPC.TL_messageMediaVenue) {
+ ((TLRPC.TL_messageMediaVenue) mediaGeo).emoji = emoji;
+ }
+ }
+ }
+ }
}
public void serializeTo(AbstractSerializedData data, boolean full) {
@@ -218,6 +240,26 @@ public class VideoEditedInfo {
document.serializeToStream(data);
}
}
+ if (type == TYPE_LOCATION) {
+ data.writeFloat(density);
+ mediaArea.serializeToStream(data);
+ if (mediaGeo.provider == null) {
+ mediaGeo.provider = "";
+ }
+ if (mediaGeo.venue_id == null) {
+ mediaGeo.venue_id = "";
+ }
+ if (mediaGeo.venue_type == null) {
+ mediaGeo.venue_type = "";
+ }
+ mediaGeo.serializeToStream(data);
+ if (mediaGeo instanceof TLRPC.TL_messageMediaVenue && ((TLRPC.TL_messageMediaVenue) mediaGeo).emoji != null) {
+ data.writeInt32(0xdeadbeef);
+ data.writeString(((TLRPC.TL_messageMediaVenue) mediaGeo).emoji);
+ } else {
+ data.writeInt32(TLRPC.TL_null.constructor);
+ }
+ }
}
public MediaEntity copy() {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
index 5db3620d5..4c91e7555 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
@@ -254,7 +254,7 @@ public class Browser {
if (tryTelegraph) {
try {
String host = AndroidUtilities.getHostAuthority(uri);
- if (isTelegraphUrl(host, true) || uri.toString().toLowerCase().contains("telegram.org/faq") || uri.toString().toLowerCase().contains("telegram.org/privacy")) {
+ if (isTelegraphUrl(host, true) || "telegram.org".equalsIgnoreCase(host) && (uri.toString().toLowerCase().contains("telegram.org/faq") || uri.toString().toLowerCase().contains("telegram.org/privacy") || uri.toString().toLowerCase().contains("telegram.org/blog"))) {
final AlertDialog[] progressDialog = new AlertDialog[] {
new AlertDialog(context, AlertDialog.ALERT_TYPE_SPINNER)
};
@@ -515,6 +515,8 @@ public class Browser {
}
return true;
}
+ } else if ("telegram.org".equals(host) && uri != null && uri.getPath() != null && uri.getPath().startsWith("/blog/")) {
+ return true;
} else if (all) {
if (host.endsWith("telegram.org") || host.endsWith("telegra.ph") || host.endsWith("telesco.pe")) {
return true;
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 224baaac4..f96214372 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/video/TextureRenderer.java
@@ -57,12 +57,14 @@ import org.telegram.messenger.MessageObject;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.messenger.VideoEditedInfo;
+import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.AnimatedEmojiDrawable;
import org.telegram.ui.Components.AnimatedEmojiSpan;
import org.telegram.ui.Components.AnimatedFileDrawable;
import org.telegram.ui.Components.EditTextEffects;
import org.telegram.ui.Components.FilterShaders;
import org.telegram.ui.Components.Paint.Views.EditTextOutline;
+import org.telegram.ui.Components.Paint.Views.LocationMarker;
import org.telegram.ui.Components.Paint.Views.PaintTextOptionsView;
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.Rect;
@@ -556,10 +558,13 @@ public class TextureRenderer {
private void drawEntity(VideoEditedInfo.MediaEntity entity, int textColor) {
if (entity.ptr != 0) {
- RLottieDrawable.getFrame(entity.ptr, (int) entity.currentFrame, stickerBitmap, 512, 512, stickerBitmap.getRowBytes(), true);
- applyRoundRadius(entity, stickerBitmap, (entity.subType & 8) != 0 ? textColor : 0);
+ if (entity.bitmap == null || entity.W <= 0 || entity.H <= 0) {
+ return;
+ }
+ RLottieDrawable.getFrame(entity.ptr, (int) entity.currentFrame, entity.bitmap, entity.W, entity.H, entity.bitmap.getRowBytes(), true);
+ applyRoundRadius(entity, entity.bitmap, (entity.subType & 8) != 0 ? textColor : 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, stickerTexture[0]);
- GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, stickerBitmap, 0);
+ GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, entity.bitmap, 0);
entity.currentFrame += entity.framesPerDraw;
if (entity.currentFrame >= entity.metadata[0]) {
entity.currentFrame = 0;
@@ -594,7 +599,7 @@ public class TextureRenderer {
if (entity.bitmap != null) {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, stickerTexture[0]);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, entity.bitmap, 0);
- drawTexture(false, stickerTexture[0], entity.x, entity.y, entity.width, entity.height, entity.rotation, entity.type == VideoEditedInfo.MediaEntity.TYPE_PHOTO && (entity.subType & 2) != 0);
+ drawTexture(false, stickerTexture[0], entity.x - entity.additionalWidth / 2f, entity.y - entity.additionalHeight / 2f, entity.width + entity.additionalWidth, entity.height + entity.additionalHeight, entity.rotation, entity.type == VideoEditedInfo.MediaEntity.TYPE_PHOTO && (entity.subType & 2) != 0);
}
if (entity.entities != null && !entity.entities.isEmpty()) {
for (int i = 0; i < entity.entities.size(); ++i) {
@@ -899,6 +904,7 @@ public class TextureRenderer {
initStickerEntity(entity);
} else if (entity.type == VideoEditedInfo.MediaEntity.TYPE_TEXT) {
EditTextOutline editText = new EditTextOutline(ApplicationLoader.applicationContext);
+ editText.getPaint().setAntiAlias(true);
editText.betterFraming = useMatrixForImagePath;
editText.drawAnimatedEmojiDrawables = false;
editText.setBackgroundColor(Color.TRANSPARENT);
@@ -916,7 +922,6 @@ public class TextureRenderer {
e.entity = new VideoEditedInfo.MediaEntity();
e.entity.text = e.documentAbsolutePath;
e.entity.subType = e.subType;
- initStickerEntity(e.entity);
AnimatedEmojiSpan span = new AnimatedEmojiSpan(0L, 1f, editText.getPaint().getFontMetricsInt()) {
@Override
public void draw(@NonNull Canvas canvas, CharSequence charSequence, int start, int end, float x, int top, int y, int bottom, @NonNull Paint paint) {
@@ -940,6 +945,9 @@ public class TextureRenderer {
e.entity.x = tcx - e.entity.width / 2f;
e.entity.y = tcy - e.entity.height / 2f;
e.entity.rotation = entity.rotation;
+
+ if (e.entity.bitmap == null)
+ initStickerEntity(e.entity);
}
};
text.setSpan(span, e.offset, e.offset + e.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@@ -1013,6 +1021,57 @@ public class TextureRenderer {
entity.bitmap = Bitmap.createBitmap(entity.viewWidth, entity.viewHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(entity.bitmap);
editText.draw(canvas);
+ } else if (entity.type == VideoEditedInfo.MediaEntity.TYPE_LOCATION) {
+ LocationMarker marker = new LocationMarker(ApplicationLoader.applicationContext, entity.density);
+ marker.setText(entity.text);
+ marker.setType(entity.subType, entity.color);
+ marker.setMaxWidth(entity.viewWidth);
+ if (entity.entities.size() == 1) {
+ marker.forceEmoji();
+ }
+ marker.measure(View.MeasureSpec.makeMeasureSpec(entity.viewWidth, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(entity.viewHeight, View.MeasureSpec.EXACTLY));
+ marker.layout(0, 0, entity.viewWidth, entity.viewHeight);
+ float scale = entity.width * transformedWidth / entity.viewWidth;
+ int w = (int) (entity.viewWidth * scale), h = (int) (entity.viewHeight * scale), pad = 8;
+ entity.bitmap = Bitmap.createBitmap(w + pad + pad, h + pad + pad, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(entity.bitmap);
+ canvas.translate(pad, pad);
+ canvas.scale(scale, scale);
+ marker.draw(canvas);
+ entity.additionalWidth = (2 * pad) * scale / transformedWidth;
+ entity.additionalHeight = (2 * pad) * scale / transformedHeight;
+ if (entity.entities.size() == 1) {
+ VideoEditedInfo.EmojiEntity e = entity.entities.get(0);
+ e.entity = new VideoEditedInfo.MediaEntity();
+ e.entity.text = e.documentAbsolutePath;
+ e.entity.subType = e.subType;
+
+ RectF bounds = new RectF();
+ marker.getEmojiBounds(bounds);
+
+ float tcx = entity.x + (bounds.centerX()) / entity.viewWidth * entity.width;
+ float tcy = entity.y + (bounds.centerY()) / entity.viewHeight * entity.height;
+
+ if (entity.rotation != 0) {
+ float mx = entity.x + entity.width / 2f;
+ float my = entity.y + entity.height / 2f;
+ float ratio = transformedWidth / (float) transformedHeight;
+ float x1 = tcx - mx;
+ float y1 = (tcy - my) / ratio;
+ tcx = (float) (x1 * Math.cos(-entity.rotation) - y1 * Math.sin(-entity.rotation)) + mx;
+ tcy = (float) (x1 * Math.sin(-entity.rotation) + y1 * Math.cos(-entity.rotation)) * ratio + my;
+ }
+
+ e.entity.width = (float) bounds.width() / entity.viewWidth * entity.width;
+ e.entity.height = (float) bounds.height() / entity.viewHeight * entity.height;
+ e.entity.width *= LocationMarker.SCALE;
+ e.entity.height *= LocationMarker.SCALE;
+ e.entity.x = tcx - e.entity.width / 2f;
+ e.entity.y = tcy - e.entity.height / 2f;
+ e.entity.rotation = entity.rotation;
+
+ initStickerEntity(e.entity);
+ }
}
}
} catch (Throwable e) {
@@ -1022,9 +1081,23 @@ public class TextureRenderer {
}
private void initStickerEntity(VideoEditedInfo.MediaEntity entity) {
+ entity.W = (int) (entity.width * transformedWidth);
+ entity.H = (int) (entity.height * transformedHeight);
+ if (entity.W > 512) {
+ entity.H = (int) (entity.H / (float) entity.W * 512);
+ entity.W = 512;
+ }
+ if (entity.H > 512) {
+ entity.W = (int) (entity.W / (float) entity.H * 512);
+ entity.H = 512;
+ }
if ((entity.subType & 1) != 0) {
+ if (entity.W <= 0 || entity.H <= 0) {
+ return;
+ }
+ entity.bitmap = Bitmap.createBitmap(entity.W, entity.H, Bitmap.Config.ARGB_8888);
entity.metadata = new int[3];
- entity.ptr = RLottieDrawable.create(entity.text, null, 512, 512, entity.metadata, false, null, false, 0);
+ entity.ptr = RLottieDrawable.create(entity.text, null, entity.W, entity.H, entity.metadata, false, null, false, 0);
entity.framesPerDraw = entity.metadata[1] / videoFps;
} else if ((entity.subType & 4) != 0) {
entity.animatedFileDrawable = new AnimatedFileDrawable(new File(entity.text), true, 0, 0, null, null, null, 0, UserConfig.selectedAccount, true, 512, 512, null);
@@ -1149,6 +1222,10 @@ public class TextureRenderer {
if (entity.view instanceof EditTextEffects) {
((EditTextEffects) entity.view).recycleEmojis();
}
+ if (entity.bitmap != null) {
+ entity.bitmap.recycle();
+ entity.bitmap = null;
+ }
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
index 5a5d00fbd..401d60e2e 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;
@@ -412,6 +413,9 @@ public class ConnectionsManager extends BaseController {
}
public void bindRequestToGuid(int requestToken, int guid) {
+ if (guid == 0) {
+ return;
+ }
native_bindRequestToGuid(currentAccount, requestToken, guid);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
index d9ee03b66..996df75f8 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
@@ -25,6 +25,7 @@ import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Stories.MessageMediaStoryFull;
import org.telegram.ui.Stories.MessageMediaStoryFull_old;
+import org.telegram.ui.Stories.recorder.StoryPrivacyBottomSheet;
import java.util.ArrayList;
import java.util.HashMap;
@@ -73,7 +74,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 = 160;
+ public static final int LAYER = 161;
public static class TL_stats_megagroupStats extends TLObject {
public static int constructor = 0xef7ff916;
@@ -8796,6 +8797,10 @@ public class TLRPC {
public static class TL_messageMediaVenue extends MessageMedia {
public static int constructor = 0x2ec0533f;
+ public String icon; //custom
+ public String emoji; //custom
+ public long query_id; //custom
+ public String result_id; //custom
public void readParams(AbstractSerializedData stream, boolean exception) {
geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception);
@@ -23810,8 +23815,12 @@ public class TLRPC {
usernames.add(object);
}
}
- if ((flags2 & 32) != 0) {
- stories_max_id = stream.readInt32(exception);
+ try {
+ if ((flags2 & 32) != 0) {
+ stories_max_id = stream.readInt32(exception);
+ }
+ } catch (Throwable e) {
+ FileLog.e(e);
}
}
@@ -32931,7 +32940,7 @@ public class TLRPC {
case 0x26ffde7d:
result = new TL_updateDialogFilter();
break;
- case 0x246a4b22:
+ case 0xebe07752:
result = new TL_updatePeerBlocked();
break;
case 0xed85eab5:
@@ -32949,6 +32958,9 @@ public class TLRPC {
case 0x74d8be99:
result = new TL_updateSavedRingtones();
break;
+ case 0x2c084dc1:
+ result = new TL_updateStoriesStealthMode();
+ break;
case 0x84cd5a:
result = new TL_updateTranscribedAudio();
break;
@@ -32985,6 +32997,9 @@ public class TLRPC {
case 0xc32d5b12:
result = new TL_updateDeleteChannelMessages();
break;
+ case 0xe3a73d20:
+ result = new TL_updateSentStoryReaction();
+ break;
case 0xf227868c:
result = new TL_updateUserPhoto();
break;
@@ -34556,20 +34571,26 @@ public class TLRPC {
}
public static class TL_updatePeerBlocked extends Update {
- public static int constructor = 0x246a4b22;
+ public static int constructor = 0xebe07752;
- public Peer peer_id;
+ public int flags;
public boolean blocked;
+ public boolean blocked_my_stories_from;
+ public Peer peer_id;
public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ blocked = (flags & 1) != 0;
+ blocked_my_stories_from = (flags & 2) != 0;
peer_id = Peer.TLdeserialize(stream, stream.readInt32(exception), exception);
- blocked = stream.readBool(exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = blocked ? (flags | 1) : (flags &~ 1);
+ flags = blocked_my_stories_from ? (flags | 2) : (flags &~ 2);
+ stream.writeInt32(flags);
peer_id.serializeToStream(stream);
- stream.writeBool(blocked);
}
}
@@ -34908,6 +34929,27 @@ public class TLRPC {
}
}
+ public static class TL_updateSentStoryReaction extends Update {
+ public static int constructor = 0xe3a73d20;
+
+ public long user_id;
+ public int story_id;
+ public Reaction reaction;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ user_id = stream.readInt64(exception);
+ story_id = stream.readInt32(exception);
+ reaction = Reaction.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt64(user_id);
+ stream.writeInt32(story_id);
+ reaction.serializeToStream(stream);
+ }
+ }
+
public static class TL_updateChannelMessageForwards extends Update {
public static int constructor = 0xd29a27f4;
@@ -48673,6 +48715,7 @@ public class TLRPC {
public boolean voice_messages_forbidden;
public boolean translations_disabled;
public boolean stories_pinned_available;
+ public boolean blocked_my_stories_from;
public User user;
public String about;
public TL_contacts_link_layer101 link;
@@ -48759,6 +48802,7 @@ public class TLRPC {
voice_messages_forbidden = (flags & 1048576) != 0;
translations_disabled = (flags & 8388608) != 0;
stories_pinned_available = (flags & 67108864) != 0;
+ blocked_my_stories_from = (flags & 134217728) != 0;
id = stream.readInt64(exception);
if ((flags & 2) != 0) {
about = stream.readString(exception);
@@ -48835,6 +48879,7 @@ public class TLRPC {
flags = voice_messages_forbidden ? (flags | 1048576) : (flags &~ 1048576);
flags = translations_disabled ? (flags | 8388608) : (flags &~ 8388608);
flags = stories_pinned_available ? (flags | 67108864) : (flags &~ 67108864);
+ flags = blocked_my_stories_from ? (flags | 134217728) : (flags &~ 134217728);
stream.writeInt32(flags);
stream.writeInt64(id);
if ((flags & 2) != 0) {
@@ -52547,8 +52592,6 @@ public class TLRPC {
}
}
-
-
public static abstract class Reaction extends TLObject {
public static Reaction TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -53365,8 +53408,10 @@ public class TLRPC {
}
public static class TL_contacts_block extends TLObject {
- public static int constructor = 0x68cc1411;
+ public static int constructor = 0x2e2e8734;
+ public int flags;
+ public boolean my_stories_from;
public InputPeer id;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -53375,13 +53420,17 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = my_stories_from ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
id.serializeToStream(stream);
}
}
public static class TL_contacts_unblock extends TLObject {
- public static int constructor = 0xbea65d50;
+ public static int constructor = 0xb550d328;
+ public int flags;
+ public boolean my_stories_from;
public InputPeer id;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -53390,13 +53439,17 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = my_stories_from ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
id.serializeToStream(stream);
}
}
public static class TL_contacts_getBlocked extends TLObject {
- public static int constructor = 0xf57c350f;
+ public static int constructor = 0x9a868f80;
+ public int flags;
+ public boolean my_stories_from;
public int offset;
public int limit;
@@ -53406,6 +53459,8 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = my_stories_from ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
stream.writeInt32(offset);
stream.writeInt32(limit);
}
@@ -69221,8 +69276,10 @@ public class TLRPC {
public boolean edited;
public ArrayList entities = new ArrayList<>();
public MessageMedia media;
+ public ArrayList media_areas = new ArrayList();
public ArrayList privacy = new ArrayList<>();
- public TL_storyViews views;
+ public StoryViews views;
+ public Reaction sent_reaction;
public long lastUpdateTime; //custom
public String attachPath; //custom
public String firstFramePath; //custom
@@ -69231,13 +69288,21 @@ public class TLRPC {
public int messageId;//custom
public int messageType;//custom
public int fileReference;
+ public String detectedLng; //custom
+ public String translatedLng; //custom
+ public boolean translated; //custom
+ public TLRPC.TL_textWithEntities translatedText; //custom
+ public StoryPrivacyBottomSheet.StoryPrivacy parsedPrivacy; //custom
public static StoryItem TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
StoryItem result = null;
switch (constructor) {
- case 0x562aa637:
+ case 0x44c457ce:
result = new TL_storyItem();
break;
+ case 0x562aa637:
+ result = new TL_storyItem_layer160();
+ break;
case 0x51e6ee4f:
result = new TL_storyItemDeleted();
break;
@@ -69255,25 +69320,35 @@ public class TLRPC {
}
}
- public static class TL_storyViews extends TLObject {
- public static int constructor = 0xd36760cf;
+ public static abstract class StoryViews extends TLObject {
public int flags;
public int views_count;
+ public int reactions_count;
public ArrayList recent_viewers = new ArrayList<>();
- public static TL_storyViews TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
- if (TL_storyViews.constructor != constructor) {
- if (exception) {
- throw new RuntimeException(String.format("can't parse magic %x in TL_storyViews", constructor));
- } else {
- return null;
- }
+ public static StoryViews TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ StoryViews result = null;
+ switch (constructor) {
+ case 0xd36760cf:
+ result = new TL_storyViews_layer160();
+ break;
+ case 0xc64c0b97:
+ result = new TL_storyViews();
+ break;
+ }
+ if (result == null && exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in StoryViews", constructor));
+ }
+ if (result != null) {
+ result.readParams(stream, exception);
}
- TL_storyViews result = new TL_storyViews();
- result.readParams(stream, exception);
return result;
}
+ }
+
+ public static class TL_storyViews_layer160 extends StoryViews {
+ public static int constructor = 0xd36760cf;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
@@ -69308,7 +69383,175 @@ public class TLRPC {
}
}
+ public static class TL_storyViews extends StoryViews {
+ public static int constructor = 0xc64c0b97;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ views_count = stream.readInt32(exception);
+ reactions_count = stream.readInt32(exception);
+ if ((flags & 1) != 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++) {
+ recent_viewers.add(stream.readInt64(exception));
+ }
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ stream.writeInt32(views_count);
+ stream.writeInt32(reactions_count);
+ if ((flags & 1) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = recent_viewers.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeInt64(recent_viewers.get(a));
+ }
+ }
+ }
+ }
+
public static class TL_storyItem extends StoryItem {
+ public static int constructor = 0x44c457ce;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ pinned = (flags & 32) != 0;
+ isPublic = (flags & 128) != 0;
+ close_friends = (flags & 256) != 0;
+ min = (flags & 512) != 0;
+ noforwards = (flags & 1024) != 0;
+ edited = (flags & 2048) != 0;
+ contacts = (flags & 4096) != 0;
+ selected_contacts = (flags & 8192) != 0;
+ id = stream.readInt32(exception);
+ date = stream.readInt32(exception);
+ expire_date = stream.readInt32(exception);
+ if ((flags & 1) != 0) {
+ caption = stream.readString(exception);
+ }
+ if ((flags & 2) != 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++) {
+ MessageEntity object = MessageEntity.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ entities.add(object);
+ }
+ }
+ media = MessageMedia.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if ((flags & 16384) != 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++) {
+ MediaArea object = MediaArea.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ media_areas.add(object);
+ }
+ }
+ if ((flags & 4) != 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++) {
+ PrivacyRule object = PrivacyRule.TLdeserialize(stream, stream.readInt32(exception), exception);
+ if (object == null) {
+ return;
+ }
+ privacy.add(object);
+ }
+ }
+ if ((flags & 8) != 0) {
+ views = StoryViews.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ if ((flags & 32768) != 0) {
+ sent_reaction = Reaction.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = pinned ? (flags | 32) : (flags &~ 32);
+ flags = isPublic ? (flags | 128) : (flags &~ 128);
+ flags = close_friends ? (flags | 256) : (flags &~ 256);
+ flags = min ? (flags | 512) : (flags &~ 512);
+ flags = noforwards ? (flags | 1024) : (flags &~ 1024);
+ flags = edited ? (flags | 2048) : (flags &~ 2048);
+ flags = contacts ? (flags | 4096) : (flags &~ 4096);
+ flags = selected_contacts ? (flags | 8192) : (flags &~ 8192);
+ stream.writeInt32(flags);
+ stream.writeInt32(id);
+ stream.writeInt32(date);
+ stream.writeInt32(expire_date);
+ if ((flags & 1) != 0) {
+ stream.writeString(caption);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = entities.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ entities.get(a).serializeToStream(stream);
+ }
+ }
+ media.serializeToStream(stream);
+ if ((flags & 16384) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = media_areas.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ media_areas.get(a).serializeToStream(stream);
+ }
+ }
+ if ((flags & 4) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = privacy.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ privacy.get(a).serializeToStream(stream);
+ }
+ }
+ if ((flags & 8) != 0) {
+ views.serializeToStream(stream);
+ }
+ if ((flags & 32768) != 0) {
+ sent_reaction.serializeToStream(stream);
+ }
+ }
+ }
+
+ public static class TL_storyItem_layer160 extends TL_storyItem {
public static int constructor = 0x562aa637;
public void readParams(AbstractSerializedData stream, boolean exception) {
@@ -69363,7 +69606,7 @@ public class TLRPC {
}
}
if ((flags & 8) != 0) {
- views = TL_storyViews.TLdeserialize(stream, stream.readInt32(exception), exception);
+ views = StoryViews.TLdeserialize(stream, stream.readInt32(exception), exception);
}
}
@@ -69440,11 +69683,154 @@ public class TLRPC {
stream.writeInt32(expire_date);
}
}
+
+ public static class TL_mediaAreaCoordinates extends TLObject {
+ public static final int constructor = 0x3d1ea4e;
+
+ public double x;
+ public double y;
+ public double w;
+ public double h;
+ public double rotation;
+
+ public static TL_mediaAreaCoordinates TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_mediaAreaCoordinates.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_mediaAreaCoordinates", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_mediaAreaCoordinates result = new TL_mediaAreaCoordinates();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ @Override
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ x = stream.readDouble(exception);
+ y = stream.readDouble(exception);
+ w = stream.readDouble(exception);
+ h = stream.readDouble(exception);
+ rotation = stream.readDouble(exception);
+ }
+
+ @Override
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeDouble(x);
+ stream.writeDouble(y);
+ stream.writeDouble(w);
+ stream.writeDouble(h);
+ stream.writeDouble(rotation);
+ }
+ }
+
+ public static class MediaArea extends TLObject {
+ public TL_mediaAreaCoordinates coordinates;
+
+ public static MediaArea TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ MediaArea result = null;
+ switch (constructor) {
+ case TL_mediaAreaVenue.constructor:
+ result = new TL_mediaAreaVenue();
+ break;
+ case TL_mediaAreaGeoPoint.constructor:
+ result = new TL_mediaAreaGeoPoint();
+ break;
+ case TL_inputMediaAreaVenue.constructor:
+ result = new TL_inputMediaAreaVenue();
+ break;
+ }
+ if (result == null && exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in MediaArea", constructor));
+ }
+ if (result != null) {
+ result.readParams(stream, exception);
+ }
+ return result;
+ }
+ }
+
+ public static class TL_mediaAreaVenue extends MediaArea {
+ public static final int constructor = 0xbe82db9c;
+
+ public GeoPoint geo;
+ public String title;
+ public String address;
+ public String provider;
+ public String venue_id;
+ public String venue_type;
+
+ @Override
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ coordinates = TL_mediaAreaCoordinates.TLdeserialize(stream, stream.readInt32(exception), exception);
+ geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception);
+ title = stream.readString(exception);
+ address = stream.readString(exception);
+ provider = stream.readString(exception);
+ venue_id = stream.readString(exception);
+ venue_type = stream.readString(exception);
+ }
+
+ @Override
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ coordinates.serializeToStream(stream);
+ geo.serializeToStream(stream);
+ stream.writeString(title);
+ stream.writeString(address);
+ stream.writeString(provider);
+ stream.writeString(venue_id);
+ stream.writeString(venue_type);
+ }
+ }
+
+ public static class TL_inputMediaAreaVenue extends MediaArea {
+ public static final int constructor = 0xb282217f;
+
+ public long query_id;
+ public String result_id;
+
+ @Override
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ coordinates = TL_mediaAreaCoordinates.TLdeserialize(stream, stream.readInt32(exception), exception);
+ query_id = stream.readInt64(exception);
+ result_id = stream.readString(exception);
+ }
+
+ @Override
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ coordinates.serializeToStream(stream);
+ stream.writeInt64(query_id);
+ stream.writeString(result_id);
+ }
+ }
+
+ public static class TL_mediaAreaGeoPoint extends MediaArea {
+ public static final int constructor = 0xdf8b3b22;
+
+ public GeoPoint geo;
+
+ @Override
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ coordinates = TL_mediaAreaCoordinates.TLdeserialize(stream, stream.readInt32(exception), exception);
+ geo = GeoPoint.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+
+ @Override
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ coordinates.serializeToStream(stream);
+ geo.serializeToStream(stream);
+ }
+ }
public static class TL_stories_storyViews extends TLObject {
public static int constructor = 0xde9eed1d;
- public ArrayList views = new ArrayList<>();
+ public ArrayList views = new ArrayList<>();
public ArrayList users = new ArrayList<>();
public static TL_stories_storyViews TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -69470,7 +69856,7 @@ public class TLRPC {
}
int count = stream.readInt32(exception);
for (int a = 0; a < count; a++) {
- TL_storyViews object = TL_storyViews.TLdeserialize(stream, stream.readInt32(exception), exception);
+ StoryViews object = StoryViews.TLdeserialize(stream, stream.readInt32(exception), exception);
if (object == null) {
return;
}
@@ -69511,10 +69897,14 @@ public class TLRPC {
}
public static class TL_storyView extends TLObject {
- public static int constructor = 0xa71aacc2;
+ public static int constructor = 0xb0bdeac5;
+ public int flags;
+ public boolean blocked;
+ public boolean blocked_my_stories_from;
public long user_id;
public int date;
+ public Reaction reaction;
public static TL_storyView TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_storyView.constructor != constructor) {
@@ -69530,14 +69920,26 @@ public class TLRPC {
}
public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ blocked = (flags & 1) != 0;
+ blocked_my_stories_from = (flags & 2) != 0;
user_id = stream.readInt64(exception);
date = stream.readInt32(exception);
+ if ((flags & 4) != 0) {
+ reaction = Reaction.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = blocked ? (flags | 1) : (flags &~ 1);
+ flags = blocked_my_stories_from ? (flags | 2) : (flags &~ 2);
+ stream.writeInt32(flags);
stream.writeInt64(user_id);
stream.writeInt32(date);
+ if ((flags & 4) != 0) {
+ reaction.serializeToStream(stream);
+ }
}
}
@@ -69657,10 +70059,10 @@ public class TLRPC {
public static stories_AllStories TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
stories_AllStories result = null;
switch (constructor) {
- case 0x47e0a07e:
+ case 0x1158fe3e:
result = new TL_stories_allStoriesNotModified();
break;
- case 0x839e0428:
+ case 0x519d899e:
result = new TL_stories_allStories();
break;
}
@@ -69675,22 +70077,28 @@ public class TLRPC {
}
public static class TL_stories_allStoriesNotModified extends stories_AllStories {
- public static int constructor = 0x47e0a07e;
+ public static int constructor = 0x1158fe3e;
+ public int flags;
public String state;
+ public TL_storiesStealthMode stealth_mode;
public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
state = stream.readString(exception);
+ stealth_mode = TL_storiesStealthMode.TLdeserialize(stream, stream.readInt32(exception), exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ stream.writeInt32(flags);
stream.writeString(state);
+ stealth_mode.serializeToStream(stream);
}
}
public static class TL_stories_allStories extends stories_AllStories {
- public static int constructor = 0x839e0428;
+ public static int constructor = 0x519d899e;
public int flags;
public boolean has_more;
@@ -69698,6 +70106,7 @@ public class TLRPC {
public String state;
public ArrayList user_stories = new ArrayList<>();
public ArrayList users = new ArrayList<>();
+ public TL_storiesStealthMode stealth_mode;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
@@ -69734,6 +70143,7 @@ public class TLRPC {
}
users.add(object);
}
+ stealth_mode = TL_storiesStealthMode.TLdeserialize(stream, stream.readInt32(exception), exception);
}
public void serializeToStream(AbstractSerializedData stream) {
@@ -69754,16 +70164,30 @@ public class TLRPC {
for (int a = 0; a < count; a++) {
users.get(a).serializeToStream(stream);
}
+ stealth_mode.serializeToStream(stream);
+ }
+ }
+
+ public static class TL_stories_canSendStory extends TLObject {
+ public static int constructor = 0xb100d45d;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Bool.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
}
}
public static class TL_stories_sendStory extends TLObject {
- public static int constructor = 0x424cd47a;
+ public static int constructor = 0xd455fcec;
public int flags;
public boolean pinned;
public boolean noforwards;
public InputMedia media;
+ public ArrayList media_areas = new ArrayList<>();
public String caption;
public ArrayList entities = new ArrayList<>();
public ArrayList privacy_rules = new ArrayList<>();
@@ -69780,6 +70204,14 @@ public class TLRPC {
flags = noforwards ? (flags | 16) : (flags &~ 16);
stream.writeInt32(flags);
media.serializeToStream(stream);
+ if ((flags & 32) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = media_areas.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; ++a) {
+ media_areas.get(a).serializeToStream(stream);
+ }
+ }
if ((flags & 1) != 0) {
stream.writeString(caption);
}
@@ -69857,11 +70289,12 @@ public class TLRPC {
}
public static class TL_stories_editStory extends TLObject {
- public static int constructor = 0x2aae7a41;
+ public static int constructor = 0xa9b91ae4;
public int flags;
public int id;
public InputMedia media;
+ public ArrayList media_areas = new ArrayList<>();
public String caption;
public ArrayList entities = new ArrayList<>();
public ArrayList privacy_rules = new ArrayList<>();
@@ -69877,6 +70310,14 @@ public class TLRPC {
if ((flags & 1) != 0) {
media.serializeToStream(stream);
}
+ if ((flags & 8) != 0) {
+ stream.writeInt32(0x1cb5c415);
+ int count = media_areas.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ media_areas.get(a).serializeToStream(stream);
+ }
+ }
if ((flags & 2) != 0) {
stream.writeString(caption);
}
@@ -69938,6 +70379,31 @@ public class TLRPC {
stream.writeBool(hidden);
}
}
+
+ public static class TL_contacts_setBlocked extends TLObject {
+ public static int constructor = 0x94c65c76;
+
+ public int flags;
+ public boolean my_stories_from;
+ public ArrayList id = new ArrayList<>();
+ public int limit;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Bool.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = my_stories_from ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
+ stream.writeInt32(0x1cb5c415);
+ stream.writeInt32(id.size());
+ for (int i = 0; i < id.size(); ++i) {
+ id.get(i).serializeToStream(stream);
+ }
+ stream.writeInt32(limit);
+ }
+ }
public static class TL_stories_stories extends TLObject {
public static int constructor = 0x4fe57df1;
@@ -70099,11 +70565,14 @@ public class TLRPC {
}
public static class TL_stories_storyViewsList extends TLObject {
- public static int constructor = 0xfb3f77ac;
+ public static int constructor = 0x46e9b9ec;
+ public int flags;
public int count;
+ public int reactions_count;
public ArrayList views = new ArrayList<>();
public ArrayList users = new ArrayList<>();
+ public String next_offset = "";
public static TL_stories_storyViewsList TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
if (TL_stories_storyViewsList.constructor != constructor) {
@@ -70119,7 +70588,9 @@ public class TLRPC {
}
public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
count = stream.readInt32(exception);
+ reactions_count = stream.readInt32(exception);
int magic = stream.readInt32(exception);
if (magic != 0x1cb5c415) {
if (exception) {
@@ -70150,11 +70621,16 @@ public class TLRPC {
}
users.add(object);
}
+ if ((flags & 1) != 0) {
+ next_offset = stream.readString(exception);
+ }
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ stream.writeInt32(flags);
stream.writeInt32(count);
+ stream.writeInt32(reactions_count);
stream.writeInt32(0x1cb5c415);
int count = views.size();
stream.writeInt32(count);
@@ -70167,6 +70643,9 @@ public class TLRPC {
for (int a = 0; a < count; a++) {
users.get(a).serializeToStream(stream);
}
+ if ((flags & 1) != 0) {
+ stream.writeString(next_offset);
+ }
}
}
@@ -70193,11 +70672,14 @@ public class TLRPC {
}
public static class TL_stories_getStoryViewsList extends TLObject {
- public static int constructor = 0x4b3b5e97;
+ public static int constructor = 0xf95f61a4;
+ public int flags;
+ public boolean just_contacts;
+ public boolean reactions_first;
+ public String q;
public int id;
- public int offset_date;
- public long offset_id;
+ public String offset;
public int limit;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
@@ -70206,9 +70688,14 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
+ flags = just_contacts ? (flags | 1) : (flags &~ 1);
+ flags = reactions_first ? (flags | 4) : (flags &~ 4);
+ stream.writeInt32(flags);
+ if ((flags & 2) != 0) {
+ stream.writeString(q);
+ }
stream.writeInt32(id);
- stream.writeInt32(offset_date);
- stream.writeInt64(offset_id);
+ stream.writeString(offset);
stream.writeInt32(limit);
}
}
@@ -70497,6 +70984,104 @@ public class TLRPC {
}
}
+ public static class TL_updateStoriesStealthMode extends Update {
+ public static int constructor = 0x2c084dc1;
+
+ public TL_storiesStealthMode stealth_mode;
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ stealth_mode = TL_storiesStealthMode.TLdeserialize(stream, stream.readInt32(exception), exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stealth_mode.serializeToStream(stream);
+ }
+ }
+
+ public static class TL_storiesStealthMode extends TLObject {
+ public static int constructor = 0x712e27fd;
+
+ public int flags;
+ public int active_until_date;
+ public int cooldown_until_date;
+
+ public static TL_storiesStealthMode TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) {
+ if (TL_storiesStealthMode.constructor != constructor) {
+ if (exception) {
+ throw new RuntimeException(String.format("can't parse magic %x in TL_storiesStealthMode", constructor));
+ } else {
+ return null;
+ }
+ }
+ TL_storiesStealthMode result = new TL_storiesStealthMode();
+ result.readParams(stream, exception);
+ return result;
+ }
+
+ public void readParams(AbstractSerializedData stream, boolean exception) {
+ flags = stream.readInt32(exception);
+ if ((flags & 1) != 0) {
+ active_until_date = stream.readInt32(exception);
+ }
+ if ((flags & 2) != 0) {
+ cooldown_until_date = stream.readInt32(exception);
+ }
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ if ((flags & 1) != 0) {
+ stream.writeInt32(active_until_date);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeInt32(cooldown_until_date);
+ }
+ }
+ }
+
+ public static class TL_stories_activateStealthMode extends TLObject {
+ public static int constructor = 0x57bbd166;
+
+ public int flags;
+ public boolean past;
+ public boolean future;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Updates.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = past ? (flags | 1) : (flags &~ 1);
+ flags = future ? (flags | 2) : (flags &~ 2);
+ stream.writeInt32(flags);
+ }
+ }
+
+ public static class TL_stories_sendReaction extends TLObject {
+ public static int constructor = 0x49aaa9b3;
+
+ public int flags;
+ public boolean add_to_recent;
+ public InputUser user_id;
+ public int story_id;
+ public Reaction reaction;
+
+ public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
+ return Updates.TLdeserialize(stream, constructor, exception);
+ }
+
+ public void serializeToStream(AbstractSerializedData stream) {
+ stream.writeInt32(constructor);
+ flags = add_to_recent ? (flags | 1) : (flags &~ 1);
+ stream.writeInt32(flags);
+ user_id.serializeToStream(stream);
+ stream.writeInt32(story_id);
+ reaction.serializeToStream(stream);
+ }
+ }
//functions
public static class Vector extends TLObject {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
index 48123b210..5d301f725 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
@@ -1226,8 +1226,8 @@ public class ActionBar extends FrameLayout {
if (searchFieldIsVisible && !this.isSearchFieldVisible) {
menuWidth = MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST);
menu.measure(menuWidth, actionBarHeightSpec);
- int itemsWidth = menu.getItemsMeasuredWidth();
- menuWidth = MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 74 : 66) + menu.getItemsMeasuredWidth(), MeasureSpec.EXACTLY);
+ int itemsWidth = menu.getItemsMeasuredWidth(true);
+ menuWidth = MeasureSpec.makeMeasureSpec(width - AndroidUtilities.dp(AndroidUtilities.isTablet() ? 74 : 66) + menu.getItemsMeasuredWidth(true), MeasureSpec.EXACTLY);
if (!isMenuOffsetSuppressed) {
menu.translateXItems(-itemsWidth);
}
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 377ba1e51..ad5365bbd 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
@@ -964,7 +964,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
if (GroupCallPip.onBackPressed()) {
return;
}
- if (currentActionBar != null && !currentActionBar.isActionModeShowed() && currentActionBar.isSearchFieldVisible) {
+ if (!storyViewerAttached() && currentActionBar != null && !currentActionBar.isActionModeShowed() && currentActionBar.isSearchFieldVisible) {
currentActionBar.closeSearchField();
return;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java
index 21fcfb643..9256e0337 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java
@@ -518,11 +518,14 @@ public class ActionBarMenu extends LinearLayout {
}
}
- public int getItemsMeasuredWidth() {
+ public int getItemsMeasuredWidth(boolean ignoreAlpha) {
int w = 0;
int count = getChildCount();
for (int a = 0; a < count; a++) {
View view = getChildAt(a);
+ if (!ignoreAlpha && (view.getAlpha() == 0 || view.getVisibility() != View.VISIBLE)) {
+ continue;
+ }
if (view instanceof ActionBarMenuItem) {
w += view.getMeasuredWidth();
}
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 82d88c386..28c1b073c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java
@@ -81,6 +81,17 @@ public class ActionBarMenuItem extends FrameLayout {
private FrameLayout wrappedSearchFrameLayout;
+ public static void addText(ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout, String text, Theme.ResourcesProvider resourcesProvider) {
+ final TextView textView = new TextView(popupLayout.getContext());
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
+ textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack, resourcesProvider));
+ textView.setPadding(AndroidUtilities.dp(13), AndroidUtilities.dp(8), AndroidUtilities.dp(13), AndroidUtilities.dp(8));
+ textView.setText(text);
+ textView.setTag(R.id.fit_width_tag, 1);
+ textView.setMaxWidth(AndroidUtilities.dp(200));
+ popupLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
+ }
+
public void setSearchPaddingStart(int padding) {
searchItemPaddingStart = padding;
if (searchContainer != null) {
@@ -525,6 +536,7 @@ public class ActionBarMenuItem extends FrameLayout {
View cell = new View(popupLayout.getContext());
cell.setTag(id);
cell.setTag(R.id.object_tag, 1);
+ cell.setTag(R.id.fit_width_tag, 1);
popupLayout.addView(cell);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) cell.getLayoutParams();
if (LocaleController.isRTL) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuSubItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuSubItem.java
index 8affa9321..dd3cb892c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuSubItem.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuSubItem.java
@@ -203,6 +203,10 @@ public class ActionBarMenuSubItem extends FrameLayout {
imageView.setImageResource(resId);
}
+ public void setIcon(Drawable drawable) {
+ imageView.setImageDrawable(drawable);
+ }
+
public void setAnimatedIcon(int resId) {
imageView.setAnimation(resId, 24, 24);
}
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 7116843f0..cde9699d6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
@@ -950,6 +950,9 @@ public abstract class BaseFragment {
}
public boolean isLightStatusBar() {
+ if (storyViewer != null && storyViewer.isShown()) {
+ return false;
+ }
if (hasForceLightStatusBar() && !Theme.getCurrentTheme().isDark()) {
return true;
}
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 1fe0fb575..65566b2be 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheet.java
@@ -31,6 +31,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
+import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
@@ -770,6 +771,10 @@ public class BottomSheet extends Dialog {
return !keyboardVisible && drawNavigationBar && insets != null && (insets.left != 0 || insets.right != 0) ? insets.bottom : 0;
}
+ public boolean isKeyboardVisible() {
+ return keyboardVisible;
+ }
+
public interface BottomSheetDelegateInterface {
void onOpenAnimationStart();
void onOpenAnimationEnd();
@@ -1905,6 +1910,11 @@ public class BottomSheet extends Dialog {
}
}
+ @Override
+ public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
+ return super.dispatchKeyEvent(event);
+ }
+
public void setImageReceiverNumLevel(int playingImages, int onShowing) {
this.playingImagesLayerNum = playingImages;
this.openedLayerNum = onShowing;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/FloatingToolbar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/FloatingToolbar.java
index 1d531c5e1..aa2f89f45 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/FloatingToolbar.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/FloatingToolbar.java
@@ -25,6 +25,8 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.Point;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.AnimatedVectorDrawable;
@@ -32,6 +34,7 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.text.TextUtils;
+import android.util.Log;
import android.util.Size;
import android.util.TypedValue;
import android.view.Gravity;
@@ -49,23 +52,30 @@ import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.Transformation;
import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
+import android.widget.Space;
import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities;
+import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
+import org.telegram.ui.Components.CubicBezierInterpolator;
+import org.telegram.ui.Components.LayoutHelper;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
@@ -90,6 +100,11 @@ public final class FloatingToolbar {
public static final int STYLE_THEME = 1;
public static final int STYLE_BLACK = 2;
+ private Runnable premiumLockClickListener;
+ public void setOnPremiumLockClick(Runnable listener) {
+ premiumLockClickListener = listener;
+ }
+
private final OnLayoutChangeListener mOrientationChangeHandler = new OnLayoutChangeListener() {
private final Rect mNewRect = new Rect();
private final Rect mOldRect = new Rect();
@@ -220,7 +235,7 @@ public final class FloatingToolbar {
Menu subMenu = menuItem.getSubMenu();
if (subMenu != null) {
menuItems.addAll(getVisibleAndEnabledMenuItems(subMenu));
- } else if (menuItem.getItemId() != TRANSLATE) {
+ } else if (menuItem.getItemId() != TRANSLATE && (menuItem.getItemId() != R.id.menu_regular || premiumLockClickListener == null)) {
menuItems.add(menuItem);
}
}
@@ -237,6 +252,16 @@ public final class FloatingToolbar {
mWindowView.removeOnLayoutChangeListener(mOrientationChangeHandler);
}
+ private static final List premiumOptions = Arrays.asList(
+ R.id.menu_bold,
+ R.id.menu_italic,
+ R.id.menu_strike,
+ R.id.menu_link,
+ R.id.menu_mono,
+ R.id.menu_underline,
+ R.id.menu_spoiler
+ );
+
private final class FloatingToolbarPopup {
private static final int MIN_OVERFLOW_SIZE = 2;
@@ -251,7 +276,10 @@ public final class FloatingToolbar {
private final ViewGroup mContentContainer;
private final ViewGroup mMainPanel;
private final OverflowPanel mOverflowPanel;
- private final ImageButton mOverflowButton;
+ private final FrameLayout mOverflowButton;
+ private final View mOverflowButtonShadow;
+ private final ImageView mOverflowButtonIcon;
+ private final TextView mOverflowButtonText;
private final Drawable mArrow;
private final Drawable mOverflow;
@@ -338,8 +366,52 @@ public final class FloatingToolbar {
mToOverflow = (AnimatedVectorDrawable) mContext.getDrawable(R.drawable.ft_avd_tooverflow_animation).mutate();
mToOverflow.setAutoMirrored(true);
- mOverflowButton = createOverflowButton();
- mOverflowButtonSize = measure(mOverflowButton);
+ mOverflowButton = new FrameLayout(mContext);
+ mOverflowButtonIcon = new ImageButton(mContext) {
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent event) {
+ if (mIsOverflowOpen) {
+ return false;
+ }
+ return super.dispatchTouchEvent(event);
+ }
+ };
+ mOverflowButtonIcon.setLayoutParams(new ViewGroup.LayoutParams(AndroidUtilities.dp(56), AndroidUtilities.dp(48)));
+ mOverflowButtonIcon.setPaddingRelative(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12));
+ mOverflowButtonIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
+ mOverflowButtonIcon.setImageDrawable(mOverflow);
+ mOverflowButtonText = new TextView(mContext);
+ mOverflowButtonText.setText(LocaleController.getString(R.string.Back));
+ mOverflowButtonText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+ mOverflowButtonText.setAlpha(0f);
+ mOverflowButtonShadow = new View(mContext);
+ int color;
+ if (currentStyle == STYLE_DIALOG) {
+ color = getThemedColor(Theme.key_dialogTextBlack);
+ mOverflowButtonIcon.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), Theme.RIPPLE_MASK_CIRCLE_20DP));
+ mOverflowButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), Theme.RIPPLE_MASK_ALL));
+ mOverflowButtonShadow.setBackgroundColor(Theme.multAlpha(getThemedColor(Theme.key_dialogTextBlack), .4f));
+ } else if (currentStyle == STYLE_BLACK) {
+ color = 0xfffafafa;
+ mOverflowButtonIcon.setBackground(Theme.createSelectorDrawable(0x20ffffff, Theme.RIPPLE_MASK_CIRCLE_20DP));
+ mOverflowButton.setBackground(Theme.createSelectorDrawable(0x20ffffff, Theme.RIPPLE_MASK_ALL));
+ mOverflowButtonShadow.setBackgroundColor(0xff000000);
+ } else {
+ color = getThemedColor(Theme.key_windowBackgroundWhiteBlackText);
+ mOverflowButtonIcon.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), Theme.RIPPLE_MASK_CIRCLE_20DP));
+ mOverflowButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector), Theme.RIPPLE_MASK_ALL));
+ mOverflowButtonShadow.setBackgroundColor(getThemedColor(Theme.key_divider));
+ }
+ mOverflow.setTint(color);
+ mArrow.setTint(color);
+ mToArrow.setTint(color);
+ mToOverflow.setTint(color);
+ mOverflowButtonText.setTextColor(color);
+ mOverflowButtonIcon.setOnClickListener(v -> onBackPressed());
+ mOverflowButton.addView(mOverflowButtonIcon, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT));
+ mOverflowButton.addView(mOverflowButtonText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 56, 0, 0, 0));
+ mOverflowButton.addView(mOverflowButtonShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 1f / AndroidUtilities.density, Gravity.TOP | Gravity.FILL_HORIZONTAL));
+ mOverflowButtonSize = measure(mOverflowButtonIcon);
mMainPanel = createMainPanel();
mOverflowPanelViewHelper = new OverflowPanelViewHelper(mContext, mIconTextSpacing);
mOverflowPanel = createOverflowPanel();
@@ -369,6 +441,26 @@ public final class FloatingToolbar {
});
}
+ private void onBackPressed() {
+ if (mIsOverflowOpen) {
+ mOverflowButtonIcon.setImageDrawable(mToOverflow);
+ mToOverflow.start();
+ closeOverflow();
+ mOverflowButton.setClickable(false);
+ mOverflowButton.setOnClickListener(null);
+ mOverflowButtonIcon.setClickable(true);
+ mOverflowButtonIcon.setOnClickListener(v -> onBackPressed());
+ } else {
+ mOverflowButtonIcon.setImageDrawable(mToArrow);
+ mToArrow.start();
+ openOverflow();
+ mOverflowButton.setClickable(true);
+ mOverflowButton.setOnClickListener(v -> onBackPressed());
+ mOverflowButtonIcon.setClickable(false);
+ mOverflowButtonIcon.setOnClickListener(null);
+ }
+ }
+
public boolean setOutsideTouchable(boolean outsideTouchable, PopupWindow.OnDismissListener onDismiss) {
boolean ret = false;
if (mPopupWindow.isOutsideTouchable() ^ outsideTouchable) {
@@ -562,7 +654,7 @@ public final class FloatingToolbar {
}
};
final float overflowButtonStartX = mOverflowButton.getX();
- final float overflowButtonTargetX = isInRTLMode() ? overflowButtonStartX + targetWidth - mOverflowButton.getWidth() : overflowButtonStartX - targetWidth + mOverflowButton.getWidth();
+ final float overflowButtonTargetX = isInRTLMode() ? overflowButtonStartX + targetWidth - mOverflowButtonIcon.getWidth() : overflowButtonStartX - targetWidth + mOverflowButtonIcon.getWidth();
Animation overflowButtonAnimation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
@@ -570,6 +662,8 @@ public final class FloatingToolbar {
float deltaContainerWidth = isInRTLMode() ? 0 : mContentContainer.getWidth() - startWidth;
float actualOverflowButtonX = overflowButtonX + deltaContainerWidth;
mOverflowButton.setX(actualOverflowButtonX);
+ mOverflowButtonText.setAlpha(interpolatedTime);
+ mOverflowButtonShadow.setAlpha(interpolatedTime);
}
};
widthAnimation.setInterpolator(mLogAccelerateInterpolator);
@@ -585,6 +679,9 @@ public final class FloatingToolbar {
mContentContainer.startAnimation(mOpenOverflowAnimation);
mIsOverflowOpen = true;
mMainPanel.animate().alpha(0).withLayer().setInterpolator(mLinearOutSlowInInterpolator).setDuration(250).start();
+ RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mOverflowButton.getLayoutParams();
+ lp.width = mOverflowPanel.getWidth();
+ mOverflowButton.setLayoutParams(lp);
mOverflowPanel.setAlpha(1);
}
@@ -624,7 +721,7 @@ public final class FloatingToolbar {
}
};
final float overflowButtonStartX = mOverflowButton.getX();
- final float overflowButtonTargetX = isInRTLMode() ? overflowButtonStartX - startWidth + mOverflowButton.getWidth() : overflowButtonStartX + startWidth - mOverflowButton.getWidth();
+ final float overflowButtonTargetX = isInRTLMode() ? overflowButtonStartX - startWidth + mOverflowButtonIcon.getWidth() : overflowButtonStartX + startWidth - mOverflowButtonIcon.getWidth();
Animation overflowButtonAnimation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
@@ -632,6 +729,8 @@ public final class FloatingToolbar {
float deltaContainerWidth = isInRTLMode() ? 0 : mContentContainer.getWidth() - startWidth;
float actualOverflowButtonX = overflowButtonX + deltaContainerWidth;
mOverflowButton.setX(actualOverflowButtonX);
+ mOverflowButtonText.setAlpha(1f - interpolatedTime);
+ mOverflowButtonShadow.setAlpha(1f - interpolatedTime);
}
};
widthAnimation.setInterpolator(mFastOutSlowInInterpolator);
@@ -668,7 +767,7 @@ public final class FloatingToolbar {
mMainPanel.setVisibility(View.INVISIBLE);
mOverflowPanel.setAlpha(1);
mOverflowPanel.setVisibility(View.VISIBLE);
- mOverflowButton.setImageDrawable(mArrow);
+ mOverflowButtonIcon.setImageDrawable(mArrow);
mOverflowButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
if (isInRTLMode()) {
@@ -700,7 +799,7 @@ public final class FloatingToolbar {
mMainPanel.setVisibility(View.VISIBLE);
mOverflowPanel.setAlpha(0);
mOverflowPanel.setVisibility(View.INVISIBLE);
- mOverflowButton.setImageDrawable(mOverflow);
+ mOverflowButtonIcon.setImageDrawable(mOverflow);
mOverflowButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
if (hasOverflow()) {
if (isInRTLMode()) {
@@ -832,9 +931,15 @@ public final class FloatingToolbar {
mMainPanel.removeAllViews();
mMainPanel.setPaddingRelative(0, 0, 0, 0);
boolean isFirstItem = true;
- while (!remainingMenuItems.isEmpty()) {
- final MenuItem menuItem = remainingMenuItems.peek();
- boolean isLastItem = remainingMenuItems.size() == 1;
+ Iterator