Skip to content

Commit

Permalink
update to 10.1.0 (3919)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Sep 22, 2023
1 parent 6b4602c commit 750eedf
Show file tree
Hide file tree
Showing 137 changed files with 9,590 additions and 2,322 deletions.
17 changes: 16 additions & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ configurations.all {
}

dependencies {
implementation 'androidx.fragment:fragment:1.2.0'

This comment has been minimized.

Copy link
@ashishBot234

ashishBot234 Nov 15, 2023

Cp

implementation 'androidx.core:core:1.10.1'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.exifinterface:exifinterface:1.3.6'
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.sharetarget:sharetarget:1.2.0"
implementation 'androidx.interpolator:interpolator:1.0.0'

compileOnly 'org.checkerframework:checker-qual:2.5.2'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
Expand Down Expand Up @@ -138,6 +140,19 @@ android {
buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
}

HA_hardcore {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), '../TMessagesProj/proguard-rules.pro'
ndk.debugSymbolLevel = 'FULL'
buildConfigField "String", "APP_CENTER_HASH", "\"" + getProps("APP_CENTER_HASH_HARDCORE") + "\""
buildConfigField "boolean", "DEBUG_VERSION", "true"
buildConfigField "boolean", "DEBUG_PRIVATE_VERSION", "true"
buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
}

standalone {
debuggable false
jniDebuggable false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ protected void animateRemoveImpl(final RecyclerView.ViewHolder holder) {
.setInterpolator(getRemoveInterpolator())
.alpha(0)
.scaleX(1f - animateByScale(view))
.scaleY(1f - animateByScale(view))
.scaleY(1f - animateByScale(view));
if (Build.VERSION.SDK_INT >= 19) {
animation.setUpdateListener(animation1 -> onRemoveAnimationUpdate(holder));
}
animation
.setListener(
new AnimatorListenerAdapter() {
@Override
Expand Down Expand Up @@ -284,7 +288,11 @@ public void animateAddImpl(final RecyclerView.ViewHolder holder) {
.scaleY(1f)
.setDuration(getAddDuration())
.setStartDelay(getAddDelay())
.setInterpolator(getAddInterpolator())
.setInterpolator(getAddInterpolator());
if (Build.VERSION.SDK_INT >= 19) {
animation.setUpdateListener(animation1 -> onAddAnimationUpdate(holder));
}
animation
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
Expand Down Expand Up @@ -342,6 +350,14 @@ protected void onChangeAnimationUpdate(RecyclerView.ViewHolder holder) {

}

protected void onAddAnimationUpdate(RecyclerView.ViewHolder holder) {

}

protected void onRemoveAnimationUpdate(RecyclerView.ViewHolder holder) {

}

protected void beforeAnimateMoveImpl(final RecyclerView.ViewHolder holder) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,16 @@ public static float[] getCoordinateInParent(ViewGroup parentView, View view) {
return new float[] {xOffset, yOffset};
}

public static void doOnLayout(View view, Runnable runnable) {
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
view.removeOnLayoutChangeListener(this);
runnable.run();
}
});
}

private static class LinkSpec {
String url;
int start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

public class ApplicationLoader extends Application {

private static ApplicationLoader applicationLoaderInstance;
public static ApplicationLoader applicationLoaderInstance;

@SuppressLint("StaticFieldLeak")
public static volatile Context applicationContext;
Expand Down Expand Up @@ -555,4 +555,11 @@ protected void logDualCameraInternal(boolean success, boolean vendor) {

}

public boolean checkApkInstallPermissions(final Context context) {
return false;
}

public boolean openApkInstall(Activity activity, TLRPC.Document document) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ 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 = 3872;
public static String BUILD_VERSION_STRING = "10.0.9";
public static int BUILD_VERSION = 3919;
public static String BUILD_VERSION_STRING = "10.1.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

// SafetyNet key for Google Identity SDK, set it to empty to disable
public static String SAFETYNET_KEY = "AIzaSyDqt8P-7F7CPCseMkOiVRgb1LY8RN1bvH8";
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";
public static String HUAWEI_STORE_URL = "https://appgallery.huawei.com/app/C101184875";
public static String GOOGLE_AUTH_CLIENT_ID = "760348033671-81kmi3pi84p11ub8hp9a1funsv0rn2p9.apps.googleusercontent.com";

public static String HUAWEI_APP_ID = "101184875";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package org.telegram.messenger;

import com.google.android.exoplayer2.util.Consumer;

import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.BulletinFactory;

public class ChannelBoostsController {

private final int currentAccount;
private final MessagesController messagesController;
private final ConnectionsManager connectionsManager;

public final static int BOOSTS_FOR_LEVEL_1 = 1;
public final static int BOOSTS_FOR_LEVEL_2 = 1;

public ChannelBoostsController(int currentAccount) {
this.currentAccount = currentAccount;
messagesController = MessagesController.getInstance(currentAccount);
connectionsManager = ConnectionsManager.getInstance(currentAccount);
}


public void getBoostsStats(long dialogId, Consumer<TLRPC.TL_stories_boostsStatus> consumer) {
TLRPC.TL_stories_getBoostsStatus req = new TLRPC.TL_stories_getBoostsStatus();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response != null) {
consumer.accept((TLRPC.TL_stories_boostsStatus) response);
} else {
BulletinFactory.showForError(error);
consumer.accept(null);
}
}));

}

public void userCanBoostChannel(long dialogId, Consumer<CanApplyBoost> consumer) {
TLRPC.TL_stories_canApplyBoost req = new TLRPC.TL_stories_canApplyBoost();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
CanApplyBoost canApplyBoost = new CanApplyBoost();
if (response != null) {
canApplyBoost.canApply = true;
if (response instanceof TLRPC.TL_stories_canApplyBoostReplace) {
TLRPC.TL_stories_canApplyBoostReplace canApplyBoostReplace = (TLRPC.TL_stories_canApplyBoostReplace) response;
messagesController.putChats(canApplyBoostReplace.chats, false);
canApplyBoost.replaceDialogId = DialogObject.getPeerDialogId(canApplyBoostReplace.current_boost);
if (canApplyBoost.replaceDialogId == 0 && canApplyBoostReplace.chats.size() > 0) {
canApplyBoost.replaceDialogId = -canApplyBoostReplace.chats.get(0).id;
}
}
} else {
if (error != null) {
if (error.text.equals("SAME_BOOST_ALREADY_ACTIVE") || error.text.equals("BOOST_NOT_MODIFIED")) {
canApplyBoost.alreadyActive = true;
} else if (error.text.equals("PREMIUM_GIFTED_NOT_ALLOWED")) {
canApplyBoost.giftedPremium = true;
} else if (error.text.startsWith("FLOOD_WAIT")) {
canApplyBoost.floodWait = Utilities.parseInt(error.text);
canApplyBoost.lastCheckTime = System.currentTimeMillis();
}
}
}
consumer.accept(canApplyBoost);
}), ConnectionsManager.RequestFlagDoNotWaitFloodWait);
}

public void applyBoost(long dialogId) {
TLRPC.TL_stories_applyBoost req = new TLRPC.TL_stories_applyBoost();
req.peer = messagesController.getInputPeer(dialogId);
connectionsManager.sendRequest(req, (response, error) -> {

});
}

public int getTotalBooststToLevel(int level) {
int count = 0;
if (level >= 1) {
count += BOOSTS_FOR_LEVEL_1;
}
if (level >= 2) {
count += BOOSTS_FOR_LEVEL_2;
}
return count;
}

public static class CanApplyBoost {
public boolean canApply;
public long replaceDialogId;

public boolean alreadyActive;
public int floodWait;
public boolean giftedPremium;
private long lastCheckTime;

public void checkTime() {
floodWait -= (System.currentTimeMillis() - lastCheckTime) / 1000;
lastCheckTime = System.currentTimeMillis();
if (floodWait < 0) {
floodWait = 0;
canApply = true;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void loadStoriesForMessages(long dialogId, ArrayList<MessageObject> visi
continue;
}
long storyDialogId = storyItem.dialogId;
req.user_id = chatActivity.getMessagesController().getInputUser(storyDialogId);
req.peer = chatActivity.getMessagesController().getInputPeer(storyDialogId);
req.id.add(storyItem.id);
int storyId = storyItem.id;
int reqId = chatActivity.getConnectionsManager().sendRequest(req, (response, error) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2864,6 +2864,9 @@ public static String formatName(TLObject object) {
}

public static String formatName(TLRPC.User user) {
if (user == null) {
return "";
}
return formatName(user.first_name, user.last_name, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,12 @@ public static int migrate(MessagesStorage messagesStorage, int version) throws E
version = 133;
}

if (version == 133) {
database.executeFast("ALTER TABLE unread_push_messages ADD COLUMN topicId INTEGER default 0").stepThis().dispose();
database.executeFast("PRAGMA user_version = 134").stepThis().dispose();
version = 134;
}

return version;
}

Expand Down
26 changes: 20 additions & 6 deletions TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,10 @@ public File getPathToMessage(TLRPC.Message message) {
}

public File getPathToMessage(TLRPC.Message message, boolean useFileDatabaseQueue) {
return getPathToMessage(message, useFileDatabaseQueue, false);
}

public File getPathToMessage(TLRPC.Message message, boolean useFileDatabaseQueue, boolean saveAsFile) {
if (message == null) {
return new File("");
}
Expand All @@ -1184,7 +1188,7 @@ public File getPathToMessage(TLRPC.Message message, boolean useFileDatabaseQueue
}
} else {
if (MessageObject.getMedia(message) instanceof TLRPC.TL_messageMediaDocument) {
return getPathToAttach(MessageObject.getMedia(message).document, null, MessageObject.getMedia(message).ttl_seconds != 0, useFileDatabaseQueue);
return getPathToAttach(MessageObject.getMedia(message).document, null,null, MessageObject.getMedia(message).ttl_seconds != 0, useFileDatabaseQueue, saveAsFile);
} else if (MessageObject.getMedia(message) instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = MessageObject.getMedia(message).photo.sizes;
if (sizes.size() > 0) {
Expand Down Expand Up @@ -1221,21 +1225,22 @@ public File getPathToAttach(TLObject attach, boolean forceCache) {
}

public File getPathToAttach(TLObject attach, String ext, boolean forceCache) {
return getPathToAttach(attach, null, ext, forceCache, true);
return getPathToAttach(attach, null, ext, forceCache, true, false);
}

public File getPathToAttach(TLObject attach, String ext, boolean forceCache, boolean useFileDatabaseQueue) {
return getPathToAttach(attach, null, ext, forceCache, useFileDatabaseQueue);
return getPathToAttach(attach, null, ext, forceCache, useFileDatabaseQueue, false);
}

/**
* Return real file name. Used before file.exist()
*/
public File getPathToAttach(TLObject attach, String size, String ext, boolean forceCache, boolean useFileDatabaseQueue) {
public File getPathToAttach(TLObject attach, String size, String ext, boolean forceCache, boolean useFileDatabaseQueue, boolean saveAsFile) {
File dir = null;
long documentId = 0;
int dcId = 0;
int type = 0;
String fileName = null;
if (forceCache) {
dir = getDirectory(MEDIA_DIR_CACHE);
} else {
Expand All @@ -1252,7 +1257,13 @@ public File getPathToAttach(TLObject attach, String size, String ext, boolean fo
} else if (MessageObject.isVideoDocument(document)) {
type = MEDIA_DIR_VIDEO;
} else {
type = MEDIA_DIR_DOCUMENT;
String documentFileName = getDocumentFileName(document);
if (saveAsFile && !TextUtils.isEmpty(documentFileName)) {
fileName = documentFileName;
type = MEDIA_DIR_FILES;
} else {
type = MEDIA_DIR_DOCUMENT;
}
}
}
documentId = document.id;
Expand Down Expand Up @@ -1323,7 +1334,10 @@ public File getPathToAttach(TLObject attach, String size, String ext, boolean fo
return new File(path);
}
}
return new File(dir, getAttachFileName(attach, ext));
if (fileName == null) {
fileName = getAttachFileName(attach, ext);
}
return new File(dir, fileName);
}

public FilePathDatabase getFileDatabase() {
Expand Down
Loading

1 comment on commit 750eedf

@Suburbanno
Copy link

Choose a reason for hiding this comment

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

🎉

Please sign in to comment.