Skip to content

Commit

Permalink
update to 10.0.1 (3793)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Aug 14, 2023
1 parent 0bcf4fe commit 702d37c
Show file tree
Hide file tree
Showing 330 changed files with 15,335 additions and 3,257 deletions.
2 changes: 1 addition & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ android {

defaultConfig {
minSdkVersion 19
targetSdkVersion 31
targetSdkVersion 33
versionName "8.9.0"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/config/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>

<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/config/debug/AndroidManifest_SDK23.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/config/release/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>

<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/config/release/AndroidManifest_SDK23.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ JNIEXPORT void JNICALL Java_org_telegram_messenger_voip_NativeInstance_onStreamP
return;
}
auto context = (AndroidContext *) instance->_platformContext.get();
std::shared_ptr<BroadcastPartTask> task;
std::shared_ptr<BroadcastPartTask> task = nullptr;
auto q = (VideoChannelDescription::Quality) quality;
if (videoChannel != 0) {
for (auto videoTaskIter = context->videoStreamTasks.begin(); videoTaskIter != context->videoStreamTasks.end(); videoTaskIter++) {
Expand Down
4 changes: 4 additions & 0 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
Expand All @@ -53,6 +56,7 @@
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
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;
Expand Down Expand Up @@ -2844,13 +2845,31 @@ private static HashMap<String, String> createIsoLanguageReplacementMap() {

@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<String> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.telegram.messenger;

import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
Expand Down Expand Up @@ -112,6 +113,7 @@
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;
Expand Down Expand Up @@ -157,6 +159,8 @@
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;

Expand Down Expand Up @@ -454,6 +458,10 @@ public static CharSequence replaceSingleTag(String str, Runnable runnable) {
}

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("**", "");
Expand All @@ -473,7 +481,7 @@ public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
if (colorKey >= 0) {
ds.setColor(Theme.getColor(colorKey));
ds.setColor(Theme.getColor(colorKey, resourcesProvider));
}
}

Expand All @@ -490,7 +498,7 @@ public void onClick(@NonNull View view) {
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);
Expand Down Expand Up @@ -573,18 +581,25 @@ public static void recycleBitmap(Bitmap image) {
}

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;
}
}
Expand Down Expand Up @@ -721,6 +736,36 @@ public static void getBitmapFromSurface(SurfaceView surfaceView, Bitmap surfaceB
}
}

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;
Expand Down Expand Up @@ -2982,7 +3027,17 @@ public static void addMediaToGallery(File file) {
}

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;
Expand Down Expand Up @@ -5197,7 +5252,7 @@ public static String getHostAuthority(Uri uri) {
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ public void loadExtendedMediaForMessages(long dialogId, ArrayList<MessageObject>

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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2878,14 +2878,19 @@ public static String formatName(String firstName, String lastName, int maxLength
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();
}
StringBuilder result = new StringBuilder((firstName != null ? firstName.length() : 0) + (lastName != null ? lastName.length() : 0) + 1);
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) {
Expand All @@ -2898,14 +2903,14 @@ public static String formatName(String firstName, String lastName, int maxLength
}
} 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) {
Expand All @@ -2918,7 +2923,7 @@ public static String formatName(String firstName, String lastName, int maxLength
}
} 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,13 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public boolean postRunnable(Runnable runnable) {
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();
Expand Down

1 comment on commit 702d37c

@Suburbanno
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insane, Why do you only do one commit per version?

Please sign in to comment.