Skip to content

Commit

Permalink
update to 9.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix authored and immat0x1 committed Feb 6, 2023
1 parent 801067a commit 516c364
Show file tree
Hide file tree
Showing 50 changed files with 378 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static void execute(Runnable runnable) {
@UiThread
public static void execute(Runnable runnable, boolean now) {
if (Thread.currentThread() != ApplicationLoader.applicationHandler.getLooper().getThread()) {
if (BuildVars.DEBUG_PRIVATE_VERSION) {
if (BuildVars.DEBUG_VERSION) {
FileLog.e(new RuntimeException("wrong thread"));
}
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public FileLog() {
private static HashSet<String> excludeRequests;

public static void dumpResponseAndRequest(TLObject request, TLObject response, TLRPC.TL_error error, long requestMsgId, long startRequestTimeInMillis, int requestToken) {
if (!BuildVars.DEBUG_PRIVATE_VERSION || !BuildVars.LOGS_ENABLED || request == null || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
if (!BuildVars.DEBUG_VERSION || !BuildVars.LOGS_ENABLED || request == null || SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
return;
}
String requestSimpleName = request.getClass().getSimpleName();
Expand Down Expand Up @@ -114,7 +114,7 @@ public static void dumpResponseAndRequest(TLObject request, TLObject response, T
}

public static void dumpUnparsedMessage(TLObject message, long messageId) {
if (!BuildVars.DEBUG_PRIVATE_VERSION || !BuildVars.LOGS_ENABLED || message == null) {
if (!BuildVars.DEBUG_VERSION || !BuildVars.LOGS_ENABLED || message == null) {
return;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ private void loadLastFrame(RLottieDrawable lottieDrawable, int w, int h, boolean
bitmapDrawable = new BitmapDrawable(bitmap);
}

lottieDrawable.recycle();
lottieDrawable.recycle(false);
currentBitmap.recycle();
onPostExecute(bitmapDrawable);
}
Expand All @@ -1588,7 +1588,7 @@ private void onPostExecute(final Drawable drawable) {
lottieMemCache.put(cacheImage.key, lottieDrawable);
toSet = lottieDrawable;
} else {
lottieDrawable.recycle();
lottieDrawable.recycle(false);
}
if (toSet != null) {
incrementUseCount(cacheImage.key);
Expand Down Expand Up @@ -1977,7 +1977,7 @@ protected void entryRemoved(boolean evicted, String key, final BitmapDrawable ol
((AnimatedFileDrawable) oldValue).recycle();
}
if (oldValue instanceof RLottieDrawable) {
((RLottieDrawable) oldValue).recycle();
((RLottieDrawable) oldValue).recycle(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void release() {
} else if (drawable != null) {
if (drawable instanceof RLottieDrawable) {
RLottieDrawable fileDrawable = (RLottieDrawable) drawable;
fileDrawable.recycle();
fileDrawable.recycle(false);
} else if (drawable instanceof AnimatedFileDrawable) {
AnimatedFileDrawable fileDrawable = (AnimatedFileDrawable) drawable;
fileDrawable.recycle();
Expand Down Expand Up @@ -2797,7 +2797,7 @@ private void recycleBitmap(String newKey, int type) {
boolean canDelete = ImageLoader.getInstance().decrementUseCount(key);
if (!ImageLoader.getInstance().isInMemCache(key, true)) {
if (canDelete) {
fileDrawable.recycle();
fileDrawable.recycle(false);
}
}
} else if (image instanceof AnimatedFileDrawable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void reloadCurrentRemoteLocale(int currentAccount, String langCode, boole
langCode = langCode.replace("-", "_");
}
if (langCode == null || currentLocaleInfo != null && (langCode.equals(currentLocaleInfo.shortName) || langCode.equals(currentLocaleInfo.baseLangCode))) {
applyRemoteLanguage(currentLocaleInfo, langCode, force, currentAccount, onDone);
applyRemoteLanguage(currentLocaleInfo, langCode, force, force, currentAccount, onDone);
}
}

Expand All @@ -495,11 +495,11 @@ public void checkUpdateForCurrentRemoteLocale(int currentAccount, int version, i
}
if (currentLocaleInfo.hasBaseLang()) {
if (currentLocaleInfo.baseVersion < baseVersion) {
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, currentAccount, null);
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.baseLangCode, false, false, currentAccount, null);
}
}
if (currentLocaleInfo.version < version) {
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, currentAccount, null);
applyRemoteLanguage(currentLocaleInfo, currentLocaleInfo.shortName, false, false, currentAccount, null);
}
}

Expand Down Expand Up @@ -656,7 +656,7 @@ public boolean applyLanguageFile(File file, int currentAccount) {
saveOtherLanguages();
}
localeValues = stringMap;
applyLanguage(localeInfo, true, false, true, false, currentAccount, null);
applyLanguage(localeInfo, true, false, true, false, false, currentAccount, null);
return true;
}
} catch (Exception e) {
Expand Down Expand Up @@ -851,10 +851,10 @@ private HashMap<String, String> getLocaleFileStrings(File file, boolean preserve
}

public int applyLanguage(LocaleInfo localeInfo, boolean override, boolean init, final int currentAccount) {
return applyLanguage(localeInfo, override, init, false, false, currentAccount, null);
return applyLanguage(localeInfo, override, init, false, false, false, currentAccount, null);
}

public int applyLanguage(final LocaleInfo localeInfo, boolean override, boolean init, boolean fromFile, boolean force, final int currentAccount, Runnable onDone) {
public int applyLanguage(final LocaleInfo localeInfo, boolean override, boolean init, boolean fromFile, boolean force, boolean forceFullDifference, final int currentAccount, Runnable onDone) {
if (localeInfo == null) {
return 0;
}
Expand Down Expand Up @@ -887,9 +887,9 @@ public int applyLanguage(final LocaleInfo localeInfo, boolean override, boolean
}
isLoadingRemote = true;
if (init) {
AndroidUtilities.runOnUIThread(() -> applyRemoteLanguage(localeInfo, null, true, currentAccount, onDone));
AndroidUtilities.runOnUIThread(() -> applyRemoteLanguage(localeInfo, null, true, forceFullDifference, currentAccount, onDone));
} else {
requestId = applyRemoteLanguage(localeInfo, null, true, currentAccount, onDone);
requestId = applyRemoteLanguage(localeInfo, null, true, forceFullDifference, currentAccount, onDone);
}
}
try {
Expand Down Expand Up @@ -931,12 +931,12 @@ public int applyLanguage(final LocaleInfo localeInfo, boolean override, boolean
}
if (currentPluralRules == null) {
currentPluralRules = allRules.get(args[0]);
if (currentPluralRules == null) {
currentPluralRules = allRules.get(currentLocale.getLanguage());
if (currentPluralRules == null) {
currentPluralRules = new PluralRules_None();
}
}
}
if (currentPluralRules == null) {
currentPluralRules = allRules.get(currentLocale.getLanguage());
}
if (currentPluralRules == null) {
currentPluralRules = new PluralRules_None();
}
changingConfiguration = true;
Locale.setDefault(currentLocale);
Expand Down Expand Up @@ -2088,6 +2088,9 @@ public void saveRemoteLocaleStringsForCurrentLocale(final TLRPC.TL_langPackDiffe

public void saveRemoteLocaleStrings(LocaleInfo localeInfo, final TLRPC.TL_langPackDifference difference, int currentAccount, Runnable onDone) {
if (difference == null || difference.strings.isEmpty() || localeInfo == null || localeInfo.isLocal()) {
if (onDone != null) {
onDone.run();
}
return;
}
final String langCode = difference.lang_code.replace('-', '_').toLowerCase();
Expand Down Expand Up @@ -2289,42 +2292,57 @@ public void loadRemoteLanguages(final int currentAccount, boolean applyCurrent)
}, ConnectionsManager.RequestFlagWithoutLogin);
}

private int applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean force, final int currentAccount, Runnable onDone) {
private int applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean force, boolean forceFullDifference, final int currentAccount, Runnable onDone) {
if (localeInfo == null || !localeInfo.isRemote() && !localeInfo.isUnofficial()) {
return 0;
}
int[] requested = new int[1], received = new int[1];
requested[0] = received[0] = 0;
Runnable onPartlyDone = () -> {
received[0]++;
if (received[0] >= requested[0] && onDone != null) {
onDone.run();
}
};
if (localeInfo.hasBaseLang() && (langCode == null || langCode.equals(localeInfo.baseLangCode))) {
if (localeInfo.baseVersion != 0 && !force) {
if (localeInfo.baseVersion != 0 && !forceFullDifference) {
if (localeInfo.hasBaseLang()) {
TLRPC.TL_langpack_getDifference req = new TLRPC.TL_langpack_getDifference();
req.from_version = localeInfo.baseVersion;
req.lang_code = localeInfo.getBaseLangCode();
req.lang_pack = "";
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
requested[0]++;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) {
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onPartlyDone));
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}
} else {
TLRPC.TL_langpack_getLangPack req = new TLRPC.TL_langpack_getLangPack();
req.lang_code = localeInfo.getBaseLangCode();
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> {
requested[0]++;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> {
if (response != null) {
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
AndroidUtilities.runOnUIThread(() -> {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onPartlyDone);
});
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}
}
if (langCode == null || langCode.equals(localeInfo.shortName)) {
if (localeInfo.version != 0 && !force) {
if (localeInfo.version != 0 && !forceFullDifference) {
TLRPC.TL_langpack_getDifference req = new TLRPC.TL_langpack_getDifference();
req.from_version = localeInfo.version;
req.lang_code = localeInfo.getLangCode();
req.lang_pack = "";
requested[0]++;
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
if (response != null) {
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
AndroidUtilities.runOnUIThread(() -> {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onPartlyDone);
});
}
}, ConnectionsManager.RequestFlagWithoutLogin);
} else {
Expand All @@ -2333,9 +2351,12 @@ private int applyRemoteLanguage(LocaleInfo localeInfo, String langCode, boolean
}
TLRPC.TL_langpack_getLangPack req = new TLRPC.TL_langpack_getLangPack();
req.lang_code = localeInfo.getLangCode();
requested[0]++;
return ConnectionsManager.getInstance(currentAccount).sendRequest(req, (TLObject response, TLRPC.TL_error error) -> {
if (response != null) {
AndroidUtilities.runOnUIThread(() -> saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onDone));
AndroidUtilities.runOnUIThread(() -> {
saveRemoteLocaleStrings(localeInfo, (TLRPC.TL_langPackDifference) response, currentAccount, onPartlyDone);
});
}
}, ConnectionsManager.RequestFlagWithoutLogin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4206,9 +4206,6 @@ void call() {
photoPath = null;
canReply = false;
}
if (passcode) {
canReply = false;
}

if (photoPath != null) {
avatalFile = getFileLoader().getPathToAttach(photoPath, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5750,6 +5750,13 @@ protected void performSendMessageRequest(final TLObject req, final MessageObject
} else {
isSentError = true;
existFlags = 0;
if (BuildVars.LOGS_ENABLED) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < updatesArr.size(); i++) {
builder.append(updatesArr.get(i).getClass().getSimpleName()).append(", ");
}
FileLog.d("can't find message int updates " + builder);
}
}
Utilities.stageQueue.postRunnable(() -> getMessagesController().processUpdates(updates, false));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1850,8 +1850,8 @@ private void removeFragmentFromStackInternal(BaseFragment fragment, boolean allo
}

@Override
public void removeFragmentFromStack(BaseFragment fragment) {
if ((fragmentsStack.size() > 0 && fragmentsStack.get(fragmentsStack.size() - 1) == fragment) || (fragmentsStack.size() > 1 && fragmentsStack.get(fragmentsStack.size() - 2) == fragment)) {
public void removeFragmentFromStack(BaseFragment fragment, boolean immediate) {
if (((fragmentsStack.size() > 0 && fragmentsStack.get(fragmentsStack.size() - 1) == fragment) || (fragmentsStack.size() > 1 && fragmentsStack.get(fragmentsStack.size() - 2) == fragment))) {
onOpenAnimationEnd();
onCloseAnimationEnd();
}
Expand All @@ -1861,7 +1861,7 @@ public void removeFragmentFromStack(BaseFragment fragment) {
if (delegate != null && fragmentsStack.size() == 1 && AndroidUtilities.isTablet()) {
delegate.needCloseLastFragment(this);
}
removeFragmentFromStackInternal(fragment, true);
removeFragmentFromStackInternal(fragment, fragment.allowFinishFragmentInsteadOfRemoveFromStack() && !immediate);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,22 @@ public void finishFragment(boolean animated) {
}

public void removeSelfFromStack() {
removeSelfFromStack(false);
}

public void removeSelfFromStack(boolean immediate) {
if (isFinished || parentLayout == null) {
return;
}
if (parentDialog != null) {
parentDialog.dismiss();
return;
}
parentLayout.removeFragmentFromStack(this);
parentLayout.removeFragmentFromStack(this, immediate);
}

public boolean allowFinishFragmentInsteadOfRemoveFromStack() {
return true;
}

protected boolean isFinishing() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface INavigationLayout {
boolean presentFragment(NavigationParams params);
boolean checkTransitionAnimation();
boolean addFragmentToStack(BaseFragment fragment, int position);
void removeFragmentFromStack(BaseFragment fragment);
void removeFragmentFromStack(BaseFragment fragment, boolean immediate);
List<BaseFragment> getFragmentStack();
void setDelegate(INavigationLayoutDelegate INavigationLayoutDelegate);
void closeLastFragment(boolean animated, boolean forceNoAnimation);
Expand Down Expand Up @@ -78,6 +78,9 @@ static INavigationLayout newLayout(Context context) {
return SharedConfig.useLNavigation ? new LNavigation(context) : new ActionBarLayout(context);
}

default void removeFragmentFromStack(BaseFragment fragment) {
removeFragmentFromStack(fragment, false);
}
default boolean isActionBarInCrossfade() {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java
Original file line number Diff line number Diff line change
Expand Up @@ -8769,22 +8769,22 @@ public static void createCommonResources(Context context) {

if (dialogs_archiveAvatarDrawable != null) {
dialogs_archiveAvatarDrawable.setCallback(null);
dialogs_archiveAvatarDrawable.recycle();
dialogs_archiveAvatarDrawable.recycle(false);
}
if (dialogs_archiveDrawable != null) {
dialogs_archiveDrawable.recycle();
dialogs_archiveDrawable.recycle(false);
}
if (dialogs_unarchiveDrawable != null) {
dialogs_unarchiveDrawable.recycle();
dialogs_unarchiveDrawable.recycle(false);
}
if (dialogs_pinArchiveDrawable != null) {
dialogs_pinArchiveDrawable.recycle();
dialogs_pinArchiveDrawable.recycle(false);
}
if (dialogs_unpinArchiveDrawable != null) {
dialogs_unpinArchiveDrawable.recycle();
dialogs_unpinArchiveDrawable.recycle(false);
}
if (dialogs_hidePsaDrawable != null) {
dialogs_hidePsaDrawable.recycle();
dialogs_hidePsaDrawable.recycle(false);
}
dialogs_archiveAvatarDrawable = new RLottieDrawable(R.raw.chats_archiveavatar, "chats_archiveavatar", AndroidUtilities.dp(36), AndroidUtilities.dp(36), false, null);
dialogs_archiveDrawable = new RLottieDrawable(R.raw.chats_archive, "chats_archive", AndroidUtilities.dp(36), AndroidUtilities.dp(36));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onItemClick(int id) {
}
args.putBoolean("allowGlobalSearch", false);
DialogsActivity activity = new DialogsActivity(args);
activity.setDelegate((fragment, dids, message, param) -> {
activity.setDelegate((fragment, dids, message, param, topicsFragment) -> {
activity.finishFragment();
CacheByChatsController.KeepMediaException newException = null;
for (int i = 0; i < dids.size(); i++) {
Expand Down
Loading

0 comments on commit 516c364

Please sign in to comment.