update to 9.4.2

This commit is contained in:
xaxtix 2023-02-06 15:08:24 +04:00
parent fb2d9f90bc
commit c48aa4f3c9
51 changed files with 368 additions and 477 deletions

View file

@ -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 = 3102;
public static String BUILD_VERSION_STRING = "9.4.1";
public static int BUILD_VERSION = 3106;
public static String BUILD_VERSION_STRING = "9.4.2";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -110,7 +110,7 @@ public class DispatchQueuePoolBackground {
@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;

View file

@ -71,7 +71,7 @@ public class 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();
@ -115,7 +115,7 @@ public class FileLog {
}
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 {

View file

@ -1605,7 +1605,7 @@ public class ImageLoader {
bitmapDrawable = new BitmapDrawable(bitmap);
}
lottieDrawable.recycle();
lottieDrawable.recycle(false);
currentBitmap.recycle();
onPostExecute(bitmapDrawable);
}
@ -1621,7 +1621,7 @@ public class ImageLoader {
lottieMemCache.put(cacheImage.key, lottieDrawable);
toSet = lottieDrawable;
} else {
lottieDrawable.recycle();
lottieDrawable.recycle(false);
}
if (toSet != null) {
incrementUseCount(cacheImage.key);
@ -2010,7 +2010,7 @@ public class ImageLoader {
((AnimatedFileDrawable) oldValue).recycle();
}
if (oldValue instanceof RLottieDrawable) {
((RLottieDrawable) oldValue).recycle();
((RLottieDrawable) oldValue).recycle(false);
}
}
}

View file

@ -125,7 +125,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} 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();
@ -2795,7 +2795,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
boolean canDelete = ImageLoader.getInstance().decrementUseCount(key);
if (!ImageLoader.getInstance().isInMemCache(key, true)) {
if (canDelete) {
fileDrawable.recycle();
fileDrawable.recycle(false);
}
}
} else if (image instanceof AnimatedFileDrawable) {

View file

@ -483,7 +483,7 @@ public class LocaleController {
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);
}
}
@ -493,11 +493,11 @@ public class LocaleController {
}
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);
}
}
@ -654,7 +654,7 @@ public class LocaleController {
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) {
@ -849,10 +849,10 @@ public class LocaleController {
}
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;
}
@ -885,9 +885,9 @@ public class LocaleController {
}
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 {
@ -929,13 +929,13 @@ public class LocaleController {
}
if (currentPluralRules == null) {
currentPluralRules = allRules.get(args[0]);
}
if (currentPluralRules == null) {
currentPluralRules = allRules.get(currentLocale.getLanguage());
}
if (currentPluralRules == null) {
currentPluralRules = new PluralRules_None();
}
}
}
changingConfiguration = true;
Locale.setDefault(currentLocale);
android.content.res.Configuration config = new android.content.res.Configuration();
@ -2063,6 +2063,9 @@ public class LocaleController {
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();
@ -2264,42 +2267,57 @@ public class LocaleController {
}, 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 {
@ -2308,9 +2326,12 @@ public class LocaleController {
}
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);
}

View file

@ -4211,9 +4211,6 @@ public class NotificationsController extends BaseController {
photoPath = null;
canReply = false;
}
if (passcode) {
canReply = false;
}
if (photoPath != null) {
avatalFile = getFileLoader().getPathToAttach(photoPath, true);

View file

@ -5751,6 +5751,13 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
} 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 {

View file

@ -1869,8 +1869,8 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
}
@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();
}
@ -1880,7 +1880,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
if (delegate != null && fragmentsStack.size() == 1 && AndroidUtilities.isTablet()) {
delegate.needCloseLastFragment(this);
}
removeFragmentFromStackInternal(fragment, true);
removeFragmentFromStackInternal(fragment, fragment.allowFinishFragmentInsteadOfRemoveFromStack() && !immediate);
}
}

View file

@ -311,6 +311,10 @@ public abstract class BaseFragment {
}
public void removeSelfFromStack() {
removeSelfFromStack(false);
}
public void removeSelfFromStack(boolean immediate) {
if (isFinished || parentLayout == null) {
return;
}
@ -318,7 +322,11 @@ public abstract class BaseFragment {
parentDialog.dismiss();
return;
}
parentLayout.removeFragmentFromStack(this);
parentLayout.removeFragmentFromStack(this, immediate);
}
public boolean allowFinishFragmentInsteadOfRemoveFromStack() {
return true;
}
protected boolean isFinishing() {

View file

@ -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);
@ -78,6 +78,9 @@ public interface INavigationLayout {
return SharedConfig.useLNavigation ? new LNavigation(context) : new ActionBarLayout(context);
}
default void removeFragmentFromStack(BaseFragment fragment) {
removeFragmentFromStack(fragment, false);
}
default boolean isActionBarInCrossfade() {
return false;
}

View file

@ -8888,22 +8888,22 @@ public class Theme {
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));

View file

@ -89,7 +89,7 @@ public class CacheChatsExceptionsFragment extends BaseFragment {
}
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++) {

View file

@ -40,6 +40,7 @@ import org.telegram.ui.Components.RLottieImageView;
import org.telegram.ui.Components.Switch;
import java.util.ArrayList;
import java.util.Locale;
public class TextCheckCell extends FrameLayout {
private boolean isAnimatingToThumbInsteadOfTouch;
@ -59,6 +60,7 @@ public class TextCheckCell extends FrameLayout {
private int padding;
private Theme.ResourcesProvider resourcesProvider;
ImageView imageView;
private boolean isRTL;
public static final Property<TextCheckCell, Float> ANIMATION_PROGRESS = new AnimationProperties.FloatProperty<TextCheckCell>("animationProgress") {
@Override
@ -121,6 +123,8 @@ public class TextCheckCell extends FrameLayout {
addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
setClipChildren(false);
isRTL = LocaleController.isRTL;
}
@Override
@ -167,6 +171,11 @@ public class TextCheckCell extends FrameLayout {
}
public void updateRTL() {
if (isRTL == LocaleController.isRTL) {
return;
}
isRTL = LocaleController.isRTL;
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
removeView(textView);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 70 : padding, 0, LocaleController.isRTL ? padding : 70, 0));

View file

@ -39,6 +39,7 @@ public class TextInfoPrivacyCell extends FrameLayout {
private int topPadding = 10;
private int bottomPadding = 17;
private int fixedSize;
private boolean isRTL;
private CharSequence text;
private final Theme.ResourcesProvider resourcesProvider;
@ -76,9 +77,23 @@ public class TextInfoPrivacyCell extends FrameLayout {
textView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, padding, 0, padding, 0));
isRTL = LocaleController.isRTL;
setWillNotDraw(false);
}
public void updateRTL() {
if (isRTL == LocaleController.isRTL) {
return;
}
isRTL = LocaleController.isRTL;
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) textView.getLayoutParams();
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
textView.setLayoutParams(layoutParams);
}
@Override
protected void onDraw(Canvas canvas) {
if (links != null) {

View file

@ -24,7 +24,6 @@ import org.telegram.ui.Components.AnimationProperties;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RadioButton;
import org.telegram.ui.Components.Switch;
import java.util.ArrayList;
@ -42,6 +41,8 @@ public class TextRadioCell extends FrameLayout {
private float lastTouchX;
private ObjectAnimator animator;
private boolean drawCheckRipple;
private boolean isRTL;
private int padding;
public static final Property<TextRadioCell, Float> ANIMATION_PROGRESS = new AnimationProperties.FloatProperty<TextRadioCell>("animationProgress") {
@Override
@ -67,6 +68,8 @@ public class TextRadioCell extends FrameLayout {
public TextRadioCell(Context context, int padding, boolean dialog) {
super(context);
this.padding = padding;
textView = new TextView(context);
textView.setTextColor(Theme.getColor(dialog ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@ -94,9 +97,33 @@ public class TextRadioCell extends FrameLayout {
radioButton.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked));
addView(radioButton, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
isRTL = LocaleController.isRTL;
setClipChildren(false);
}
public void updateRTL() {
if (isRTL == LocaleController.isRTL) {
return;
}
isRTL = LocaleController.isRTL;
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
FrameLayout.LayoutParams textViewLayout = (FrameLayout.LayoutParams) textView.getLayoutParams();
textViewLayout.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
textViewLayout.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? padding : 64);
textViewLayout.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 64 : padding);
textView.setLayoutParams(textViewLayout);
valueTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
FrameLayout.LayoutParams valueTextViewLayout = (FrameLayout.LayoutParams) valueTextView.getLayoutParams();
valueTextViewLayout.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
valueTextViewLayout.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? padding : 64);
valueTextViewLayout.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 64 : padding);
valueTextView.setLayoutParams(valueTextViewLayout);
FrameLayout.LayoutParams radioButtonLayout = (FrameLayout.LayoutParams) radioButton.getLayoutParams();
radioButtonLayout.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL;
radioButton.setLayoutParams(radioButtonLayout);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (isMultiline) {

View file

@ -16420,7 +16420,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (AndroidUtilities.isTablet() && parentLayout != null && parentLayout.getFragmentStack().size() > 1) {
finishFragment();
} else {
removeSelfFromStack();
removeSelfFromStack(true);
}
}
} else if (id == NotificationCenter.commentsRead) {
@ -24243,7 +24243,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onSwipeBackProgress(PopupSwipeBackLayout layout, float toProgress, float progress) {
if (toProgress == 0 && !isEnter) {
finalReactionsLayout.startEnterAnimation();
finalReactionsLayout.startEnterAnimation(false);
isEnter = true;
} else if (toProgress == 1 && isEnter) {
finalReactionsLayout.setAlpha(1f - progress);
@ -24377,7 +24377,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scrimPopupWindow.setDismissAnimationDuration(220);
scrimPopupWindow.setOutsideTouchable(true);
scrimPopupWindow.setClippingEnabled(true);
if (reactionsLayout == null) {
if (!isReactionsAvailable || reactionsLayout == null) {
scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
} else {
scrimPopupWindow.setAnimationStyle(0);
@ -24430,7 +24430,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
scrimPopupWindow.showAtLocation(chatListView, Gravity.LEFT | Gravity.TOP, finalPopupX, finalPopupY);
if (isReactionsAvailable && finalReactionsLayout != null) {
finalReactionsLayout.startEnterAnimation();
finalReactionsLayout.startEnterAnimation(true);
}
AndroidUtilities.runOnUIThread(() -> {
if (scrimPopupWindowItems != null && scrimPopupWindowItems.length > 0 && scrimPopupWindowItems[0] != null) {
@ -25530,7 +25530,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param) {
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment) {
if (forwardingMessage == null && selectedMessagesIds[0].size() == 0 && selectedMessagesIds[1].size() == 0) {
return false;
}

View file

@ -363,7 +363,7 @@ public class AlertsCreator {
} else if (request instanceof TLRPC.TL_messages_sendScheduledMessages) {
dialogId = DialogObject.getPeerDialogId(((TLRPC.TL_messages_sendScheduledMessages) request).peer);
}
if (BuildVars.DEBUG_VERSION && error.text != null && error.text.startsWith("CHAT_SEND_") && error.text.endsWith("FORBIDDEN")) {
if (error.text != null && error.text.startsWith("CHAT_SEND_") && error.text.endsWith("FORBIDDEN")) {
String errorText = error.text;
TLRPC.Chat chat = dialogId < 0 ? MessagesController.getInstance(currentAccount).getChat(-dialogId) : null;
switch (error.text) {
@ -628,7 +628,7 @@ public class AlertsCreator {
localeInfo.pathToFile = "unofficial";
}
}
LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, UserConfig.selectedAccount, null);
LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, true, UserConfig.selectedAccount, null);
activity.rebuildAllFragments(true);
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);

View file

@ -1395,7 +1395,7 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
DialogsActivity fragment = new DialogsActivity(args);
final ArrayList<MessageObject> fmessages = new ArrayList<>();
fmessages.add(messageObject);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
if (dids.size() > 1 || dids.get(0) .dialogId== UserConfig.getInstance(currentAccount).getClientUserId() || message != null) {
for (int a = 0; a < dids.size(); a++) {
long did = dids.get(a).dialogId;

View file

@ -150,6 +150,7 @@ import org.telegram.ui.PhotoViewer;
import org.telegram.ui.PremiumPreviewFragment;
import org.telegram.ui.ProfileActivity;
import org.telegram.ui.StickersActivity;
import org.telegram.ui.TopicsFragment;
import java.io.File;
import java.io.FileOutputStream;
@ -7415,7 +7416,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_BOT_SHARE);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
long uid = messageObject.messageOwner.from_id.user_id;
if (messageObject.messageOwner.via_bot_id != 0) {
uid = messageObject.messageOwner.via_bot_id;
@ -7483,7 +7484,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
@Override
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param) {
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment) {
if (dids != null && !dids.isEmpty()) {
TLRPC.TL_messages_sendBotRequestedPeer req = new TLRPC.TL_messages_sendBotRequestedPeer();
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(messageObject.messageOwner.peer_id);

View file

@ -994,13 +994,13 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
}
}
boolean mePremium = UserConfig.getInstance(currentAccount).isPremium();
// boolean mePremium = UserConfig.getInstance(currentAccount).isPremium();
ArrayList<TLRPC.TL_messages_stickerSet> canInstallPacks = new ArrayList<>(notInstalledPacks);
for (int i = 0; i < canInstallPacks.size(); ++i) {
if (MessageObject.isPremiumEmojiPack(canInstallPacks.get(i)) && !mePremium) {
canInstallPacks.remove(i--);
}
}
// for (int i = 0; i < canInstallPacks.size(); ++i) {
// if (MessageObject.isPremiumEmojiPack(canInstallPacks.get(i)) && !mePremium) {
// canInstallPacks.remove(i--);
// }
// }
boolean loadedNow = customEmojiPacks.inputStickerSets != null && allPacks.size() == customEmojiPacks.inputStickerSets.size();
if (!loaded && loadedNow) {
@ -1030,11 +1030,11 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
addButtonView.setVisibility(View.GONE);
removeButtonView.setVisibility(View.GONE);
updateShowButton(false);
} else if (canInstallPacks.size() <= 0 && notInstalledPacks.size() >= 0 && !mePremium || !loaded) {
premiumButtonView.setVisibility(View.VISIBLE);
addButtonView.setVisibility(View.GONE);
removeButtonView.setVisibility(View.GONE);
updateShowButton(true);
// } else if (canInstallPacks.size() <= 0 && notInstalledPacks.size() >= 0 && !mePremium || !loaded) {
// premiumButtonView.setVisibility(View.VISIBLE);
// addButtonView.setVisibility(View.GONE);
// removeButtonView.setVisibility(View.GONE);
// updateShowButton(true);
} else {
premiumButtonView.setVisibility(View.INVISIBLE);
if (canInstallPacks.size() > 0) {

View file

@ -23,7 +23,7 @@ public class HelloParticles {
"Sveiki", "Halo", "გამარჯობა", "Hallå", "Salam", "Tere", "Dia dhuit", "こんにちは", "Сайн уу",
"Bongu", "Ahoj", "γεια", "Zdravo", "नमस्ते", "Habari", "Hallo", "ជំរាបសួរ", "مرحبًا", "ನಮಸ್ಕಾರ",
"Салам", "Silav li wir", "سڵاو", "Kif inti", "Talofa", "Thobela", "हॅलो", "ሰላም", "Здраво",
"ഹലോ", "ہیلو", "ꯍꯦꯜꯂꯣ", "Alô", "வணக்கம்", "Mhoro", "Moni", "Alo", "สวัสดี", "Salom", ""
"ഹലോ", "ہیلو", "ꯍꯦꯜꯂꯣ", "Alô", "வணக்கம்", "Mhoro", "Moni", "Alo", "สวัสดี", "Salom", "Բարեւ"
};
public static class Drawable {

View file

@ -236,7 +236,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
if (destroyWhenDone) {
checkRunningTasks();
if (loadFrameTask == null && cacheGenerateTask == null && nativePtr != 0) {
recycleNativePtr();
recycleNativePtr(true);
}
}
if ((nativePtr == 0 || fallbackCache) && secondNativePtr == 0 && bitmapsCache == null) {
@ -250,12 +250,14 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
scheduleNextGetFrame();
}
private void recycleNativePtr() {
private void recycleNativePtr(boolean uiThread) {
long nativePtrFinal = nativePtr;
long secondNativePtrFinal = secondNativePtr;
nativePtr = 0;
secondNativePtr = 0;
if (nativePtrFinal != 0 || secondNativePtrFinal != 0) {
if (uiThread) {
DispatchQueuePoolBackground.execute(() -> {
if (nativePtrFinal != 0) {
destroy(nativePtrFinal);
@ -264,6 +266,17 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
destroy(secondNativePtrFinal);
}
});
} else {
Utilities.globalQueue.postRunnable(() ->{
if (nativePtrFinal != 0) {
destroy(nativePtrFinal);
}
if (secondNativePtrFinal != 0) {
destroy(secondNativePtrFinal);
}
});
}
}
}
protected void recycleResources() {
@ -611,7 +624,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
AndroidUtilities.runOnUIThread(() -> {
loadingInBackground = false;
if (!secondLoadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
return;
}
timeBetweenFrames = Math.max(16, (int) (1000.0f / metaData[1]));
@ -645,7 +658,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
AndroidUtilities.runOnUIThread(() -> {
secondLoadingInBackground = false;
if (!loadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
}
});
return;
@ -655,7 +668,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
AndroidUtilities.runOnUIThread(() -> {
secondLoadingInBackground = false;
if (!secondLoadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
return;
}
secondFramesCount = metaData2[0];
@ -817,14 +830,14 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
}
}
public void recycle() {
public void recycle(boolean uiThread) {
isRunning = false;
isRecycled = true;
checkRunningTasks();
if (loadingInBackground || secondLoadingInBackground) {
destroyAfterLoading = true;
} else if (loadFrameTask == null && cacheGenerateTask == null && !generatingCache) {
recycleNativePtr();
recycleNativePtr(uiThread);
if (bitmapsCache != null) {
bitmapsCache.recycle();
bitmapsCache = null;
@ -853,7 +866,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
@Override
protected void finalize() throws Throwable {
try {
recycle();
recycle(false);
} finally {
super.finalize();
}

View file

@ -292,7 +292,7 @@ public class ChatSelectionReactionMenuOverlay extends FrameLayout {
}
private boolean isMessageTypeAllowed(MessageObject obj) {
return MessageObject.isPhoto(obj.messageOwner) || obj.getDocument() != null && MessageObject.isVideoDocument(obj.getDocument());
return MessageObject.isPhoto(obj.messageOwner) || obj.getDocument() != null && (MessageObject.isVideoDocument(obj.getDocument()) || MessageObject.isGifDocument(obj.getDocument()));
}
public void setSelectedMessages(List<MessageObject> messages) {
@ -341,7 +341,7 @@ public class ChatSelectionReactionMenuOverlay extends FrameLayout {
if (reactionsContainerLayout.isEnabled()) {
messageSet = true;
reactionsContainerLayout.setMessage(currentPrimaryObject, parentFragment.getCurrentChatInfo());
reactionsContainerLayout.startEnterAnimation();
reactionsContainerLayout.startEnterAnimation(false);
} else {
messageSet = false;
reactionsContainerLayout.setTransitionProgress(1f);

View file

@ -162,6 +162,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio
private boolean allReactionsIsDefault;
private Paint selectedPaint;
ChatScrimPopupContainerLayout parentLayout;
private boolean animatePopup;
public ReactionsContainerLayout(BaseFragment fragment, @NonNull Context context, int currentAccount, Theme.ResourcesProvider resourcesProvider) {
super(context);
@ -925,7 +926,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio
public void setTransitionProgress(float transitionProgress) {
this.transitionProgress = transitionProgress;
if (parentLayout != null && parentLayout.getPopupWindowLayout() != null) {
parentLayout.getPopupWindowLayout().setReactionsTransitionProgress(transitionProgress);
parentLayout.getPopupWindowLayout().setReactionsTransitionProgress(animatePopup ? transitionProgress : 1);
}
invalidate();
}
@ -1046,7 +1047,8 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio
}
}
public void startEnterAnimation() {
public void startEnterAnimation(boolean animatePopup) {
this.animatePopup = animatePopup;
setTransitionProgress(0);
setAlpha(1f);
ObjectAnimator animator = ObjectAnimator.ofFloat(this, ReactionsContainerLayout.TRANSITION_PROGRESS_VALUE, 0f, 1f).setDuration(350);
@ -1559,7 +1561,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio
if (chatFull.id == waitingLoadingChatId && getVisibility() != View.VISIBLE && !(chatFull.available_reactions instanceof TLRPC.TL_chatReactionsNone)) {
setMessage(messageObject, null);
setVisibility(View.VISIBLE);
startEnterAnimation();
startEnterAnimation(false);
}
}
}

View file

@ -520,7 +520,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
ArrayList<MessageObject> fmessages = new ArrayList<>();
Iterator<FilteredSearchView.MessageHashId> idIterator = selectedFiles.keySet().iterator();
while (idIterator.hasNext()) {

View file

@ -3256,7 +3256,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
args.putBoolean("canSelectTopics", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
ArrayList<MessageObject> fmessages = new ArrayList<>();
for (int a = 1; a >= 0; a--) {
ArrayList<Integer> ids = new ArrayList<>();

View file

@ -196,7 +196,7 @@ public class SlotsDrawable extends RLottieDrawable {
AndroidUtilities.runOnUIThread(() -> {
loadingInBackground = false;
if (!secondLoadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
}
});
return;
@ -240,7 +240,7 @@ public class SlotsDrawable extends RLottieDrawable {
AndroidUtilities.runOnUIThread(() -> {
loadingInBackground = false;
if (!secondLoadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
return;
}
nativePtr = nativePtrs[0];
@ -268,7 +268,7 @@ public class SlotsDrawable extends RLottieDrawable {
AndroidUtilities.runOnUIThread(() -> {
secondLoadingInBackground = false;
if (!loadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
}
});
return;
@ -359,7 +359,7 @@ public class SlotsDrawable extends RLottieDrawable {
}
secondLoadingInBackground = false;
if (!loadingInBackground && destroyAfterLoading) {
recycle();
recycle(true);
return;
}
secondNativePtr = secondNativePtrs[0];
@ -373,7 +373,7 @@ public class SlotsDrawable extends RLottieDrawable {
}
@Override
public void recycle() {
public void recycle(boolean uiThread) {
isRunning = false;
isRecycled = true;
checkRunningTasks();

View file

@ -234,9 +234,18 @@ public class TranslateButton extends FrameLayout {
RestrictedLanguagesSelectActivity.toggleLanguage(detectedLanguage, true);
translateController.checkRestrictedLanguagesUpdate();
translateController.setHideTranslateDialog(dialogId, true);
BulletinFactory.of(fragment).createSimpleBulletin(R.raw.msg_translate, AndroidUtilities.replaceTags(LocaleController.formatString("AddedToDoNotTranslate", R.string.AddedToDoNotTranslate, TranslateAlert2.capitalFirst(detectedLanguageName))), LocaleController.getString("Settings", R.string.Settings), () -> {
fragment.presentFragment(new RestrictedLanguagesSelectActivity());
}).show();
String bulletinText;
if (accusative[0]) {
bulletinText = LocaleController.formatString("AddedToDoNotTranslate", R.string.AddedToDoNotTranslate, TranslateAlert2.capitalFirst(detectedLanguageNameAccusative));
} else {
bulletinText = LocaleController.formatString("AddedToDoNotTranslateOther", R.string.AddedToDoNotTranslateOther, TranslateAlert2.capitalFirst(detectedLanguageNameAccusative));
}
BulletinFactory.of(fragment).createSimpleBulletin(
R.raw.msg_translate,
bulletinText,
LocaleController.getString("Settings", R.string.Settings),
() -> fragment.presentFragment(new RestrictedLanguagesSelectActivity())
).show();
popupWindow.dismiss();
});
popupLayout.addView(dontTranslateButton);

View file

@ -938,7 +938,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
} else if (id == NotificationCenter.closeChats) {
if (!creatingChat) {
removeSelfFromStack();
removeSelfFromStack(true);
}
}
}

View file

@ -89,7 +89,7 @@ public class DialogOrContactPickerActivity extends BaseFragment {
args.putBoolean("resetDelegate", false);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_BLOCK);
dialogsActivity = new DialogsActivity(args);
dialogsActivity.setDelegate((fragment, dids, message, param) -> {
dialogsActivity.setDelegate((fragment, dids, message, param, topicsFragment) -> {
if (dids.isEmpty()) {
return true;
}

View file

@ -2201,7 +2201,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
public interface DialogsActivityDelegate {
boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param);
boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment);
}
public DialogsActivity(Bundle args) {
@ -3380,7 +3380,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (closeFragment) {
removeSelfFromStack();
}
dialogsActivityDelegate.didSelectDialogs(DialogsActivity.this, arrayList, null, true);
dialogsActivityDelegate.didSelectDialogs(DialogsActivity.this, arrayList, null, true, null);
}
@Override
@ -3850,7 +3850,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
for (int i = 0; i < selectedDialogs.size(); i++) {
topicKeys.add(MessagesStorage.TopicKey.of(selectedDialogs.get(i), 0));
}
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, null, false);
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, null, false, null);
} else {
if (floatingButton.getVisibility() != View.VISIBLE) {
return;
@ -3989,7 +3989,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
for (int i = 0; i < selectedDialogs.size(); i++) {
topicKeys.add(MessagesStorage.TopicKey.of(selectedDialogs.get(i), 0));
}
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, message, false);
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, message, false, null);
}
@Override
@ -4182,7 +4182,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
for (int i = 0; i < selectedDialogs.size(); i++) {
topicKeys.add(MessagesStorage.TopicKey.of(selectedDialogs.get(i), 0));
}
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, commentView.getFieldText(), false);
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, commentView.getFieldText(), false, null);
});
writeButtonBackground.setOnLongClickListener(v -> {
if (isNextButton) {
@ -4834,7 +4834,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (delegate != null) {
ArrayList<MessagesStorage.TopicKey> keys = new ArrayList<>();
keys.add(MessagesStorage.TopicKey.of(-chatId, 0));
delegate.didSelectDialogs(DialogsActivity.this, keys, null, false);
delegate.didSelectDialogs(DialogsActivity.this, keys, null, false, null);
}
}
);
@ -4935,7 +4935,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (delegate != null) {
ArrayList<MessagesStorage.TopicKey> keys = new ArrayList<>();
keys.add(MessagesStorage.TopicKey.of(-chatId, 0));
delegate.didSelectDialogs(DialogsActivity.this, keys, null, false);
delegate.didSelectDialogs(DialogsActivity.this, keys, null, false, null);
}
}
);
@ -5262,6 +5262,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
int[] position = new int[2];
passcodeItem.getLocationInWindow(position);
((LaunchActivity) getParentActivity()).showPasscodeActivity(false, true, position[0] + passcodeItem.getMeasuredWidth() / 2, position[1] + passcodeItem.getMeasuredHeight() / 2, () -> passcodeItem.setAlpha(1.0f), () -> passcodeItem.setAlpha(0.0f));
getNotificationsController().showNotifications();
updatePasscodeButton();
} else if (id == 2) {
presentFragment(new ProxyListActivity());
@ -9509,6 +9510,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
public void didSelectResult(final long dialogId, int topicId, boolean useAlert, final boolean param) {
didSelectResult(dialogId, topicId, useAlert, param, null);
}
public void didSelectResult(final long dialogId, int topicId, boolean useAlert, final boolean param, TopicsFragment topicsFragment) {
if (!checkCanWrite(dialogId)) {
return;
}
@ -9549,7 +9554,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
setDialogsListFrozen(true);
ArrayList<MessagesStorage.TopicKey> dids = new ArrayList<>();
dids.add(MessagesStorage.TopicKey.of(dialogId, 0));
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param, null);
});
} else {
AlertsCreator.processError(currentAccount, error, this, req);
@ -9617,7 +9622,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
builder.setTitle(title);
builder.setMessage(AndroidUtilities.replaceTags(message));
builder.setPositiveButton(buttonText, (dialogInterface, i) -> didSelectResult(dialogId, topicId,false, false));
builder.setPositiveButton(buttonText, (dialogInterface, i) -> didSelectResult(dialogId, topicId,false, false, topicsFragment));
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
} else if (initialDialogsType == DIALOGS_TYPE_BOT_REQUEST_PEER) {
@ -9625,7 +9630,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (delegate != null) {
ArrayList<MessagesStorage.TopicKey> dids = new ArrayList<>();
dids.add(MessagesStorage.TopicKey.of(dialogId, topicId));
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param, topicsFragment);
if (resetDelegate) {
delegate = null;
}
@ -9653,7 +9658,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (delegate != null) {
ArrayList<MessagesStorage.TopicKey> dids = new ArrayList<>();
dids.add(MessagesStorage.TopicKey.of(dialogId, topicId));
boolean res = delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
boolean res = delegate.didSelectDialogs(DialogsActivity.this, dids, null, param, topicsFragment);
if (res && resetDelegate) {
delegate = null;
}
@ -9767,7 +9772,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
for (int i = 0; i < selectedDialogs.size(); i++) {
topicKeys.add(MessagesStorage.TopicKey.of(selectedDialogs.get(i), 0));
}
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, commentView.getFieldText(), false);
delegate.didSelectDialogs(DialogsActivity.this, topicKeys, commentView.getFieldText(), false, null);
});
layout.addView(sendPopupLayout2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

View file

@ -31,7 +31,7 @@ public class FeedWidgetConfigActivity extends ExternalActionActivity {
args.putBoolean("allowSwitchAccount", true);
args.putBoolean("checkCanWrite", false);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
AccountInstance.getInstance(fragment1.getCurrentAccount()).getMessagesStorage().putWidgetDialogs(creatingAppWidgetId, dids);
SharedPreferences preferences = FeedWidgetConfigActivity.this.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE);

View file

@ -98,7 +98,7 @@ public class KeepMediaPopupView extends ActionBarPopupWindow.ActionBarPopupWindo
}
args.putBoolean("allowGlobalSearch", false);
DialogsActivity activity = new DialogsActivity(args);
activity.setDelegate((fragment, dids, message, param) -> {
activity.setDelegate((fragment, dids, message, param, topicsFragment) -> {
CacheByChatsController.KeepMediaException newException = null;
for (int i = 0; i < dids.size(); i++) {
exceptions.add(newException = new CacheByChatsController.KeepMediaException(dids.get(i).dialogId, CacheByChatsController.KEEP_MEDIA_ONE_DAY));

View file

@ -1078,7 +1078,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float
}
@Override
public void removeFragmentFromStack(BaseFragment fragment) {
public void removeFragmentFromStack(BaseFragment fragment, boolean immediate) {
int i = fragmentStack.indexOf(fragment);
if (i == -1) {
return;

View file

@ -8,30 +8,23 @@
package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LanguageDetector;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
@ -220,7 +213,16 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
final boolean currentFullValue = getContextValue() || getChatValue();
if (currentFullValue != prevFullValue) {
int start = 1 + (!getMessagesController().premiumLocked ? 1 : 0);
listAdapter.notifyItemChanged(start);
TextCheckCell last = null;
for (int i = 0; i < listView.getChildCount(); ++i) {
View child = listView.getChildAt(i);
if (listView.getChildAdapterPosition(child) == start && child instanceof TextCheckCell) {
last = (TextCheckCell) child;
}
}
if (last != null) {
last.setDivider(currentFullValue);
}
if (currentFullValue) {
listAdapter.notifyItemInserted(start + 1);
} else {
@ -255,11 +257,16 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
boolean sameLang = prevLocale == localeInfo;
final AlertDialog progressDialog = new AlertDialog(getContext(), AlertDialog.ALERT_TYPE_SPINNER);
int reqId = LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, currentAccount, () -> {
if (!sameLang) {
progressDialog.showDelayed(500);
}
int reqId = LocaleController.getInstance().applyLanguage(localeInfo, true, false, false, true, false, currentAccount, () -> {
progressDialog.dismiss();
if (!sameLang) {
AndroidUtilities.runOnUIThread(() -> {
actionBar.closeSearchField();
updateLanguage();
}, 10);
}
});
if (reqId != 0) {
@ -276,16 +283,14 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
if (selectedLanguages.contains(prevLangCode) && !selectedLanguages.contains(langCode)) {
newSelectedLanguages.removeIf(s -> s != null && s.equals(prevLangCode));
if (langCode != null && !"null".equals(langCode)) {
newSelectedLanguages.add(langCode);
}
}
preferences.edit().putStringSet("translate_button_restricted_languages", newSelectedLanguages).apply();
MessagesController.getInstance(currentAccount).getTranslateController().checkRestrictedLanguagesUpdate();
MessagesController.getInstance(currentAccount).getTranslateController().cleanup();
if (!sameLang) {
progressDialog.showDelayed(500);
}
TranslateController.invalidateSuggestedLanguageCodes();
}
} catch (Exception e) {
@ -420,26 +425,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
listView.setAdapter(listAdapter);
}
} else {
// try {
// if (searchTimer != null) {
// searchTimer.cancel();
// }
// } catch (Exception e) {
// FileLog.e(e);
// }
// searchTimer = new Timer();
// searchTimer.schedule(new TimerTask() {
// @Override
// public void run() {
// try {
// searchTimer.cancel();
// searchTimer = null;
// } catch (Exception e) {
// FileLog.e(e);
// }
processSearch(query);
// }
// }, 100, 300);
}
}
@ -447,15 +433,17 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
if (actionBar != null) {
actionBar.setTitleAnimated(LocaleController.getString("Language", R.string.Language), true, 350, CubicBezierInterpolator.EASE_OUT_QUINT);
}
if (listView != null) {
for (int i = 0; i < listView.getChildCount(); ++i) {
View child = listView.getChildAt(i);
if (child instanceof TranslateSettings || child instanceof HeaderCell) {
listAdapter.notifyItemChanged(listView.getChildAdapterPosition(child));
} else {
listAdapter.onBindViewHolder(listView.getChildViewHolder(child), listView.getChildAdapterPosition(child));
}
}
if (listAdapter != null) {
listAdapter.notifyItemRangeChanged(0, listAdapter.getItemCount());
// for (int i = 0; i < listView.getChildCount(); ++i) {
// View child = listView.getChildAt(i);
// listAdapter.onBindViewHolder(listView.getChildViewHolder(child), listView.getChildAdapterPosition(child));
// if (child instanceof TextRadioCell) {
// ((TextRadioCell) child).updateRTL();
// } else if (child instanceof TextInfoPrivacyCell) {
// ((TextInfoPrivacyCell) child).updateRTL();
// }
// }
}
}
@ -495,278 +483,6 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
});
}
private class TranslateSettings extends LinearLayout {
private SharedPreferences preferences;
private HeaderCell header;
private TextCheckCell showButtonCheck;
private TextCheckCell showChatButtonCheck;
private TextSettingsCell doNotTranslateCell;
private TextInfoPrivacyCell info;
private TextInfoPrivacyCell info2;
private ValueAnimator doNotTranslateCellAnimation = null;
// private HeaderCell header2;
// private float HEIGHT_OPEN = 243;
// private float HEIGHT_CLOSED = HEIGHT_OPEN - 50;
private Drawable topShadow, bottomShadow;
public TranslateSettings(Context context) {
super(context);
setFocusable(false);
setOrientation(VERTICAL);
topShadow = Theme.getThemedDrawable(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
bottomShadow = Theme.getThemedDrawable(context, R.drawable.greydivider_top, Theme.key_windowBackgroundGrayShadow);
preferences = MessagesController.getMainSettings(currentAccount);
header = new HeaderCell(context);
header.setFocusable(true);
header.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
header.setText(LocaleController.getString("TranslateMessages", R.string.TranslateMessages));
header.setContentDescription(LocaleController.getString("TranslateMessages", R.string.TranslateMessages));
addView(header, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
final boolean value = getValue();
showButtonCheck = new TextCheckCell(context);
showButtonCheck.setBackground(Theme.createSelectorWithBackgroundDrawable(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_listSelector)));
showButtonCheck.setTextAndCheck(
LocaleController.getString("ShowTranslateButton", R.string.ShowTranslateButton),
getContextValue(),
true
);
showButtonCheck.setOnClickListener(e -> {
getMessagesController().getTranslateController().setContextTranslateEnabled(!getContextValue());
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateSearchSettings);
update();
});
addView(showButtonCheck, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
showChatButtonCheck = new TextCheckCell(context);
showChatButtonCheck.setBackground(Theme.createSelectorWithBackgroundDrawable(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_listSelector)));
showChatButtonCheck.setTextAndCheck(
LocaleController.getString("ShowTranslateChatButton", R.string.ShowTranslateChatButton),
getChatValue(),
value
);
showChatButtonCheck.setOnClickListener(e -> {
if (!getUserConfig().isPremium()) {
showDialog(new PremiumFeatureBottomSheet(LanguageSelectActivity.this, PremiumPreviewFragment.PREMIUM_FEATURE_TRANSLATIONS, false));
return;
}
MessagesController.getMainSettings(currentAccount).edit().putBoolean("translate_chat_button", !getChatValue()).apply();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.updateSearchSettings);
update();
});
showChatButtonCheck.setCheckBoxIcon(!getUserConfig().isPremium() ? R.drawable.permission_locked : 0);
addView(showChatButtonCheck, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
doNotTranslateCell = new TextSettingsCell(context);
doNotTranslateCell.setBackground(Theme.createSelectorWithBackgroundDrawable(Theme.getColor(Theme.key_windowBackgroundWhite), Theme.getColor(Theme.key_listSelector)));
doNotTranslateCell.setOnClickListener(e -> {
presentFragment(new RestrictedLanguagesSelectActivity());
update();
});
doNotTranslateCell.setClickable(value && LanguageDetector.hasSupport());
doNotTranslateCell.setAlpha(value && LanguageDetector.hasSupport() ? 1f : 0f);
addView(doNotTranslateCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
info = new TextInfoPrivacyCell(context);
info.setTopPadding(11);
info.setBottomPadding(16);
info.setFocusable(true);
info.setText(LocaleController.getString("TranslateMessagesInfo1", R.string.TranslateMessagesInfo1));
info.setContentDescription(LocaleController.getString("TranslateMessagesInfo1", R.string.TranslateMessagesInfo1));
addView(info, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
info2 = new TextInfoPrivacyCell(context);
info2.setTopPadding(0);
info2.setBottomPadding(16);
info2.setFocusable(true);
info2.setText(LocaleController.getString("TranslateMessagesInfo2", R.string.TranslateMessagesInfo2));
info2.setContentDescription(LocaleController.getString("TranslateMessagesInfo2", R.string.TranslateMessagesInfo2));
info2.setAlpha(value ? 0f : 1f);
addView(info2, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
// header2 = new HeaderCell(context);
// header2.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
// header2.setText(LocaleController.getString("Language", R.string.Language));
// header2.setTranslationY(-Math.max(doNotTranslateCell.getHeight(), info2.getHeight()));
// addView(header2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM));
// setLayoutParams(new RecyclerView.LayoutParams(LayoutHelper.MATCH_PARENT, height()));
updateHeight();
update();
}
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
float topShadowY = Math.max(showChatButtonCheck.getY() + showChatButtonCheck.getHeight(), doNotTranslateCell.getY() + doNotTranslateCell.getHeight() * doNotTranslateCell.getAlpha());
topShadow.setBounds(0, (int) topShadowY, getWidth(), (int) (topShadowY + AndroidUtilities.dp(12)));
topShadow.draw(canvas);
float bottomShadowY = getHeight();
bottomShadow.setBounds(0, (int) (bottomShadowY - AndroidUtilities.dp(12)), getWidth(), (int) bottomShadowY);
bottomShadow.draw(canvas);
}
public void updateTranslations() {
header.setText(LocaleController.getString("TranslateMessages", R.string.TranslateMessages));
showButtonCheck.setTextAndCheck(
LocaleController.getString("ShowTranslateButton", R.string.ShowTranslateButton), getContextValue(), true
);
showChatButtonCheck.setTextAndCheck(
LocaleController.getString("ShowTranslateChatButton", R.string.ShowTranslateChatButton), getChatValue(), getValue()
);
showChatButtonCheck.setCheckBoxIcon(!getUserConfig().isPremium() ? R.drawable.permission_locked : 0);
showButtonCheck.updateRTL();
doNotTranslateCell.updateRTL();
info.setText(LocaleController.getString("TranslateMessagesInfo1", R.string.TranslateMessagesInfo1));
info.getTextView().setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
info2.setText(LocaleController.getString("TranslateMessagesInfo2", R.string.TranslateMessagesInfo2));
info2.getTextView().setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
update();
updateHeight();
}
private boolean getValue() {
return getContextValue() || getChatValue();
}
public void update() {
boolean value = getValue() && LanguageDetector.hasSupport();
showButtonCheck.setChecked(getContextValue());
showChatButtonCheck.setChecked(getChatValue());
if (doNotTranslateCellAnimation != null) {
doNotTranslateCellAnimation.cancel();
}
showChatButtonCheck.setDivider(value);
HashSet<String> langCodes = RestrictedLanguagesSelectActivity.getRestrictedLanguages();
final String doNotTranslateCellName = LocaleController.getString("DoNotTranslate", R.string.DoNotTranslate);
String doNotTranslateCellValue = null;
try {
if (langCodes.size() == 1) {
doNotTranslateCellValue = TranslateAlert2.capitalFirst(TranslateAlert2.languageName(langCodes.iterator().next()));
} else {
Iterator<String> iterator = langCodes.iterator();
boolean first = true;
StringBuilder string = new StringBuilder();
while (iterator.hasNext()) {
String lang = iterator.next();
if (!first) {
string.append(", ");
}
string.append(TranslateAlert2.capitalFirst(TranslateAlert2.languageName(lang)));
first = false;
}
doNotTranslateCellValue = string.toString();
if (doNotTranslateCell.getValueTextView().getPaint().measureText(doNotTranslateCellValue) >
Math.min((AndroidUtilities.displaySize.x - AndroidUtilities.dp(34)) / 2f, AndroidUtilities.displaySize.x - AndroidUtilities.dp(21 * 4) - doNotTranslateCell.getTextView().getPaint().measureText(doNotTranslateCellName))) {
doNotTranslateCellValue = null;
}
}
} catch (Exception ignore) {}
if (doNotTranslateCellValue == null)
doNotTranslateCellValue = String.format(LocaleController.getPluralString("Languages", langCodes.size()), langCodes.size());
doNotTranslateCell.setTextAndValue(doNotTranslateCellName, doNotTranslateCellValue, false, false);
doNotTranslateCell.setClickable(value);
info2.setVisibility(View.VISIBLE);
doNotTranslateCellAnimation = ValueAnimator.ofFloat(doNotTranslateCell.getAlpha(), value ? 1f : 0f);
doNotTranslateCellAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
doNotTranslateCellAnimation.addUpdateListener(a -> {
float t = (float) a.getAnimatedValue();
doNotTranslateCell.setAlpha(t);
doNotTranslateCell.setTranslationY(-AndroidUtilities.dp(8) * (1f - t));
info.setTranslationY(-doNotTranslateCell.getHeight() * (1f - t));
t = 1f;
info2.setAlpha(1f - t);
info2.setTranslationY(-doNotTranslateCell.getHeight() * (1f - t));
translateSettingsBackgroundHeight = header.getMeasuredHeight() + showButtonCheck.getMeasuredHeight() + (int) (doNotTranslateCell.getAlpha() * doNotTranslateCell.getMeasuredHeight());
invalidate();
});
doNotTranslateCellAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (doNotTranslateCell.getAlpha() > .5) {
info2.setVisibility(View.GONE);
} else {
info2.setVisibility(View.VISIBLE);
}
translateSettingsBackgroundHeight = header.getMeasuredHeight() + showButtonCheck.getMeasuredHeight() + (int) (doNotTranslateCell.getAlpha() * doNotTranslateCell.getMeasuredHeight());
invalidate();
}
});
doNotTranslateCellAnimation.setDuration((long) (Math.abs(doNotTranslateCell.getAlpha() - (value ? 1f : 0f)) * 200));
doNotTranslateCellAnimation.start();
// updateHeight();
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateHeight();
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
updateHeight();
super.onLayout(changed, l, t, r, b);
}
void updateHeight() {
header.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
showButtonCheck.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
showChatButtonCheck.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
doNotTranslateCell.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
info.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
info2.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, MeasureSpec.EXACTLY), MeasureSpec.UNSPECIFIED);
int newHeight = searching ? 0 : height();
if (getLayoutParams() == null) {
setLayoutParams(new RecyclerView.LayoutParams(LayoutHelper.MATCH_PARENT, newHeight));
} else if (getLayoutParams().height != newHeight) {
RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) getLayoutParams();
lp.height = newHeight;
setLayoutParams(lp);
}
invalidate();
}
int height() {
return Math.max(AndroidUtilities.dp(40), header.getMeasuredHeight()) +
Math.max(AndroidUtilities.dp(50), showButtonCheck.getMeasuredHeight()) +
Math.max(AndroidUtilities.dp(50), showChatButtonCheck.getMeasuredHeight()) +
Math.max(Math.max(AndroidUtilities.dp(50), doNotTranslateCell.getMeasuredHeight()), (info2.getMeasuredHeight() <= 0 ? AndroidUtilities.dp(51) : info2.getMeasuredHeight())) +
(info.getMeasuredHeight() <= 0 ? AndroidUtilities.dp(62) : info.getMeasuredHeight());/* + header2.getHeight()*/
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
updateHeight();
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
update();
updateHeight();
}
}
private boolean getContextValue() {
return getMessagesController().getTranslateController().isContextTranslateEnabled();
}
@ -854,6 +570,13 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
return new RecyclerListView.Holder(view);
}
@Override
public void onViewAttachedToWindow(@NonNull RecyclerView.ViewHolder holder) {
if (holder.itemView instanceof TextRadioCell) {
((TextRadioCell) holder.itemView).updateRTL();
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
@ -862,6 +585,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
position -= (7 - (!(getChatValue() || getContextValue()) ? 1 : 0) - (getMessagesController().premiumLocked ? 1 : 0));
}
TextRadioCell textSettingsCell = (TextRadioCell) holder.itemView;
textSettingsCell.updateRTL();
LocaleController.LocaleInfo localeInfo = null;
boolean last;
if (search) {
@ -904,6 +628,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
}
case VIEW_TYPE_SETTINGS: {
TextSettingsCell settingsCell = (TextSettingsCell) holder.itemView;
settingsCell.updateRTL();
HashSet<String> langCodes = RestrictedLanguagesSelectActivity.getRestrictedLanguages();
final String doNotTranslateCellName = LocaleController.getString("DoNotTranslate", R.string.DoNotTranslate);
String doNotTranslateCellValue = null;
@ -920,9 +645,12 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
if (!first) {
string.append(", ");
}
string.append(TranslateAlert2.capitalFirst(TranslateAlert2.languageName(lang, accusative)));
String langName = TranslateAlert2.capitalFirst(TranslateAlert2.languageName(lang, accusative));
if (langName != null) {
string.append(langName);
first = false;
}
}
doNotTranslateCellValue = string.toString();
if (settingsCell.getValueTextView().getPaint().measureText(doNotTranslateCellValue) > Math.min((AndroidUtilities.displaySize.x - AndroidUtilities.dp(34)) / 2f, AndroidUtilities.displaySize.x - AndroidUtilities.dp(21 * 4) - settingsCell.getTextView().getPaint().measureText(doNotTranslateCellName))) {
doNotTranslateCellValue = null;
@ -937,6 +665,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
}
case VIEW_TYPE_SWITCH: {
TextCheckCell cell = (TextCheckCell) holder.itemView;
cell.updateRTL();
if (position == 1) {
cell.setTextAndCheck(LocaleController.getString("ShowTranslateButton", R.string.ShowTranslateButton), getContextValue(), true);
} else if (position == 2) {
@ -947,6 +676,7 @@ public class LanguageSelectActivity extends BaseFragment implements Notification
}
case VIEW_TYPE_INFO: {
TextInfoPrivacyCell infoCell = (TextInfoPrivacyCell) holder.itemView;
infoCell.updateRTL();
if (position == (getContextValue() || getChatValue() ? 4 : 3)) {
infoCell.setText(LocaleController.getString("TranslateMessagesInfo1", R.string.TranslateMessagesInfo1));
infoCell.setBackground(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));

View file

@ -50,7 +50,6 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.util.Base64;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.TypedValue;
@ -88,11 +87,11 @@ import com.google.firebase.appindexing.Action;
import com.google.firebase.appindexing.FirebaseUserActions;
import com.google.firebase.appindexing.builders.AssistActionBuilder;
import org.telegram.messenger.BackupAgent;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AccountInstance;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BackupAgent;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ChatObject;
@ -112,6 +111,7 @@ import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.NotificationsController;
import org.telegram.messenger.PushListenerController;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
@ -1564,11 +1564,21 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
rightActionBarLayout.getView().setVisibility(View.VISIBLE);
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.passcodeDismissed, view);
try {
NotificationsController.getInstance(UserConfig.selectedAccount).showNotifications();
} catch (Exception e) {
FileLog.e(e);
}
};
passcodeView.setDelegate(delegate);
for (PasscodeView overlay : overlayPasscodeViews) {
overlay.setDelegate(delegate);
}
try {
NotificationsController.getInstance(UserConfig.selectedAccount).showNotifications();
} catch (Exception e) {
FileLog.e(e);
}
}
public boolean allowShowFingerprintDialog(PasscodeView passcodeView) {
@ -2774,7 +2784,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
} else {
ArrayList<MessagesStorage.TopicKey> dids = new ArrayList<>();
dids.add(MessagesStorage.TopicKey.of(dialogId, 0));
didSelectDialogs(null, dids, null, false);
didSelectDialogs(null, dids, null, false, null);
}
} else if (open_settings != 0) {
BaseFragment fragment;
@ -3505,7 +3515,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
args.putBoolean("allowBots", chooserTargets.contains("bots"));
dialogsActivity = new DialogsActivity(args);
dialogsActivity.setDelegate((fragment, dids, message1, param) -> {
dialogsActivity.setDelegate((fragment, dids, message1, param, topicsFragment) -> {
long did = dids.get(0).dialogId;
Bundle args1 = new Bundle();
@ -3615,7 +3625,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
args.putString("selectAlertString", LocaleController.getString("SendGameToText", R.string.SendGameToText));
args.putString("selectAlertStringGroup", LocaleController.getString("SendGameToGroupText", R.string.SendGameToGroupText));
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message1, param) -> {
fragment.setDelegate((fragment1, dids, message1, param, topicsFragment) -> {
long did = dids.get(0).dialogId;
TLRPC.TL_inputMediaGame inputMediaGame = new TLRPC.TL_inputMediaGame();
inputMediaGame.id = new TLRPC.TL_inputGameShortName();
@ -3684,7 +3694,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
final String botHash = TextUtils.isEmpty(botChat) ? (TextUtils.isEmpty(botChannel) ? null : botChannel) : botChat;
// args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupAlertText", R.string.AddToTheGroupAlertText, UserObject.getUserName(user), "%1$s"));
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment12, dids, message1, param) -> {
fragment.setDelegate((fragment12, dids, message1, param, topicsFragment) -> {
long did = dids.get(0).dialogId;
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-did);
@ -4163,7 +4173,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment13, dids, m, param) -> {
fragment.setDelegate((fragment13, dids, m, param, topicsFragment) -> {
long did = dids.get(0).dialogId;
Bundle args13 = new Bundle();
args13.putBoolean("scrollToTopOnResume", true);
@ -4921,7 +4931,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
@Override
public boolean didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param) {
public boolean didSelectDialogs(DialogsActivity dialogsFragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment) {
final int account = dialogsFragment != null ? dialogsFragment.getCurrentAccount() : currentAccount;
if (exportingChatUri != null) {
@ -5016,7 +5026,12 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
}
if (topicsFragment != null) {
topicsFragment.removeSelfFromStack();
}
boolean presentedFragmentWithRemoveLast = false;
if (contactsToSend != null && contactsToSend.size() == 1 && !mainFragmentsStack.isEmpty()) {
presentedFragmentWithRemoveLast = true;
PhonebookShareAlert alert = new PhonebookShareAlert(mainFragmentsStack.get(mainFragmentsStack.size() - 1), null, null, contactsToSendUri, null, null, null);
alert.setDelegate((user, notify2, scheduleDate) -> {
if (fragment != null) {
@ -5025,7 +5040,17 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
for (int i = 0; i < dids.size(); i++) {
long did = dids.get(i).dialogId;
SendMessagesHelper.getInstance(account).sendMessage(user, did, null, null, null, null, notify2, scheduleDate);
int topicId = dids.get(i).topicId;
MessageObject replyToMsg = null;
if (topicId != 0) {
TLRPC.TL_forumTopic topic = accountInstance.getMessagesController().getTopicsController().findTopic(-did, topicId);
if (topic != null && topic.topicStartMessage != null) {
replyToMsg = new MessageObject(accountInstance.getCurrentAccount(), topic.topicStartMessage, false, false);
replyToMsg.isTopicMainMessage = true;
}
}
SendMessagesHelper.getInstance(account).sendMessage(user, did, replyToMsg, replyToMsg, null, null, notify2, scheduleDate);
if (!TextUtils.isEmpty(message)) {
SendMessagesHelper.prepareSendingText(accountInstance, message.toString(), did, notify, 0);
}
@ -5044,12 +5069,14 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
TLRPC.TL_forumTopic topic = accountInstance.getMessagesController().getTopicsController().findTopic(-did, topicId);
if (topic != null && topic.topicStartMessage != null) {
replyToMsg = new MessageObject(accountInstance.getCurrentAccount(), topic.topicStartMessage, false, false);
replyToMsg.isTopicMainMessage = true;
}
}
boolean photosEditorOpened = false, videoEditorOpened = false;
if (fragment != null) {
boolean withoutAnimation = dialogsFragment == null || (videoPath != null || (photoPathsArray != null && photoPathsArray.size() > 0));
actionBarLayout.presentFragment(fragment, dialogsFragment != null, withoutAnimation, true, false);
presentedFragmentWithRemoveLast = dialogsFragment != null;
if (videoPath != null) {
fragment.openVideoEditor(videoPath, sendingText);
videoEditorOpened = true;
@ -5083,7 +5110,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
captionToSend = sendingText;
sendingText = null;
}
SendMessagesHelper.prepareSendingDocuments(accountInstance, documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, captionToSend, documentsMimeType, did, null, null, null, null, notify, 0);
SendMessagesHelper.prepareSendingDocuments(accountInstance, documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, captionToSend, documentsMimeType, did, replyToMsg, replyToMsg, null, null, notify, 0);
}
if (sendingText != null) {
SendMessagesHelper.prepareSendingText(accountInstance, sendingText, did, topicId, notify, 0);
@ -5100,9 +5127,11 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
}
if (dialogsFragment != null && fragment == null) {
if (!presentedFragmentWithRemoveLast) {
dialogsFragment.finishFragment();
}
}
}
photoPathsArray = null;
videoPath = null;
@ -6497,6 +6526,11 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
FileLog.d("lock app");
}
showPasscodeActivity(true, false, -1, -1, null, null);
try {
NotificationsController.getInstance(UserConfig.selectedAccount).showNotifications();
} catch (Exception e) {
FileLog.e(e);
}
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("didn't pass lock check");

View file

@ -2435,7 +2435,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
removeSelfFromStack(true);
} else if (id == NotificationCenter.locationPermissionGranted) {
locationDenied = false;
if (adapter != null) {

View file

@ -404,7 +404,7 @@ public class NotificationsCustomSettingsActivity extends BaseFragment implements
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_USERS_ONLY);
}
DialogsActivity activity = new DialogsActivity(args);
activity.setDelegate((fragment, dids, message, param) -> {
activity.setDelegate((fragment, dids, message, param, topicsFragment) -> {
Bundle args2 = new Bundle();
args2.putLong("dialog_id", dids.get(0).dialogId);
args2.putBoolean("exception", true);

View file

@ -612,7 +612,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
loading = false;
}
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
removeSelfFromStack(true);
}
}

View file

@ -1291,7 +1291,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
removeSelfFromStack(true);
}
}

View file

@ -67,7 +67,6 @@ import android.transition.TransitionManager;
import android.transition.TransitionSet;
import android.transition.TransitionValues;
import android.util.FloatProperty;
import android.util.Log;
import android.util.Property;
import android.util.Range;
import android.util.SparseArray;
@ -198,7 +197,6 @@ import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.Crop.CropTransform;
import org.telegram.ui.Components.Crop.CropView;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EmojiPacksAlert;
import org.telegram.ui.Components.FadingTextViewLayout;
import org.telegram.ui.Components.FilterShaders;
import org.telegram.ui.Components.FloatSeekBarAccessibilityDelegate;
@ -4369,7 +4367,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final ArrayList<MessageObject> fmessages = new ArrayList<>();
fmessages.add(currentMessageObject);
final ChatActivity parentChatActivityFinal = parentChatActivity;
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
if (dids.size() > 1 || dids.get(0).dialogId == UserConfig.getInstance(currentAccount).getClientUserId() || message != null) {
for (int a = 0; a < dids.size(); a++) {
long did = dids.get(a).dialogId;
@ -15431,19 +15429,26 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
progress = progress + (1f - progress) * clippingImageProgress;
}
float scale = 1f + (1f - Utilities.clamp(progress, 1, 0)) * ZOOM_SCALE;
if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_HIGH || SharedConfig.getLiteMode().enabled()) {
scale = 1f;
}
View view = parentFragment.getFragmentView();
if (view.getScaleX() != scale || view.getScaleY() != scale) {
view.setPivotX(view.getWidth() / 2f);
view.setPivotY(view.getHeight() / 2f);
view.setScaleX(scale);
view.setScaleY(scale);
}
if (parentAlert != null) {
view = parentAlert.getContainer();
if (view.getScaleX() != scale || view.getScaleY() != scale) {
view.setPivotX(view.getWidth() / 2f);
view.setPivotY(view.getHeight() / 2f);
view.setScaleX(scale);
view.setScaleY(scale);
}
}
if (animationInProgress == 1 || animationInProgress == 2 || animationInProgress == 3 || pipAnimationInProgress) {
containerView.invalidate();

View file

@ -1905,7 +1905,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
args.putBoolean("closeFragment", false);
// args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupAlertText", R.string.AddToTheGroupAlertText, UserObject.getUserName(user), "%1$s"));
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
long did = dids.get(0).dialogId;
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-did);
@ -6041,7 +6041,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
updateTtlIcon();
}
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
removeSelfFromStack(true);
} else if (id == NotificationCenter.botInfoDidLoad) {
TLRPC.BotInfo info = (TLRPC.BotInfo) args[0];
if (info.user_id == userId) {
@ -8023,7 +8023,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
@Override
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param) {
public boolean didSelectDialogs(DialogsActivity fragment, ArrayList<MessagesStorage.TopicKey> dids, CharSequence message, boolean param, TopicsFragment topicsFragment) {
long did = dids.get(0).dialogId;
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true);

View file

@ -1265,7 +1265,7 @@ public class QrActivity extends BaseFragment {
super.onDetachedFromWindow();
if (loadingMatrix != null) {
loadingMatrix.stop();
loadingMatrix.recycle();
loadingMatrix.recycle(false);
loadingMatrix = null;
}
}

View file

@ -179,7 +179,7 @@ public class SaveToGallerySettingsActivity extends BaseFragment {
}
args.putBoolean("allowGlobalSearch", false);
DialogsActivity activity = new DialogsActivity(args);
activity.setDelegate((fragment, dids, message, param) -> {
activity.setDelegate((fragment, dids, message, param, topicsFragment) -> {
Bundle args2 = new Bundle();
args2.putLong("dialog_id", dids.get(0).dialogId);
args2.putInt("type", type);

View file

@ -1808,7 +1808,7 @@ public class SelectAnimatedEmojiDialog extends FrameLayout implements Notificati
}
imageView.setDrawable(drawable);
if (!UserConfig.getInstance(currentAccount).isPremium()) {
if (!UserConfig.getInstance(currentAccount).isPremium() && type != TYPE_AVATAR_CONSTRUCTOR && type != TYPE_TOPIC_ICON) {
if (imageView.premiumLockIconView == null) {
imageView.premiumLockIconView = new PremiumLockIconView(getContext(), PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED);
imageView.addView(imageView.premiumLockIconView, LayoutHelper.createFrame(12, 12, Gravity.RIGHT | Gravity.BOTTOM));
@ -2122,7 +2122,7 @@ public class SelectAnimatedEmojiDialog extends FrameLayout implements Notificati
}
imageView.setDrawable(drawable);
if (!UserConfig.getInstance(currentAccount).isPremium()) {
if (!UserConfig.getInstance(currentAccount).isPremium() && type != TYPE_AVATAR_CONSTRUCTOR && type != TYPE_TOPIC_ICON) {
if (imageView.premiumLockIconView == null) {
imageView.premiumLockIconView = new PremiumLockIconView(getContext(), PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED);
imageView.addView(imageView.premiumLockIconView, LayoutHelper.createFrame(12, 12, Gravity.RIGHT | Gravity.BOTTOM));

View file

@ -827,9 +827,8 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N
onTopicSelectedListener.onTopicSelected(topic);
}
if (dialogsActivity != null) {
dialogsActivity.didSelectResult(-chatId, topic.id, true, false);
dialogsActivity.didSelectResult(-chatId, topic.id, true, false, this);
}
removeFragmentOnTransitionEnd = true;
return;
}
if (selectedTopics.size() > 0) {
@ -1394,6 +1393,11 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N
}
}
@Override
public boolean allowFinishFragmentInsteadOfRemoveFromStack() {
return false;
}
private void updateTopView() {
float translation = 0;
if (fragmentContextView != null) {
@ -2634,7 +2638,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N
} else if (id == NotificationCenter.chatSwithcedToForum) {
} else if (id == NotificationCenter.closeChats) {
removeSelfFromStack();
removeSelfFromStack(true);
}
if (id == NotificationCenter.openedChatChanged) {
if (getParentActivity() == null || !(inPreviewMode && AndroidUtilities.isTablet())) {

View file

@ -234,7 +234,7 @@ public class TwoStepVerificationSetupActivity extends BaseFragment {
}
if (animationDrawables != null) {
for (int a = 0; a < animationDrawables.length; a++) {
animationDrawables[a].recycle();
animationDrawables[a].recycle(false);
}
animationDrawables = null;
}

View file

@ -566,7 +566,7 @@ public class WallpapersListActivity extends BaseFragment implements Notification
args.putBoolean("onlySelect", true);
args.putInt("dialogsType", DialogsActivity.DIALOGS_TYPE_FORWARD);
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
fragment.setDelegate((fragment1, dids, message, param, topicsFragment) -> {
StringBuilder fmessage = new StringBuilder();
for (int b = 0; b < selectedWallPapers.size(); b++) {
Object object = selectedWallPapers.valueAt(b);

View file

@ -6239,6 +6239,7 @@
<string name="TranslateToButtonOther">Translate to %s</string>
<string name="ShowOriginalButton">Show Original</string>
<string name="AddedToDoNotTranslate">**%s** is added to the Do Not Translate list.</string>
<string name="AddedToDoNotTranslateOther">**%s** is added to the Do Not Translate list.</string>
<string name="TranslationBarHiddenForChannel">Translation bar is now hidden for this channel.</string>
<string name="TranslationBarHiddenForGroup">Translation bar is now hidden for this group.</string>
<string name="TranslationBarHiddenForChat">Translation bar is now hidden for this chat.</string>

View file

@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_NAME=9.4.1
APP_VERSION_CODE=3102
APP_VERSION_NAME=9.4.2
APP_VERSION_CODE=3106
APP_PACKAGE=org.telegram.messenger
RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey