diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 920d38c7e..d512cb78d 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -887,13 +887,7 @@ void ConnectionsManager::onConnectionDataReceived(Connection *connection, Native } deserializingDatacenter = datacenter; - bool error = false; - uint32_t constructor = data->readUint32(&error); - TLObject *object = request->deserializeResponse(data, constructor, instanceNum, error); - if (object != nullptr && error) { - delete object; - object = nullptr; - } + TLObject *object = TLdeserialize(request, messageLength, data); if (object != nullptr) { if (datacenter->isHandshaking(connection->isMediaConnection)) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index e63d4c517..4ddf0283b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -59,6 +59,7 @@ import android.telephony.TelephonyManager; import android.text.Layout; import android.text.Selection; import android.text.Spannable; +import android.text.SpannableString; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.SpannedString; @@ -136,6 +137,7 @@ import org.telegram.ui.Components.AlertsCreator; import org.telegram.ui.Components.BackgroundGradientDrawable; import org.telegram.ui.Components.Bulletin; import org.telegram.ui.Components.CubicBezierInterpolator; +import org.telegram.ui.Components.EllipsizeSpanAnimator; import org.telegram.ui.Components.ForegroundColorSpanThemable; import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.HideViewAfterAnimation; @@ -185,6 +187,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicReference; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -3436,24 +3439,25 @@ public class AndroidUtilities { return openForView(f, fileName, document.mime_type, activity, null); } - public static SpannableStringBuilder formatSpannableSimple(String format, CharSequence... cs) { + public static SpannableStringBuilder formatSpannableSimple(CharSequence format, CharSequence... cs) { return formatSpannable(format, i -> "%s", cs); } - public static SpannableStringBuilder formatSpannable(String format, CharSequence... cs) { - if (format.contains("%s")) + public static SpannableStringBuilder formatSpannable(CharSequence format, CharSequence... cs) { + if (format.toString().contains("%s")) return formatSpannableSimple(format, cs); return formatSpannable(format, i -> "%" + (i + 1) + "$s", cs); } - public static SpannableStringBuilder formatSpannable(String format, GenericProvider keysProvider, CharSequence... cs) { - SpannableStringBuilder stringBuilder = new SpannableStringBuilder(format); + public static SpannableStringBuilder formatSpannable(CharSequence format, GenericProvider keysProvider, CharSequence... cs) { + String str = format.toString(); + SpannableStringBuilder stringBuilder = SpannableStringBuilder.valueOf(format); for (int i = 0; i < cs.length; i++) { String key = keysProvider.provide(i); - int j = format.indexOf(key); + int j = str.indexOf(key); if (j != -1) { stringBuilder.replace(j, j + key.length(), cs[i]); - format = format.substring(0, j) + cs[i].toString() + format.substring(j + key.length()); + str = str.substring(0, j) + cs[i].toString() + str.substring(j + key.length()); } } return stringBuilder; @@ -3758,14 +3762,43 @@ public class AndroidUtilities { text = password; detail = LocaleController.getString("UseProxyPassword", R.string.UseProxyPassword); } else if (a == 5) { - text = LocaleController.getString(R.string.Checking); + text = LocaleController.getString(R.string.ProxyBottomSheetChecking); detail = LocaleController.getString(R.string.ProxyStatus); } if (TextUtils.isEmpty(text)) { continue; } - TextDetailSettingsCell cell = new TextDetailSettingsCell(activity); - cell.setTextAndValue(text, detail, true); + AtomicReference ellRef = new AtomicReference<>(); + TextDetailSettingsCell cell = new TextDetailSettingsCell(activity) { + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + if (ellRef.get() != null) { + ellRef.get().onAttachedToWindow(); + } + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + if (ellRef.get() != null) { + ellRef.get().onDetachedFromWindow(); + } + } + }; + if (a == 5) { + SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(text); + EllipsizeSpanAnimator ellipsizeAnimator = new EllipsizeSpanAnimator(cell); + ellipsizeAnimator.addView(cell); + SpannableString ell = new SpannableString("..."); + ellipsizeAnimator.wrap(ell, 0); + spannableStringBuilder.append(ell); + ellRef.set(ellipsizeAnimator); + + cell.setTextAndValue(spannableStringBuilder, detail, true); + } else { + cell.setTextAndValue(text, detail, true); + } cell.getTextView().setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); cell.getValueTextView().setTextColor(Theme.getColor(Theme.key_dialogTextGray3)); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 62188decb..3008e0bdf 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -24,8 +24,8 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; - public static int BUILD_VERSION = 3213; - public static String BUILD_VERSION_STRING = "9.5.3"; + public static int BUILD_VERSION = 3227; + public static String BUILD_VERSION_STRING = "9.5.4"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/CallReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/CallReceiver.java index eed5adaf9..1662b9632 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/CallReceiver.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/CallReceiver.java @@ -23,8 +23,39 @@ public class CallReceiver extends BroadcastReceiver { String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (TelephonyManager.EXTRA_STATE_RINGING.equals(phoneState)) { String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); - NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(phoneNumber)); + String phone = PhoneFormat.stripExceptNumbers(phoneNumber); + SharedConfig.getPreferences().edit() + .putString("last_call_phone_number", phone) + .putLong("last_call_time", System.currentTimeMillis()) + .apply(); + NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveCall, phone); } } } + + public static String getLastReceivedCall() { + String phone = SharedConfig.getPreferences().getString("last_call_phone_number", null); + if (phone == null) { + return null; + } + long lastTime = SharedConfig.getPreferences().getLong("last_call_time", 0); + if (System.currentTimeMillis() - lastTime < 1000 * 60 * 60 * 15) { + return phone; + } + return null; + } + + public static void checkLastReceivedCall() { + String lastCall = getLastReceivedCall(); + if (lastCall != null) { + NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveCall, lastCall); + } + } + + public static void clearLastCall() { + SharedConfig.getPreferences().edit() + .remove("last_call_phone_number") + .remove("last_call_time") + .apply(); + } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java index 65ab143c5..dbb810169 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java @@ -1296,7 +1296,11 @@ public class ChatObject { return Integer.compare(o2.date, o1.date); } }; - Collections.sort(sortedParticipants, comparator); + try { + Collections.sort(sortedParticipants, comparator); + } catch (Exception e) { + + } TLRPC.TL_groupCallParticipant lastParticipant = sortedParticipants.isEmpty() ? null : sortedParticipants.get(sortedParticipants.size() - 1); if (videoIsActive(lastParticipant, false, this) || videoIsActive(lastParticipant, true, this)) { if (call.unmuted_video_count > activeVideos) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java index e95753879..0a577a01a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java @@ -1241,6 +1241,12 @@ public class DatabaseMigrationHelper { database.executeFast("PRAGMA user_version = 114").stepThis().dispose(); version = 114; } + if (version == 114) { + database.executeFast("CREATE TABLE bot_keyboard_topics(uid INTEGER, tid INTEGER, mid INTEGER, info BLOB, PRIMARY KEY(uid, tid))").stepThis().dispose(); + database.executeFast("CREATE INDEX IF NOT EXISTS bot_keyboard_topics_idx_mid_v2 ON bot_keyboard_topics(mid, uid, tid);").stepThis().dispose(); + database.executeFast("PRAGMA user_version = 115").stepThis().dispose(); + version = 115; + } return version; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java b/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java index 844202d6b..29e62b20e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java @@ -521,7 +521,7 @@ public class EmojiData { "โŒš", "๐Ÿ“ฑ", "๐Ÿ“ฒ", "๐Ÿ’ป", "โŒจ", "๐Ÿ–ฅ", "๐Ÿ–จ", "๐Ÿ–ฑ", "๐Ÿ–ฒ", "๐Ÿ•น", "๐Ÿ—œ", "๐Ÿ’ฝ", "๐Ÿ’พ", "๐Ÿ’ฟ", "๐Ÿ“€", "๐Ÿ“ผ", "๐Ÿ“ท", "๐Ÿ“ธ", "๐Ÿ“น", "๐ŸŽฅ", "๐Ÿ“ฝ", "๐ŸŽž", "๐Ÿ“ž", "โ˜Ž", "๐Ÿ“Ÿ", "๐Ÿ“ ", "๐Ÿ“บ", "๐Ÿ“ป", "๐ŸŽ™", "๐ŸŽš", "๐ŸŽ›", "๐Ÿงญ", "โฑ", "โฒ", "โฐ", "๐Ÿ•ฐ", "โŒ›", "โณ", "๐Ÿ“ก", "๐Ÿ”‹", "๐Ÿชซ", "๐Ÿ”Œ", "๐Ÿ’ก", "๐Ÿ”ฆ", "๐Ÿ•ฏ", "๐Ÿช”", "๐Ÿงฏ", "๐Ÿ›ข", "๐Ÿ’ธ", "๐Ÿ’ต", "๐Ÿ’ด", "๐Ÿ’ถ", "๐Ÿ’ท", "๐Ÿช™", "๐Ÿ’ฐ", "๐Ÿ’ณ", "๐Ÿชช", "๐Ÿ’Ž", "โš–", "๐Ÿชœ", "๐Ÿงฐ", "๐Ÿช›", "๐Ÿ”ง", "๐Ÿ”จ", "โš’", "๐Ÿ› ", "โ›", "๐Ÿชš", "๐Ÿ”ฉ", "โš™", "๐Ÿชค", "๐Ÿงฑ", "โ›“", "๐Ÿงฒ", "๐Ÿ”ซ", "๐Ÿ’ฃ", "๐Ÿงจ", "๐Ÿช“", "๐Ÿ”ช", "๐Ÿ—ก", "โš”", "๐Ÿ›ก", "๐Ÿšฌ", "โšฐ", "๐Ÿชฆ", "โšฑ", "๐Ÿบ", "๐Ÿ”ฎ", "๐Ÿ“ฟ", "๐Ÿงฟ", "๐Ÿชฌ", "๐Ÿ’ˆ", "โš—", "๐Ÿ”ญ", "๐Ÿ”ฌ", "๐Ÿ•ณ๏ธ", "๐Ÿฉป", "๐Ÿฉน", "๐Ÿฉบ", "๐Ÿ’Š", "๐Ÿ’‰", "๐Ÿฉธ", "๐Ÿงฌ", "๐Ÿฆ ", "๐Ÿงซ", "๐Ÿงช", "๐ŸŒก", "๐Ÿงน", "๐Ÿช ", "๐Ÿงบ", "๐Ÿงป", "๐Ÿšฝ", "๐Ÿšฐ", "๐Ÿšฟ", "๐Ÿ›", "๐Ÿ›€", "๐Ÿ›€๐Ÿป", "๐Ÿ›€๐Ÿผ", "๐Ÿ›€๐Ÿฝ", "๐Ÿ›€๐Ÿพ", "๐Ÿ›€๐Ÿฟ", "๐Ÿงผ", "๐Ÿชฅ", "๐Ÿช’", "๐Ÿชฎ", "๐Ÿงฝ", "๐Ÿชฃ", "๐Ÿงด", "๐Ÿ›Ž", "๐Ÿ”‘", "๐Ÿ—", "๐Ÿšช", "๐Ÿช‘", "๐Ÿ›‹", "๐Ÿ›", "๐Ÿ›Œ", "๐Ÿงธ", "๐Ÿช†", "๐Ÿ–ผ", "๐Ÿชž", "๐ŸชŸ", "๐Ÿ›", "๐Ÿ›’", "๐ŸŽ", "๐ŸŽˆ", "๐ŸŽ", "๐ŸŽ€", "๐Ÿช„", "๐Ÿช…", "๐ŸŽŠ", "๐ŸŽ‰", "๐ŸŽŽ", "๐Ÿชญ", "๐Ÿฎ", "๐ŸŽ", "๐Ÿชฉ", "๐Ÿงง", "โœ‰", "๐Ÿ“ฉ", "๐Ÿ“จ", "๐Ÿ“ง", "๐Ÿ’Œ", "๐Ÿ“ฅ", "๐Ÿ“ค", "๐Ÿ“ฆ", "๐Ÿท", "๐Ÿชง", "๐Ÿ“ช", "๐Ÿ“ซ", "๐Ÿ“ฌ", "๐Ÿ“ญ", "๐Ÿ“ฎ", "๐Ÿ“ฏ", "๐Ÿ“œ", "๐Ÿ“ƒ", "๐Ÿ“„", "๐Ÿ“‘", "๐Ÿงพ", "๐Ÿ“Š", "๐Ÿ“ˆ", "๐Ÿ“‰", "๐Ÿ—’", "๐Ÿ—“", "๐Ÿ“†", "๐Ÿ“…", "๐Ÿ—‘", "๐Ÿ“‡", "๐Ÿ—ƒ", "๐Ÿ—ณ", "๐Ÿ—„", "๐Ÿ“‹", "๐Ÿ“", "๐Ÿ“‚", "๐Ÿ—‚", "๐Ÿ—ž", "๐Ÿ“ฐ", "๐Ÿ““", "๐Ÿ“”", "๐Ÿ“’", "๐Ÿ“•", "๐Ÿ“—", "๐Ÿ“˜", "๐Ÿ“™", "๐Ÿ“š", "๐Ÿ“–", "๐Ÿ”–", "๐Ÿงท", "๐Ÿ”—", "๐Ÿ“Ž", "๐Ÿ–‡", "๐Ÿ“", "๐Ÿ“", "๐Ÿงฎ", "๐Ÿ“Œ", "๐Ÿ“", "โœ‚", "๐Ÿ–Š", "๐Ÿ–‹", "โœ’", "๐Ÿ–Œ", "๐Ÿ–", "๐Ÿ“", "โœ", "๐Ÿ”", "๐Ÿ”Ž", "๐Ÿ”", "๐Ÿ”", "๐Ÿ”’", "๐Ÿ”“" }, new String[]{ - "๐Ÿฉท", "โค", "๐Ÿงก", "๐Ÿ’›", "๐Ÿ’š", "๐Ÿฉต", "๐Ÿ’™", "๐Ÿ’œ", "๐Ÿ–ค", "๐Ÿฉถ", "๐Ÿค", "๐ŸคŽ", "๐Ÿ’”", "โคโ€๐Ÿ”ฅ", "โคโ€๐Ÿฉน", "โฃ", "๐Ÿ’•", "๐Ÿ’ž", "๐Ÿ’“", "๐Ÿ’—", "๐Ÿ’–", "๐Ÿ’˜", "๐Ÿ’", "๐Ÿ’Ÿ", "โ˜ฎ", "โœ", "โ˜ช", "๐Ÿ•‰", "โ˜ธ", "๐Ÿชฏ", "โœก", "๐Ÿ”ฏ", "๐Ÿ•Ž", "โ˜ฏ", "โ˜ฆ", "๐Ÿ›", "โ›Ž", "โ™ˆ", "โ™‰", "โ™Š", "โ™‹", "โ™Œ", "โ™", "โ™Ž", "โ™", "โ™", "โ™‘", "โ™’", "โ™“", "๐Ÿ†”", "โš›", "๐Ÿ‰‘", "โ˜ข", "โ˜ฃ", "๐Ÿ“ด", "๐Ÿ“ณ", "๐Ÿˆถ", "๐Ÿˆš", "๐Ÿˆธ", "๐Ÿˆบ", "๐Ÿˆท", "โœด", "๐Ÿ†š", "๐Ÿ’ฎ", "๐Ÿ‰", "ใŠ™", "ใŠ—", "๐Ÿˆด", "๐Ÿˆต", "๐Ÿˆน", "๐Ÿˆฒ", "๐Ÿ…ฐ", "๐Ÿ…ฑ", "๐Ÿ†Ž", "๐Ÿ†‘", "๐Ÿ…พ", "๐Ÿ†˜", "โŒ", "โญ•", "๐Ÿ›‘", "โ›”", "๐Ÿ“›", "๐Ÿšซ", "๐Ÿ’ฏ", "๐Ÿ’ข", "โ™จ", "๐Ÿšท", "๐Ÿšฏ", "๐Ÿšณ", "๐Ÿšฑ", "๐Ÿ”ž", "๐Ÿ“ต", "๐Ÿšญ", "โ—", "โ•", "โ“", "โ”", "โ€ผ", "โ‰", "๐Ÿ”…", "๐Ÿ”†", "ใ€ฝ", "โš ", "๐Ÿšธ", "๐Ÿ”ฑ", "โšœ", "๐Ÿ”ฐ", "โ™ป", "โœ…", "๐Ÿˆฏ", "๐Ÿ’น", "โ‡", "โœณ", "โŽ", "๐ŸŒ", "๐Ÿ’ ", "โ“‚", "๐ŸŒ€", "๐Ÿ’ค", "๐Ÿง", "๐Ÿšพ", "โ™ฟ", "๐Ÿ…ฟ", "๐Ÿ›—", "๐Ÿˆณ", "๐Ÿˆ‚", "๐Ÿ›‚", "๐Ÿ›ƒ", "๐Ÿ›„", "๐Ÿ›…", "๐Ÿ›œ", "๐Ÿšน", "๐Ÿšบ", "๐Ÿšผ", "โšง", "๐Ÿšป", "๐Ÿšฎ", "๐ŸŽฆ", "๐Ÿ“ถ", "๐Ÿˆ", "๐Ÿ”ฃ", "โ„น", "๐Ÿ”ค", "๐Ÿ”ก", "๐Ÿ” ", "๐Ÿ†–", "๐Ÿ†—", "๐Ÿ†™", "๐Ÿ†’", "๐Ÿ†•", "๐Ÿ†“", "0โƒฃ", "1โƒฃ", "2โƒฃ", "3โƒฃ", "4โƒฃ", "5โƒฃ", "6โƒฃ", "7โƒฃ", "8โƒฃ", "9โƒฃ", "๐Ÿ”Ÿ", "๐Ÿ”ข", "#โƒฃ", "*โƒฃ", "โ", "โ–ถ", "โธ", "โฏ", "โน", "โบ", "โญ", "โฎ", "โฉ", "โช", "โซ", "โฌ", "โ—€", "๐Ÿ”ผ", "๐Ÿ”ฝ", "โžก", "โฌ…", "โฌ†", "โฌ‡", "โ†—", "โ†˜", "โ†™", "โ†–", "โ†•", "โ†”", "โ†ช", "โ†ฉ", "โคด", "โคต", "๐Ÿ”€", "๐Ÿ”", "๐Ÿ”‚", "๐Ÿ”„", "๐Ÿ”ƒ", "๐ŸŽต", "๐ŸŽถ", "โž•", "โž–", "โž—", "โœ–", "๐ŸŸฐ", "โ™พ", "๐Ÿ’ฒ", "๐Ÿ’ฑ", "โ„ข", "ยฉ", "ยฎ", "๐Ÿ‘โ€๐Ÿ—จ", "๐Ÿ”š", "๐Ÿ”™", "๐Ÿ”›", "๐Ÿ”", "๐Ÿ”œ", "ใ€ฐ", "โžฐ", "โžฟ", "โœ”", "โ˜‘", "๐Ÿ”˜", "๐Ÿ”ด", "๐ŸŸ ", "๐ŸŸก", "๐ŸŸข", "๐Ÿ”ต", "๐ŸŸฃ", "โšซ", "โšช", "๐ŸŸค", "๐Ÿ”บ", "๐Ÿ”ป", "๐Ÿ”ธ", "๐Ÿ”น", "๐Ÿ”ถ", "๐Ÿ”ท", "๐Ÿ”ณ", "๐Ÿ”ฒ", "โ–ช", "โ–ซ", "โ—พ", "โ—ฝ", "โ—ผ", "โ—ป", "๐ŸŸฅ", "๐ŸŸง", "๐ŸŸจ", "๐ŸŸฉ", "๐ŸŸฆ", "๐ŸŸช", "โฌ›", "โฌœ", "๐ŸŸซ", "๐Ÿ”ˆ", "๐Ÿ”‡", "๐Ÿ”‰", "๐Ÿ”Š", "๐Ÿ””", "๐Ÿ”•", "๐Ÿ“ฃ", "๐Ÿ“ข", "๐Ÿ’ฌ", "๐Ÿ’ญ", "๐Ÿ—ฏ", "โ™ ", "โ™ฃ", "โ™ฅ", "โ™ฆ", "๐Ÿƒ", "๐ŸŽด", "๐Ÿ€„", "๐Ÿ•", "๐Ÿ•‘", "๐Ÿ•’", "๐Ÿ•“", "๐Ÿ•”", "๐Ÿ••", "๐Ÿ•–", "๐Ÿ•—", "๐Ÿ•˜", "๐Ÿ•™", "๐Ÿ•š", "๐Ÿ•›", "๐Ÿ•œ", "๐Ÿ•", "๐Ÿ•ž", "๐Ÿ•Ÿ", "๐Ÿ• ", "๐Ÿ•ก", "๐Ÿ•ข", "๐Ÿ•ฃ", "๐Ÿ•ค", "๐Ÿ•ฅ", "๐Ÿ•ฆ", "๐Ÿ•ง" + "๐Ÿฉท", "โค", "๐Ÿงก", "๐Ÿ’›", "๐Ÿ’š", "๐Ÿฉต", "๐Ÿ’™", "๐Ÿ’œ", "๐Ÿ–ค", "๐Ÿฉถ", "๐Ÿค", "๐ŸคŽ", "๐Ÿ’”", "โคโ€๐Ÿ”ฅ", "โคโ€๐Ÿฉน", "โฃ", "๐Ÿ’•", "๐Ÿ’ž", "๐Ÿ’“", "๐Ÿ’—", "๐Ÿ’–", "๐Ÿ’˜", "๐Ÿ’", "๐Ÿ’Ÿ", "โ˜ฎ", "โœ", "โ˜ช", "๐Ÿ•‰", "โ˜ธ", "๐Ÿชฏ", "โœก", "๐Ÿ”ฏ", "๐Ÿ•Ž", "โ˜ฏ", "โ˜ฆ", "๐Ÿ›", "โ›Ž", "โ™ˆ", "โ™‰", "โ™Š", "โ™‹", "โ™Œ", "โ™", "โ™Ž", "โ™", "โ™", "โ™‘", "โ™’", "โ™“", "๐Ÿ†”", "โš›", "๐Ÿ‰‘", "โ˜ข", "โ˜ฃ", "๐Ÿ“ด", "๐Ÿ“ณ", "๐Ÿˆถ", "๐Ÿˆš", "๐Ÿˆธ", "๐Ÿˆบ", "๐Ÿˆท", "โœด", "๐Ÿ†š", "๐Ÿ’ฎ", "๐Ÿ‰", "ใŠ™", "ใŠ—", "๐Ÿˆด", "๐Ÿˆต", "๐Ÿˆน", "๐Ÿˆฒ", "๐Ÿ…ฐ", "๐Ÿ…ฑ", "๐Ÿ†Ž", "๐Ÿ†‘", "๐Ÿ…พ", "๐Ÿ†˜", "โŒ", "โญ•", "๐Ÿ›‘", "โ›”", "๐Ÿ“›", "๐Ÿšซ", "๐Ÿ’ฏ", "๐Ÿ’ข", "โ™จ", "๐Ÿšท", "๐Ÿšฏ", "๐Ÿšณ", "๐Ÿšฑ", "๐Ÿ”ž", "๐Ÿ“ต", "๐Ÿšญ", "โ—", "โ•", "โ“", "โ”", "โ€ผ", "โ‰", "๐Ÿ”…", "๐Ÿ”†", "ใ€ฝ", "โš ", "๐Ÿšธ", "๐Ÿ”ฑ", "โšœ", "๐Ÿ”ฐ", "โ™ป", "โœ…", "๐Ÿˆฏ", "๐Ÿ’น", "โ‡", "โœณ", "โŽ", "๐ŸŒ", "๐Ÿ’ ", "โ“‚", "๐ŸŒ€", "๐Ÿ’ค", "๐Ÿง", "๐Ÿšพ", "โ™ฟ", "๐Ÿ…ฟ", "๐Ÿ›—", "๐Ÿˆณ", "๐Ÿˆ‚", "๐Ÿ›‚", "๐Ÿ›ƒ", "๐Ÿ›„", "๐Ÿ›…", "๐Ÿ›œ", "๐Ÿšน", "๐Ÿšบ", "๐Ÿšผ", "โšง", "๐Ÿšป", "๐Ÿšฎ", "๐ŸŽฆ", "๐Ÿ“ถ", "๐Ÿˆ", "๐Ÿ”ฃ", "โ„น", "๐Ÿ”ค", "๐Ÿ”ก", "๐Ÿ” ", "๐Ÿ†–", "๐Ÿ†—", "๐Ÿ†™", "๐Ÿ†’", "๐Ÿ†•", "๐Ÿ†“", "0โƒฃ", "1โƒฃ", "2โƒฃ", "3โƒฃ", "4โƒฃ", "5โƒฃ", "6โƒฃ", "7โƒฃ", "8โƒฃ", "9โƒฃ", "๐Ÿ”Ÿ", "๐Ÿ”ข", "#โƒฃ", "*โƒฃ", "โ", "โ–ถ", "โธ", "โฏ", "โน", "โบ", "โญ", "โฎ", "โฉ", "โช", "โซ", "โฌ", "โ—€", "๐Ÿ”ผ", "๐Ÿ”ฝ", "โžก", "โฌ…", "โฌ†", "โฌ‡", "โ†—", "โ†˜", "โ†™", "โ†–", "โ†•", "โ†”", "โ†ช", "โ†ฉ", "โคด", "โคต", "๐Ÿ”€", "๐Ÿ”", "๐Ÿ”‚", "๐Ÿ”„", "๐Ÿ”ƒ", "๐ŸŽต", "๐ŸŽถ", "โž•", "โž–", "โž—", "โœ–", "๐ŸŸฐ", "โ™พ", "๐Ÿ’ฒ", "๐Ÿ’ฑ", "โ„ข๏ธ", "ยฉ", "ยฎ", "๐Ÿ‘โ€๐Ÿ—จ", "๐Ÿ”š", "๐Ÿ”™", "๐Ÿ”›", "๐Ÿ”", "๐Ÿ”œ", "ใ€ฐ", "โžฐ", "โžฟ", "โœ”", "โ˜‘", "๐Ÿ”˜", "๐Ÿ”ด", "๐ŸŸ ", "๐ŸŸก", "๐ŸŸข", "๐Ÿ”ต", "๐ŸŸฃ", "โšซ", "โšช", "๐ŸŸค", "๐Ÿ”บ", "๐Ÿ”ป", "๐Ÿ”ธ", "๐Ÿ”น", "๐Ÿ”ถ", "๐Ÿ”ท", "๐Ÿ”ณ", "๐Ÿ”ฒ", "โ–ช", "โ–ซ", "โ—พ", "โ—ฝ", "โ—ผ", "โ—ป", "๐ŸŸฅ", "๐ŸŸง", "๐ŸŸจ", "๐ŸŸฉ", "๐ŸŸฆ", "๐ŸŸช", "โฌ›", "โฌœ", "๐ŸŸซ", "๐Ÿ”ˆ", "๐Ÿ”‡", "๐Ÿ”‰", "๐Ÿ”Š", "๐Ÿ””", "๐Ÿ”•", "๐Ÿ“ฃ", "๐Ÿ“ข", "๐Ÿ’ฌ", "๐Ÿ’ญ", "๐Ÿ—ฏ", "โ™ ", "โ™ฃ", "โ™ฅ", "โ™ฆ", "๐Ÿƒ", "๐ŸŽด", "๐Ÿ€„", "๐Ÿ•", "๐Ÿ•‘", "๐Ÿ•’", "๐Ÿ•“", "๐Ÿ•”", "๐Ÿ••", "๐Ÿ•–", "๐Ÿ•—", "๐Ÿ•˜", "๐Ÿ•™", "๐Ÿ•š", "๐Ÿ•›", "๐Ÿ•œ", "๐Ÿ•", "๐Ÿ•ž", "๐Ÿ•Ÿ", "๐Ÿ• ", "๐Ÿ•ก", "๐Ÿ•ข", "๐Ÿ•ฃ", "๐Ÿ•ค", "๐Ÿ•ฅ", "๐Ÿ•ฆ", "๐Ÿ•ง" }, new String[]{ "๐Ÿณ", "๐Ÿด", "๐Ÿดโ€โ˜ ", "๐Ÿ", "๐Ÿšฉ", "๐Ÿณโ€๐ŸŒˆ", "๐Ÿณโ€โšง", "๐Ÿ‡บ๐Ÿ‡ณ", "๐Ÿ‡ฆ๐Ÿ‡ซ", "๐Ÿ‡ฆ๐Ÿ‡ฝ", "๐Ÿ‡ฆ๐Ÿ‡ฑ", "๐Ÿ‡ฉ๐Ÿ‡ฟ", "๐Ÿ‡ฆ๐Ÿ‡ธ", "๐Ÿ‡ฆ๐Ÿ‡ฉ", "๐Ÿ‡ฆ๐Ÿ‡ด", "๐Ÿ‡ฆ๐Ÿ‡ฎ", "๐Ÿ‡ฆ๐Ÿ‡ถ", "๐Ÿ‡ฆ๐Ÿ‡ฌ", "๐Ÿ‡ฆ๐Ÿ‡ท", "๐Ÿ‡ฆ๐Ÿ‡ฒ", "๐Ÿ‡ฆ๐Ÿ‡ผ", "๐Ÿ‡ฆ๐Ÿ‡บ", "๐Ÿ‡ฆ๐Ÿ‡น", "๐Ÿ‡ฆ๐Ÿ‡ฟ", "๐Ÿ‡ง๐Ÿ‡ธ", "๐Ÿ‡ง๐Ÿ‡ญ", "๐Ÿ‡ง๐Ÿ‡ฉ", "๐Ÿ‡ง๐Ÿ‡ง", "๐Ÿ‡ง๐Ÿ‡พ", "๐Ÿ‡ง๐Ÿ‡ช", "๐Ÿ‡ง๐Ÿ‡ฟ", "๐Ÿ‡ง๐Ÿ‡ฏ", "๐Ÿ‡ง๐Ÿ‡ฒ", "๐Ÿ‡ง๐Ÿ‡น", "๐Ÿ‡ง๐Ÿ‡ด", "๐Ÿ‡ง๐Ÿ‡ฆ", "๐Ÿ‡ง๐Ÿ‡ผ", "๐Ÿ‡ง๐Ÿ‡ท", "๐Ÿ‡ป๐Ÿ‡ฌ", "๐Ÿ‡ง๐Ÿ‡ณ", "๐Ÿ‡ง๐Ÿ‡ฌ", "๐Ÿ‡ง๐Ÿ‡ซ", "๐Ÿ‡ง๐Ÿ‡ฎ", "๐Ÿ‡ฐ๐Ÿ‡ญ", "๐Ÿ‡จ๐Ÿ‡ฒ", "๐Ÿ‡จ๐Ÿ‡ฆ", "๐Ÿ‡ฎ๐Ÿ‡จ", "๐Ÿ‡จ๐Ÿ‡ป", "๐Ÿ‡ง๐Ÿ‡ถ", "๐Ÿ‡ฐ๐Ÿ‡พ", "๐Ÿ‡จ๐Ÿ‡ซ", "๐Ÿ‡น๐Ÿ‡ฉ", "๐Ÿ‡ฎ๐Ÿ‡ด", "๐Ÿ‡จ๐Ÿ‡ฑ", "๐Ÿ‡จ๐Ÿ‡ณ", "๐Ÿ‡จ๐Ÿ‡ฝ", "๐Ÿ‡จ๐Ÿ‡จ", "๐Ÿ‡จ๐Ÿ‡ด", "๐Ÿ‡ฐ๐Ÿ‡ฒ", "๐Ÿ‡จ๐Ÿ‡ฌ", "๐Ÿ‡จ๐Ÿ‡ฉ", "๐Ÿ‡จ๐Ÿ‡ฐ", "๐Ÿ‡จ๐Ÿ‡ท", "๐Ÿ‡จ๐Ÿ‡ฎ", "๐Ÿ‡ญ๐Ÿ‡ท", "๐Ÿ‡จ๐Ÿ‡บ", "๐Ÿ‡จ๐Ÿ‡ผ", "๐Ÿ‡จ๐Ÿ‡พ", "๐Ÿ‡จ๐Ÿ‡ฟ", "๐Ÿ‡ฉ๐Ÿ‡ฐ", "๐Ÿ‡ฉ๐Ÿ‡ฏ", "๐Ÿ‡ฉ๐Ÿ‡ฒ", "๐Ÿ‡ฉ๐Ÿ‡ด", "๐Ÿ‡ช๐Ÿ‡จ", "๐Ÿ‡ช๐Ÿ‡ฌ", "๐Ÿ‡ธ๐Ÿ‡ป", "๐Ÿ‡ฌ๐Ÿ‡ถ", "๐Ÿ‡ช๐Ÿ‡ท", "๐Ÿ‡ช๐Ÿ‡ช", "๐Ÿ‡ธ๐Ÿ‡ฟ", "๐Ÿ‡ช๐Ÿ‡น", "๐Ÿ‡ช๐Ÿ‡บ", "๐Ÿ‡ซ๐Ÿ‡ฐ", "๐Ÿ‡ซ๐Ÿ‡ด", "๐Ÿ‡ซ๐Ÿ‡ฏ", "๐Ÿ‡ซ๐Ÿ‡ฎ", "๐Ÿ‡ซ๐Ÿ‡ท", "๐Ÿ‡ฌ๐Ÿ‡ซ", "๐Ÿ‡ต๐Ÿ‡ซ", "๐Ÿ‡น๐Ÿ‡ซ", "๐Ÿ‡ฌ๐Ÿ‡ฆ", "๐Ÿ‡ฌ๐Ÿ‡ฒ", "๐Ÿ‡ฌ๐Ÿ‡ช", "๐Ÿ‡ฉ๐Ÿ‡ช", "๐Ÿ‡ฌ๐Ÿ‡ญ", "๐Ÿ‡ฌ๐Ÿ‡ฎ", "๐Ÿ‡ฌ๐Ÿ‡ท", "๐Ÿ‡ฌ๐Ÿ‡ฑ", "๐Ÿ‡ฌ๐Ÿ‡ฉ", "๐Ÿ‡ฌ๐Ÿ‡ต", "๐Ÿ‡ฌ๐Ÿ‡บ", "๐Ÿ‡ฌ๐Ÿ‡น", "๐Ÿ‡ฌ๐Ÿ‡ฌ", "๐Ÿ‡ฌ๐Ÿ‡ณ", "๐Ÿ‡ฌ๐Ÿ‡ผ", "๐Ÿ‡ฌ๐Ÿ‡พ", "๐Ÿ‡ญ๐Ÿ‡น", "๐Ÿ‡ญ๐Ÿ‡ณ", "๐Ÿ‡ญ๐Ÿ‡ฐ", "๐Ÿ‡ญ๐Ÿ‡บ", "๐Ÿ‡ฎ๐Ÿ‡ธ", "๐Ÿ‡ฎ๐Ÿ‡ณ", "๐Ÿ‡ฎ๐Ÿ‡ฉ", "๐Ÿ‡ฎ๐Ÿ‡ท", "๐Ÿ‡ฎ๐Ÿ‡ถ", "๐Ÿ‡ฎ๐Ÿ‡ช", "๐Ÿ‡ฎ๐Ÿ‡ฒ", "๐Ÿ‡ฎ๐Ÿ‡ฑ", "๐Ÿ‡ฎ๐Ÿ‡น", "๐Ÿ‡ฏ๐Ÿ‡ฒ", "๐Ÿ‡ฏ๐Ÿ‡ต", "๐ŸŽŒ", "๐Ÿ‡ฏ๐Ÿ‡ช", "๐Ÿ‡ฏ๐Ÿ‡ด", "๐Ÿ‡ฐ๐Ÿ‡ฟ", "๐Ÿ‡ฐ๐Ÿ‡ช", "๐Ÿ‡ฐ๐Ÿ‡ฎ", "๐Ÿ‡ฝ๐Ÿ‡ฐ", "๐Ÿ‡ฐ๐Ÿ‡ผ", "๐Ÿ‡ฐ๐Ÿ‡ฌ", "๐Ÿ‡ฑ๐Ÿ‡ฆ", "๐Ÿ‡ฑ๐Ÿ‡ป", "๐Ÿ‡ฑ๐Ÿ‡ง", "๐Ÿ‡ฑ๐Ÿ‡ธ", "๐Ÿ‡ฑ๐Ÿ‡ท", "๐Ÿ‡ฑ๐Ÿ‡พ", "๐Ÿ‡ฑ๐Ÿ‡ฎ", "๐Ÿ‡ฑ๐Ÿ‡น", "๐Ÿ‡ฑ๐Ÿ‡บ", "๐Ÿ‡ฒ๐Ÿ‡ด", "๐Ÿ‡ฒ๐Ÿ‡ฌ", "๐Ÿ‡ฒ๐Ÿ‡ผ", "๐Ÿ‡ฒ๐Ÿ‡พ", "๐Ÿ‡ฒ๐Ÿ‡ป", "๐Ÿ‡ฒ๐Ÿ‡ฑ", "๐Ÿ‡ฒ๐Ÿ‡น", "๐Ÿ‡ฒ๐Ÿ‡ญ", "๐Ÿ‡ฒ๐Ÿ‡ถ", "๐Ÿ‡ฒ๐Ÿ‡ท", "๐Ÿ‡ฒ๐Ÿ‡บ", "๐Ÿ‡พ๐Ÿ‡น", "๐Ÿ‡ฒ๐Ÿ‡ฝ", "๐Ÿ‡ซ๐Ÿ‡ฒ", "๐Ÿ‡ฒ๐Ÿ‡ฉ", "๐Ÿ‡ฒ๐Ÿ‡จ", "๐Ÿ‡ฒ๐Ÿ‡ณ", "๐Ÿ‡ฒ๐Ÿ‡ช", "๐Ÿ‡ฒ๐Ÿ‡ธ", "๐Ÿ‡ฒ๐Ÿ‡ฆ", "๐Ÿ‡ฒ๐Ÿ‡ฟ", "๐Ÿ‡ฒ๐Ÿ‡ฒ", "๐Ÿ‡ณ๐Ÿ‡ฆ", "๐Ÿ‡ณ๐Ÿ‡ท", "๐Ÿ‡ณ๐Ÿ‡ต", "๐Ÿ‡ณ๐Ÿ‡ฑ", "๐Ÿ‡ณ๐Ÿ‡จ", "๐Ÿ‡ณ๐Ÿ‡ฟ", "๐Ÿ‡ณ๐Ÿ‡ฎ", "๐Ÿ‡ณ๐Ÿ‡ช", "๐Ÿ‡ณ๐Ÿ‡ฌ", "๐Ÿ‡ณ๐Ÿ‡บ", "๐Ÿ‡ณ๐Ÿ‡ซ", "๐Ÿ‡ฐ๐Ÿ‡ต", "๐Ÿ‡ฒ๐Ÿ‡ฐ", "๐Ÿ‡ฒ๐Ÿ‡ต", "๐Ÿ‡ณ๐Ÿ‡ด", "๐Ÿ‡ด๐Ÿ‡ฒ", "๐Ÿ‡ต๐Ÿ‡ฐ", "๐Ÿ‡ต๐Ÿ‡ผ", "๐Ÿ‡ต๐Ÿ‡ธ", "๐Ÿ‡ต๐Ÿ‡ฆ", "๐Ÿ‡ต๐Ÿ‡ฌ", "๐Ÿ‡ต๐Ÿ‡พ", "๐Ÿ‡ต๐Ÿ‡ช", "๐Ÿ‡ต๐Ÿ‡ญ", "๐Ÿ‡ต๐Ÿ‡ณ", "๐Ÿ‡ต๐Ÿ‡ฑ", "๐Ÿ‡ต๐Ÿ‡น", "๐Ÿ‡ต๐Ÿ‡ท", "๐Ÿ‡ถ๐Ÿ‡ฆ", "๐Ÿ‡ท๐Ÿ‡ช", "๐Ÿ‡ท๐Ÿ‡ด", "๐Ÿ‡ท๐Ÿ‡บ", "๐Ÿ‡ท๐Ÿ‡ผ", "๐Ÿ‡ผ๐Ÿ‡ธ", "๐Ÿ‡ธ๐Ÿ‡ฒ", "๐Ÿ‡ธ๐Ÿ‡น", "๐Ÿ‡ธ๐Ÿ‡ฆ", "๐Ÿ‡ธ๐Ÿ‡ณ", "๐Ÿ‡ท๐Ÿ‡ธ", "๐Ÿ‡ธ๐Ÿ‡จ", "๐Ÿ‡ธ๐Ÿ‡ฑ", "๐Ÿ‡ธ๐Ÿ‡ฌ", "๐Ÿ‡ธ๐Ÿ‡ฝ", "๐Ÿ‡ธ๐Ÿ‡ฐ", "๐Ÿ‡ธ๐Ÿ‡ฎ", "๐Ÿ‡ฌ๐Ÿ‡ธ", "๐Ÿ‡ธ๐Ÿ‡ง", "๐Ÿ‡ธ๐Ÿ‡ด", "๐Ÿ‡ฟ๐Ÿ‡ฆ", "๐Ÿ‡ฐ๐Ÿ‡ท", "๐Ÿ‡ธ๐Ÿ‡ธ", "๐Ÿ‡ช๐Ÿ‡ธ", "๐Ÿ‡ฑ๐Ÿ‡ฐ", "๐Ÿ‡ง๐Ÿ‡ฑ", "๐Ÿ‡ธ๐Ÿ‡ญ", "๐Ÿ‡ฐ๐Ÿ‡ณ", "๐Ÿ‡ฑ๐Ÿ‡จ", "๐Ÿ‡ต๐Ÿ‡ฒ", "๐Ÿ‡ป๐Ÿ‡จ", "๐Ÿ‡ธ๐Ÿ‡ฉ", "๐Ÿ‡ธ๐Ÿ‡ท", "๐Ÿ‡ธ๐Ÿ‡ช", "๐Ÿ‡จ๐Ÿ‡ญ", "๐Ÿ‡ธ๐Ÿ‡พ", "๐Ÿ‡น๐Ÿ‡ผ", "๐Ÿ‡น๐Ÿ‡ฏ", "๐Ÿ‡น๐Ÿ‡ฟ", "๐Ÿ‡น๐Ÿ‡ญ", "๐Ÿ‡น๐Ÿ‡ฑ", "๐Ÿ‡น๐Ÿ‡ฌ", "๐Ÿ‡น๐Ÿ‡ฐ", "๐Ÿ‡น๐Ÿ‡ด", "๐Ÿ‡น๐Ÿ‡น", "๐Ÿ‡น๐Ÿ‡ณ", "๐Ÿ‡น๐Ÿ‡ท", "๐Ÿ‡น๐Ÿ‡ฒ", "๐Ÿ‡น๐Ÿ‡จ", "๐Ÿ‡น๐Ÿ‡ป", "๐Ÿ‡บ๐Ÿ‡ฌ", "๐Ÿ‡บ๐Ÿ‡ฆ", "๐Ÿ‡ฆ๐Ÿ‡ช", "๐Ÿ‡ฌ๐Ÿ‡ง", "๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ", "๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ", "๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ", "๐Ÿ‡บ๐Ÿ‡ธ", "๐Ÿ‡บ๐Ÿ‡พ", "๐Ÿ‡ป๐Ÿ‡ฎ", "๐Ÿ‡บ๐Ÿ‡ฟ", "๐Ÿ‡ป๐Ÿ‡บ", "๐Ÿ‡ป๐Ÿ‡ฆ", "๐Ÿ‡ป๐Ÿ‡ช", "๐Ÿ‡ป๐Ÿ‡ณ", "๐Ÿ‡ผ๐Ÿ‡ซ", "๐Ÿ‡ช๐Ÿ‡ญ", "๐Ÿ‡พ๐Ÿ‡ช", "๐Ÿ‡ฟ๐Ÿ‡ฒ", "๐Ÿ‡ฟ๐Ÿ‡ผ" diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index 6c3ffa272..d3a1a737b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -31,6 +31,9 @@ import java.util.zip.ZipException; public class FileLoadOperation { + private final static int FINISH_CODE_DEFAULT = 0; + private final static int FINISH_CODE_FILE_ALREADY_EXIST = 1; + FileLoadOperationStream stream; boolean streamPriority; long streamOffset; @@ -1075,7 +1078,7 @@ public class FileLoadOperation { Utilities.stageQueue.postRunnable(() -> { if (totalBytesCount != 0 && (isPreloadVideoOperation && preloaded[0] || downloadedBytes == totalBytesCount)) { try { - onFinishLoadingFile(false); + onFinishLoadingFile(false, FINISH_CODE_FILE_ALREADY_EXIST); } catch (Exception e) { onFail(true, 0); } @@ -1086,7 +1089,7 @@ public class FileLoadOperation { } else { started = true; try { - onFinishLoadingFile(false); + onFinishLoadingFile(false, FINISH_CODE_FILE_ALREADY_EXIST); if (pathSaveData != null) { delegate.saveFilePath(pathSaveData, null); } @@ -1299,7 +1302,7 @@ public class FileLoadOperation { } } - private void onFinishLoadingFile(final boolean increment) { + private void onFinishLoadingFile(final boolean increment, int finishCode) { if (state != stateDownloading) { return; } @@ -1309,7 +1312,11 @@ public class FileLoadOperation { if (isPreloadVideoOperation) { preloadFinished = true; if (BuildVars.DEBUG_VERSION) { - FileLog.d("finished preloading file to " + cacheFileTemp + " loaded " + totalPreloadedBytes + " of " + totalBytesCount); + if (finishCode == FINISH_CODE_FILE_ALREADY_EXIST) { + FileLog.d("file already exist " + cacheFileTemp); + } else { + FileLog.d("finished preloading file to " + cacheFileTemp + " loaded " + totalPreloadedBytes + " of " + totalBytesCount); + } } if (fileMetadata != null) { if (cacheFileTemp != null) { @@ -1397,7 +1404,7 @@ public class FileLoadOperation { state = stateDownloading; Utilities.stageQueue.postRunnable(() -> { try { - onFinishLoadingFile(increment); + onFinishLoadingFile(increment, FINISH_CODE_DEFAULT); } catch (Exception e) { onFail(false, 0); } @@ -1575,7 +1582,7 @@ public class FileLoadOperation { bytes = null; } if (bytes == null || bytes.limit() == 0) { - onFinishLoadingFile(true); + onFinishLoadingFile(true, FINISH_CODE_DEFAULT); return false; } int currentBytesSize = bytes.limit(); @@ -1767,7 +1774,7 @@ public class FileLoadOperation { } if (finishedDownloading) { - onFinishLoadingFile(true); + onFinishLoadingFile(true, FINISH_CODE_DEFAULT); } else if (state != stateCanceled) { startDownloadRequest(); } @@ -1807,7 +1814,7 @@ public class FileLoadOperation { } else if (error.text.contains("OFFSET_INVALID")) { if (downloadedBytes % currentDownloadChunkSize == 0) { try { - onFinishLoadingFile(true); + onFinishLoadingFile(true, FINISH_CODE_DEFAULT); } catch (Exception e) { FileLog.e(e); onFail(false, 0); @@ -1946,7 +1953,7 @@ public class FileLoadOperation { tries--; } if (!found && requestInfos.isEmpty()) { - onFinishLoadingFile(false); + onFinishLoadingFile(false, FINISH_CODE_DEFAULT); } } else { downloadOffset = nextPreloadDownloadOffset; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index 871334473..fae182e79 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -222,12 +222,14 @@ public class FileLoader extends BaseController { if (dir == null && type != FileLoader.MEDIA_DIR_CACHE) { dir = mediaDirs.get(FileLoader.MEDIA_DIR_CACHE); } - try { - if (dir != null && !dir.isDirectory()) { - dir.mkdirs(); + if (BuildVars.NO_SCOPED_STORAGE) { + try { + if (dir != null && !dir.isDirectory()) { + dir.mkdirs(); + } + } catch (Exception e) { + //don't promt } - } catch (Exception e) { - //don't promt } return dir; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java index 819d9e327..fefb5bdee 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java @@ -3962,50 +3962,60 @@ public class ImageLoader { TLRPC.PhotoSize photoSize = findPhotoCachedSize(message); if (photoSize != null && photoSize.bytes != null && photoSize.bytes.length != 0) { + TLRPC.PhotoSize newPhotoSize; if (photoSize.location == null || photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) { photoSize.location = new TLRPC.TL_fileLocationToBeDeprecated(); photoSize.location.volume_id = Integer.MIN_VALUE; photoSize.location.local_id = SharedConfig.getLastLocalId(); } - File file = FileLoader.getInstance(UserConfig.selectedAccount).getPathToAttach(photoSize, true); - boolean isEncrypted = false; - if (MessageObject.shouldEncryptPhotoOrVideo(message)) { - file = new File(file.getAbsolutePath() + ".enc"); - isEncrypted = true; - } - if (!file.exists()) { - try { - if (isEncrypted) { - File keyPath = new File(FileLoader.getInternalCacheDir(), file.getName() + ".key"); - RandomAccessFile keyFile = new RandomAccessFile(keyPath, "rws"); - long len = keyFile.length(); - byte[] encryptKey = new byte[32]; - byte[] encryptIv = new byte[16]; - if (len > 0 && len % 48 == 0) { - keyFile.read(encryptKey, 0, 32); - keyFile.read(encryptIv, 0, 16); - } else { - Utilities.random.nextBytes(encryptKey); - Utilities.random.nextBytes(encryptIv); - keyFile.write(encryptKey); - keyFile.write(encryptIv); - } - keyFile.close(); - Utilities.aesCtrDecryptionByteArray(photoSize.bytes, encryptKey, encryptIv, 0, photoSize.bytes.length, 0); - } - RandomAccessFile writeFile = new RandomAccessFile(file, "rws"); - writeFile.write(photoSize.bytes); - writeFile.close(); - } catch (Exception e) { - FileLog.e(e); + if (photoSize.h <= 50 && photoSize.w <= 50) { + newPhotoSize = new TLRPC.TL_photoStrippedSize(); + newPhotoSize.location = photoSize.location; + newPhotoSize.bytes = photoSize.bytes; + newPhotoSize.h = photoSize.h; + newPhotoSize.w = photoSize.w; + } else { + File file = FileLoader.getInstance(UserConfig.selectedAccount).getPathToAttach(photoSize, true); + boolean isEncrypted = false; + if (MessageObject.shouldEncryptPhotoOrVideo(message)) { + file = new File(file.getAbsolutePath() + ".enc"); + isEncrypted = true; } + if (!file.exists()) { + try { + if (isEncrypted) { + File keyPath = new File(FileLoader.getInternalCacheDir(), file.getName() + ".key"); + RandomAccessFile keyFile = new RandomAccessFile(keyPath, "rws"); + long len = keyFile.length(); + byte[] encryptKey = new byte[32]; + byte[] encryptIv = new byte[16]; + if (len > 0 && len % 48 == 0) { + keyFile.read(encryptKey, 0, 32); + keyFile.read(encryptIv, 0, 16); + } else { + Utilities.random.nextBytes(encryptKey); + Utilities.random.nextBytes(encryptIv); + keyFile.write(encryptKey); + keyFile.write(encryptIv); + } + keyFile.close(); + Utilities.aesCtrDecryptionByteArray(photoSize.bytes, encryptKey, encryptIv, 0, photoSize.bytes.length, 0); + } + RandomAccessFile writeFile = new RandomAccessFile(file, "rws"); + writeFile.write(photoSize.bytes); + writeFile.close(); + } catch (Exception e) { + FileLog.e(e); + } + } + + newPhotoSize = new TLRPC.TL_photoSize_layer127(); + newPhotoSize.w = photoSize.w; + newPhotoSize.h = photoSize.h; + newPhotoSize.location = photoSize.location; + newPhotoSize.size = photoSize.size; + newPhotoSize.type = photoSize.type; } - TLRPC.TL_photoSize newPhotoSize = new TLRPC.TL_photoSize_layer127(); - newPhotoSize.w = photoSize.w; - newPhotoSize.h = photoSize.h; - newPhotoSize.location = photoSize.location; - newPhotoSize.size = photoSize.size; - newPhotoSize.type = photoSize.type; if (message.media instanceof TLRPC.TL_messageMediaPhoto) { for (int a = 0, count = message.media.photo.sizes.size(); a < count; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java b/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java index 73c6c4dbe..061251685 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java @@ -123,12 +123,14 @@ public class LiteMode { } private static int preprocessFlag(int flag) { - if (flag == FLAG_ANIMATED_EMOJI_KEYBOARD) { - return UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_KEYBOARD_PREMIUM : FLAG_ANIMATED_EMOJI_KEYBOARD_NOT_PREMIUM; - } else if (flag == FLAG_ANIMATED_EMOJI_REACTIONS) { - return UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM : FLAG_ANIMATED_EMOJI_REACTIONS_NOT_PREMIUM; - } else if (flag == FLAG_ANIMATED_EMOJI_CHAT) { - return UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_CHAT_PREMIUM : FLAG_ANIMATED_EMOJI_CHAT_NOT_PREMIUM; + if ((flag & FLAG_ANIMATED_EMOJI_KEYBOARD) > 0) { + flag = flag & ~FLAG_ANIMATED_EMOJI_KEYBOARD | (UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_KEYBOARD_PREMIUM : FLAG_ANIMATED_EMOJI_KEYBOARD_NOT_PREMIUM); + } + if ((flag & FLAG_ANIMATED_EMOJI_REACTIONS) > 0) { + flag = flag & ~FLAG_ANIMATED_EMOJI_REACTIONS | (UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_REACTIONS_PREMIUM : FLAG_ANIMATED_EMOJI_REACTIONS_NOT_PREMIUM); + } + if ((flag & FLAG_ANIMATED_EMOJI_CHAT) > 0) { + flag = flag & ~FLAG_ANIMATED_EMOJI_CHAT | (UserConfig.hasPremiumOnAccounts() ? FLAG_ANIMATED_EMOJI_CHAT_PREMIUM : FLAG_ANIMATED_EMOJI_CHAT_NOT_PREMIUM); } return flag; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 411628664..3aed83199 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -83,6 +83,7 @@ import org.telegram.ui.Components.EmbedBottomSheet; import org.telegram.ui.Components.PhotoFilterView; import org.telegram.ui.Components.PipRoundVideoView; import org.telegram.ui.Components.VideoPlayer; +import org.telegram.ui.LaunchActivity; import org.telegram.ui.PhotoViewer; import java.io.File; @@ -1629,7 +1630,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, lastAccelerometerDetected = System.currentTimeMillis(); } if (proximityTouched && (raisedToBack == minCount || accelerometerVertical || System.currentTimeMillis() - lastAccelerometerDetected < 60) && !NotificationsController.audioManager.isWiredHeadsetOn() && !NotificationsController.audioManager.isBluetoothA2dpOn() && !VoIPService.isAnyKindOfCallActive()) { - if (SharedConfig.raiseToSpeak && playingMessageObject == null && recordStartRunnable == null && recordingAudio == null && !PhotoViewer.getInstance().isVisible() && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress) { + if (SharedConfig.enabledRaiseTo(true) && playingMessageObject == null && recordStartRunnable == null && recordingAudio == null && !PhotoViewer.getInstance().isVisible() && ApplicationLoader.isScreenOn && !inputFieldHasText && allowStartRecord && raiseChat != null && !callInProgress) { if (!raiseToEarRecord) { if (BuildVars.LOGS_ENABLED) { FileLog.d("start record"); @@ -1648,7 +1649,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, proximityWakeLock.acquire(); } } - } else if (playingMessageObject != null && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { + } else if (SharedConfig.enabledRaiseTo(false) && playingMessageObject != null && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { if (!useFrontSpeaker) { if (BuildVars.LOGS_ENABLED) { FileLog.d("start listen"); @@ -1666,7 +1667,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, raisedToTopSign = 0; countLess = 0; } else if (proximityTouched && ((accelerometerSensor == null || linearSensor == null) && gravitySensor == null || ignoreAccelerometerGestures()) && !VoIPService.isAnyKindOfCallActive()) { - if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { + if (playingMessageObject != null && !ApplicationLoader.mainInterfacePaused && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()) && SharedConfig.enabledRaiseTo(false)) { if (!useFrontSpeaker && !NotificationsController.audioManager.isWiredHeadsetOn() && !NotificationsController.audioManager.isBluetoothA2dpOn()) { if (BuildVars.LOGS_ENABLED) { FileLog.d("start listen by proximity only"); @@ -1723,7 +1724,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } public void startRecordingIfFromSpeaker() { - if (!useFrontSpeaker || raiseChat == null || !allowStartRecord || !SharedConfig.raiseToSpeak) { + if (!useFrontSpeaker || raiseChat == null || !allowStartRecord || !SharedConfig.enabledRaiseTo(true)) { return; } raiseToEarRecord = true; @@ -1787,7 +1788,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, return; } raiseChat = chatActivity; - if (!SharedConfig.raiseToSpeak && (playingMessageObject == null || !playingMessageObject.isVoice() && !playingMessageObject.isRoundVideo())) { + if (!SharedConfig.enabledRaiseTo(true) && (playingMessageObject == null || !playingMessageObject.isVoice() && !playingMessageObject.isRoundVideo())) { return; } if (!sensorsStarted) { @@ -1925,7 +1926,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, stopProgressTimer(); lastProgress = 0; isPaused = false; - if (!useFrontSpeaker && !SharedConfig.raiseToSpeak) { + if (!useFrontSpeaker && !SharedConfig.enabledRaiseTo(true)) { ChatActivity chat = raiseChat; stopRaiseToEarSensors(raiseChat, false); raiseChat = chat; @@ -2229,12 +2230,12 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, long group2 = o2.messageOwner.grouped_id; if (mid1 < 0 && mid2 < 0) { if (group1 != 0 && group1 == group2) { - return Integer.compare(mid1, mid2); + return -Integer.compare(mid1, mid2); } return Integer.compare(mid2, mid1); } else { if (group1 != 0 && group1 == group2) { - return Integer.compare(mid2, mid1); + return -Integer.compare(mid2, mid1); } return Integer.compare(mid1, mid2); } @@ -2462,7 +2463,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (neededAudioFocus == 3) { result = NotificationsController.audioManager.requestAudioFocus(this, AudioManager.STREAM_VOICE_CALL, AudioManager.AUDIOFOCUS_GAIN); } else { - result = NotificationsController.audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, neededAudioFocus == 2 ? AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK : AudioManager.AUDIOFOCUS_GAIN); + result = NotificationsController.audioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, neededAudioFocus == 2 && !SharedConfig.pauseMusicOnMedia ? AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK : AudioManager.AUDIOFOCUS_GAIN); } if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) { audioFocus = AUDIO_FOCUSED; @@ -2770,7 +2771,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, lastProgress = 0; MessageObject oldMessageObject = playingMessageObject; playingMessageObject = messageObject; - if (!SharedConfig.raiseToSpeak) { + if (!SharedConfig.enabledRaiseTo(true)) { startRaiseToEarSensors(raiseChat); } startProgressTimer(playingMessageObject); @@ -2935,7 +2936,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, if (isPaused) { resumeAudio(messageObject); } - if (!SharedConfig.raiseToSpeak) { + if (!SharedConfig.enabledRaiseTo(true)) { startRaiseToEarSensors(raiseChat); } return true; @@ -3321,10 +3322,10 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, isPaused = false; lastProgress = 0; playingMessageObject = messageObject; - if (!SharedConfig.raiseToSpeak) { + if (!SharedConfig.enabledRaiseTo(true)) { startRaiseToEarSensors(raiseChat); } - if (!ApplicationLoader.mainInterfacePaused && proximityWakeLock != null && !proximityWakeLock.isHeld() && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo())) { + if (!ApplicationLoader.mainInterfacePaused && proximityWakeLock != null && !proximityWakeLock.isHeld() && (playingMessageObject.isVoice() || playingMessageObject.isRoundVideo()) && SharedConfig.enabledRaiseTo(false)) { if (ignoreAccelerometerGestures()) { proximityWakeLock.acquire(); } @@ -3442,7 +3443,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, stopProgressTimer(); try { if (audioPlayer != null) { - if (!playingMessageObject.isVoice() && (playingMessageObject.getDuration() * (1f - playingMessageObject.audioProgress) > 1)) { + if (!playingMessageObject.isVoice() && (playingMessageObject.getDuration() * (1f - playingMessageObject.audioProgress) > 1) && LaunchActivity.isResumed) { if (audioVolumeAnimator != null) { audioVolumeAnimator.removeAllUpdateListeners(); audioVolumeAnimator.cancel(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index 2a573dc8e..9fd030974 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -34,6 +34,7 @@ import android.text.TextUtils; import android.text.style.CharacterStyle; import android.text.style.URLSpan; import android.text.util.Linkify; +import android.util.Log; import android.util.Pair; import android.util.SparseArray; @@ -722,6 +723,9 @@ public class MediaDataController extends BaseController { if (reactionsList == null || reactionsCacheGenerated || !LiteMode.isEnabled(LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS)) { return; } + if (currentAccount != UserConfig.selectedAccount) { + return; + } reactionsCacheGenerated = true; ArrayList arrayList = new ArrayList<>(reactionsList); int N = Math.min(arrayList.size(), 10); @@ -2355,7 +2359,9 @@ public class MediaDataController extends BaseController { processLoadedDiceStickers(getUserConfig().genericAnimationsStickerPack, false, stickerSet, false, (int) (System.currentTimeMillis() / 1000)); for (int i = 0; i < stickerSet.documents.size(); i++) { - preloadImage(ImageLocation.getForDocument(stickerSet.documents.get(i))); + if (currentAccount == UserConfig.selectedAccount) { + preloadImage(ImageLocation.getForDocument(stickerSet.documents.get(i))); + } } } })); @@ -4294,48 +4300,20 @@ public class MediaDataController extends BaseController { ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit().putString("directShareHash2", SharedConfig.directShareHash).commit(); } - List currentShortcuts = ShortcutManagerCompat.getDynamicShortcuts(ApplicationLoader.applicationContext); - ArrayList shortcutsToUpdate = new ArrayList<>(); - ArrayList newShortcutsIds = new ArrayList<>(); - ArrayList shortcutsToDelete = new ArrayList<>(); + ShortcutManagerCompat.removeAllDynamicShortcuts(ApplicationLoader.applicationContext); - if (currentShortcuts != null && !currentShortcuts.isEmpty()) { - newShortcutsIds.add("compose"); - for (int a = 0; a < hintsFinal.size(); a++) { - TLRPC.TL_topPeer hint = hintsFinal.get(a); - newShortcutsIds.add("did3_" + MessageObject.getPeerId(hint.peer)); - } - for (int a = 0; a < currentShortcuts.size(); a++) { - String id = currentShortcuts.get(a).getId(); - if (!newShortcutsIds.remove(id)) { - shortcutsToDelete.add(id); - } - shortcutsToUpdate.add(id); - } - if (newShortcutsIds.isEmpty() && shortcutsToDelete.isEmpty()) { - return; - } - } Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent.setAction("new_dialog"); ArrayList arrayList = new ArrayList<>(); - arrayList.add(new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, "compose") + ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, "compose") .setShortLabel(LocaleController.getString("NewConversationShortcut", R.string.NewConversationShortcut)) .setLongLabel(LocaleController.getString("NewConversationShortcut", R.string.NewConversationShortcut)) .setIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.shortcut_compose)) + .setRank(0) .setIntent(intent) .build()); - if (shortcutsToUpdate.contains("compose")) { - ShortcutManagerCompat.updateShortcuts(ApplicationLoader.applicationContext, arrayList); - } else { - ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList); - } - arrayList.clear(); - if (!shortcutsToDelete.isEmpty()) { - ShortcutManagerCompat.removeDynamicShortcuts(ApplicationLoader.applicationContext, shortcutsToDelete); - } HashSet category = new HashSet<>(1); category.add(SHORTCUT_CATEGORY); @@ -4419,6 +4397,7 @@ public class MediaDataController extends BaseController { ShortcutInfoCompat.Builder builder = new ShortcutInfoCompat.Builder(ApplicationLoader.applicationContext, id) .setShortLabel(name) .setLongLabel(name) + .setRank(1 + a) .setIntent(shortcutIntent); if (SharedConfig.directShare) { builder.setCategories(category); @@ -4428,13 +4407,7 @@ public class MediaDataController extends BaseController { } else { builder.setIcon(IconCompat.createWithResource(ApplicationLoader.applicationContext, R.drawable.shortcut_user)); } - arrayList.add(builder.build()); - if (shortcutsToUpdate.contains(id)) { - ShortcutManagerCompat.updateShortcuts(ApplicationLoader.applicationContext, arrayList); - } else { - ShortcutManagerCompat.addDynamicShortcuts(ApplicationLoader.applicationContext, arrayList); - } - arrayList.clear(); + ShortcutManagerCompat.pushDynamicShortcut(ApplicationLoader.applicationContext, builder.build()); } } catch (Throwable ignore) { @@ -6627,37 +6600,74 @@ public class MediaDataController extends BaseController { //---------------- DRAFT END ---------------- private HashMap botInfos = new HashMap<>(); - private LongSparseArray botKeyboards = new LongSparseArray<>(); - private SparseLongArray botKeyboardsByMids = new SparseLongArray(); + private LongSparseArray> botDialogKeyboards = new LongSparseArray<>(); + private HashMap botKeyboards = new HashMap<>(); + private LongSparseArray botKeyboardsByMids = new LongSparseArray(); - public void clearBotKeyboard(long dialogId, ArrayList messages) { + public void clearBotKeyboard(MessagesStorage.TopicKey topicKey, ArrayList messages) { AndroidUtilities.runOnUIThread(() -> { if (messages != null) { for (int a = 0; a < messages.size(); a++) { - long did1 = botKeyboardsByMids.get(messages.get(a)); - if (did1 != 0) { - botKeyboards.remove(did1); - botKeyboardsByMids.delete(messages.get(a)); - getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, null, did1); + final int id = messages.get(a); + MessagesStorage.TopicKey foundTopicKey = botKeyboardsByMids.get(id); + if (foundTopicKey != null) { + botKeyboards.remove(foundTopicKey); + ArrayList dialogMessages = botDialogKeyboards.get(foundTopicKey.dialogId); + if (dialogMessages != null) { + for (int i = 0; i < dialogMessages.size(); ++i) { + TLRPC.Message msg = dialogMessages.get(i); + if (msg == null || msg.id == id) { + dialogMessages.remove(i); + i--; + } + } + if (dialogMessages.isEmpty()) { + botDialogKeyboards.remove(foundTopicKey.dialogId); + } + } + botKeyboardsByMids.remove(id); + getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, null, foundTopicKey); } } - } else { - botKeyboards.remove(dialogId); - getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, null, dialogId); + } else if (topicKey != null) { + botKeyboards.remove(topicKey); + botDialogKeyboards.remove(topicKey.dialogId); + getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, null, topicKey); } }); } - public void loadBotKeyboard(long dialogId) { - TLRPC.Message keyboard = botKeyboards.get(dialogId); + public void clearBotKeyboard(long dialogId) { + AndroidUtilities.runOnUIThread(() -> { + ArrayList dialogMessages = botDialogKeyboards.get(dialogId); + if (dialogMessages != null) { + for (int i = 0; i < dialogMessages.size(); ++i) { + TLRPC.Message msg = dialogMessages.get(i); + int topicId = MessageObject.getTopicId(msg, ChatObject.isForum(currentAccount, dialogId)); + MessagesStorage.TopicKey topicKey = MessagesStorage.TopicKey.of(dialogId, topicId); + botKeyboards.remove(topicKey); + getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, null, topicKey); + } + } + botDialogKeyboards.remove(dialogId); + }); + } + + public void loadBotKeyboard(MessagesStorage.TopicKey topicKey) { + TLRPC.Message keyboard = botKeyboards.get(topicKey); if (keyboard != null) { - getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, keyboard, dialogId); + getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, keyboard, topicKey); return; } getMessagesStorage().getStorageQueue().postRunnable(() -> { try { TLRPC.Message botKeyboard = null; - SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT info FROM bot_keyboard WHERE uid = %d", dialogId)); + SQLiteCursor cursor; + if (topicKey.topicId != 0) { + cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT info FROM bot_keyboard_topics WHERE uid = %d AND tid = %d", topicKey.dialogId, topicKey.topicId)); + } else { + cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT info FROM bot_keyboard WHERE uid = %d", topicKey.dialogId)); + } if (cursor.next()) { NativeByteBuffer data; @@ -6673,7 +6683,7 @@ public class MediaDataController extends BaseController { if (botKeyboard != null) { TLRPC.Message botKeyboardFinal = botKeyboard; - AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, botKeyboardFinal, dialogId)); + AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, botKeyboardFinal, topicKey)); } } catch (Exception e) { FileLog.e(e); @@ -6719,13 +6729,18 @@ public class MediaDataController extends BaseController { }); } - public void putBotKeyboard(long dialogId, TLRPC.Message message) { - if (message == null) { + public void putBotKeyboard(MessagesStorage.TopicKey topicKey, TLRPC.Message message) { + if (topicKey == null) { return; } try { int mid = 0; - SQLiteCursor cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT mid FROM bot_keyboard WHERE uid = %d", dialogId)); + SQLiteCursor cursor; + if (topicKey.topicId != 0) { + cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT mid FROM bot_keyboard_topics WHERE uid = %d AND tid = %d", topicKey.dialogId, topicKey.topicId)); + } else { + cursor = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT mid FROM bot_keyboard WHERE uid = %d", topicKey.dialogId)); + } if (cursor.next()) { mid = cursor.intValue(0); } @@ -6734,28 +6749,46 @@ public class MediaDataController extends BaseController { return; } - SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO bot_keyboard VALUES(?, ?, ?)"); + SQLitePreparedStatement state; + if (topicKey.topicId != 0) { + state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO bot_keyboard_topics VALUES(?, ?, ?, ?)"); + } else { + state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO bot_keyboard VALUES(?, ?, ?)"); + } state.requery(); NativeByteBuffer data = new NativeByteBuffer(message.getObjectSize()); message.serializeToStream(data); - state.bindLong(1, dialogId); - state.bindInteger(2, message.id); - state.bindByteBuffer(3, data); + if (topicKey.topicId != 0) { + state.bindLong(1, topicKey.dialogId); + state.bindInteger(2, topicKey.topicId); + state.bindInteger(3, message.id); + state.bindByteBuffer(4, data); + } else { + state.bindLong(1, topicKey.dialogId); + state.bindInteger(2, message.id); + state.bindByteBuffer(3, data); + } state.step(); data.reuse(); state.dispose(); AndroidUtilities.runOnUIThread(() -> { - TLRPC.Message old = botKeyboards.get(dialogId); - botKeyboards.put(dialogId, message); + TLRPC.Message old = botKeyboards.get(topicKey); + botKeyboards.put(topicKey, message); + ArrayList messages = botDialogKeyboards.get(topicKey.dialogId); + if (messages == null) { + messages = new ArrayList<>(); + } + messages.add(message); + botDialogKeyboards.put(topicKey.dialogId, messages); long channelId = MessageObject.getChannelId(message); if (channelId == 0) { if (old != null) { botKeyboardsByMids.delete(old.id); } - botKeyboardsByMids.put(message.id, dialogId); + botKeyboardsByMids.put(message.id, topicKey); } - getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, message, dialogId); + getNotificationCenter().postNotificationName(NotificationCenter.botKeyboardDidLoad, message, topicKey); }); } catch (Exception e) { FileLog.e(e); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 73f277bc3..4e33a6a14 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -56,7 +56,6 @@ import org.telegram.ui.Components.URLSpanNoUnderlineBold; import org.telegram.ui.Components.URLSpanReplacement; import org.telegram.ui.Components.URLSpanUserMention; import org.telegram.ui.Components.spoilers.SpoilerEffect; -import org.w3c.dom.Text; import java.io.BufferedReader; import java.io.File; @@ -345,6 +344,10 @@ public class MessageObject { message.messageOwner.action instanceof TLRPC.TL_messageActionTopicEdit; } + public static boolean canCreateStripedThubms() { + return SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_HIGH; + } + public int getEmojiOnlyCount() { return emojiOnlyCount; } @@ -1277,7 +1280,7 @@ public class MessageObject { } public void createStrippedThumb() { - if (photoThumbs == null || SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_HIGH && !hasExtendedMediaPreview()) { + if (photoThumbs == null || !canCreateStripedThubms() && !hasExtendedMediaPreview()) { return; } try { @@ -3083,24 +3086,6 @@ public class MessageObject { } wantedBotKeyboardWidth = Math.max(wantedBotKeyboardWidth, (maxButtonSize + AndroidUtilities.dp(12)) * size + AndroidUtilities.dp(5) * (size - 1)); } - } else if (messageOwner.reactions != null) { - int size = messageOwner.reactions.results.size(); - for (int a = 0; a < size; a++) { - TLRPC.ReactionCount reactionCount = messageOwner.reactions.results.get(a); - int maxButtonSize = 0; - botButtonsLayout.append(0).append(a); - CharSequence text = Emoji.replaceEmoji(String.format("%d %s", reactionCount.count, reactionCount.reaction), Theme.chat_msgBotButtonPaint.getFontMetricsInt(), AndroidUtilities.dp(15), false); - StaticLayout staticLayout = new StaticLayout(text, Theme.chat_msgBotButtonPaint, AndroidUtilities.dp(2000), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); - if (staticLayout.getLineCount() > 0) { - float width = staticLayout.getLineWidth(0); - float left = staticLayout.getLineLeft(0); - if (left < width) { - width -= left; - } - maxButtonSize = Math.max(maxButtonSize, (int) Math.ceil(width) + AndroidUtilities.dp(4)); - } - wantedBotKeyboardWidth = Math.max(wantedBotKeyboardWidth, (maxButtonSize + AndroidUtilities.dp(12)) * size + AndroidUtilities.dp(5) * (size - 1)); - } } } @@ -4085,7 +4070,7 @@ public class MessageObject { } for (int a = 0, N = document.thumbs.size(); a < N; a++) { TLRPC.PhotoSize photoSize = document.thumbs.get(a); - if (photoSize != null && !(photoSize instanceof TLRPC.TL_photoSizeEmpty) && !(photoSize.location instanceof TLRPC.TL_fileLocationUnavailable)) { + if (photoSize != null && !(photoSize instanceof TLRPC.TL_photoSizeEmpty) && (!(photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) || photoSize.bytes != null)) { return true; } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index d0f5a559b..aa18b0fd0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -1158,8 +1158,8 @@ public class MessagesController extends BaseController implements NotificationCe mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig" + currentAccount, Activity.MODE_PRIVATE); emojiPreferences = ApplicationLoader.applicationContext.getSharedPreferences("emoji" + currentAccount, Activity.MODE_PRIVATE); } + long time = System.currentTimeMillis(); - enableJoined = notificationsPreferences.getBoolean("EnableContactJoined", true); remoteConfigLoaded = mainPreferences.getBoolean("remoteConfigLoaded", false); secretWebpagePreview = mainPreferences.getInt("secretWebpage2", 2); maxGroupCount = mainPreferences.getInt("maxGroupCount", 200); @@ -1196,14 +1196,13 @@ public class MessagesController extends BaseController implements NotificationCe promoPsaMessage = mainPreferences.getString("promo_psa_message", null); promoPsaType = mainPreferences.getString("promo_psa_type", null); proxyDialogAddress = mainPreferences.getString("proxyDialogAddress", null); - nextTosCheckTime = notificationsPreferences.getInt("nextTosCheckTime", 0); venueSearchBot = mainPreferences.getString("venueSearchBot", "foursquare"); gifSearchBot = mainPreferences.getString("gifSearchBot", "gif"); imageSearchBot = mainPreferences.getString("imageSearchBot", "pic"); blockedCountry = mainPreferences.getBoolean("blockedCountry", false); suggestedLangCode = mainPreferences.getString("suggestedLangCode", "en"); animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f); - qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", false); + qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", true); saveGifsWithStickers = mainPreferences.getBoolean("saveGifsWithStickers", false); filtersEnabled = mainPreferences.getBoolean("filtersEnabled", false); getfileExperimentalParams = mainPreferences.getBoolean("getfileExperimentalParams", false); @@ -1261,9 +1260,16 @@ public class MessagesController extends BaseController implements NotificationCe giftTextFieldIcon = mainPreferences.getBoolean("giftTextFieldIcon", false); checkResetLangpack = mainPreferences.getInt("checkResetLangpack", 0); BuildVars.GOOGLE_AUTH_CLIENT_ID = mainPreferences.getString("googleAuthClientId", BuildVars.GOOGLE_AUTH_CLIENT_ID); - - dcDomainName = mainPreferences.getString("dcDomainName2", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com"); - webFileDatacenterId = mainPreferences.getInt("webFileDatacenterId", ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? 2 : 4); + if (mainPreferences.contains("dcDomainName2")) { + dcDomainName = mainPreferences.getString("dcDomainName2", "apv3.stel.com"); + } else { + dcDomainName = ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com"; + } + if (mainPreferences.contains("webFileDatacenterId")) { + webFileDatacenterId = mainPreferences.getInt("webFileDatacenterId", 4); + } else { + webFileDatacenterId = ConnectionsManager.native_isTestBackend(currentAccount) != 0 ? 2 : 4; + } Set currencySet = mainPreferences.getStringSet("directPaymentsCurrency", null); if (currencySet != null) { @@ -1392,7 +1398,6 @@ public class MessagesController extends BaseController implements NotificationCe FileLog.e(e); } } - if (BuildVars.DEBUG_VERSION) { AndroidUtilities.runOnUIThread(this::loadAppConfig, 2000); } @@ -1400,10 +1405,15 @@ public class MessagesController extends BaseController implements NotificationCe topicsController = new TopicsController(num); cacheByChatsController = new CacheByChatsController(num); translateController = new TranslateController(this); + + Utilities.globalQueue.postRunnable(() -> { + enableJoined = notificationsPreferences.getBoolean("EnableContactJoined", true); + nextTosCheckTime = notificationsPreferences.getInt("nextTosCheckTime", 0); + }); } - private void sendLoadPeersRequest(TLObject req, ArrayList requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashMap> filterUserRemovals, HashSet filtersUnreadCounterReset) { + private void sendLoadPeersRequest(TLObject req, ArrayList requests, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashSet filtersUnreadCounterReset) { getConnectionsManager().sendRequest(req, (response, error) -> { if (response instanceof TLRPC.TL_messages_chats) { TLRPC.TL_messages_chats res = (TLRPC.TL_messages_chats) response; @@ -1425,12 +1435,12 @@ public class MessagesController extends BaseController implements NotificationCe } requests.remove(req); if (requests.isEmpty()) { - getMessagesStorage().processLoadedFilterPeers(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + getMessagesStorage().processLoadedFilterPeers(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } }); } - protected void loadFilterPeers(HashMap dialogsToLoadMap, HashMap usersToLoadMap, HashMap chatsToLoadMap, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashMap> filterUserRemovals, HashSet filtersUnreadCounterReset) { + protected void loadFilterPeers(HashMap dialogsToLoadMap, HashMap usersToLoadMap, HashMap chatsToLoadMap, TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashSet filtersUnreadCounterReset) { Utilities.stageQueue.postRunnable(() -> { ArrayList requests = new ArrayList<>(); TLRPC.TL_users_getUsers req = null; @@ -1441,12 +1451,12 @@ public class MessagesController extends BaseController implements NotificationCe } req.id.add(getInputUser(entry.getValue())); if (req.id.size() == 100) { - sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); req = null; } } if (req != null) { - sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } TLRPC.TL_messages_getChats req2 = null; TLRPC.TL_channels_getChannels req3 = null; @@ -1459,7 +1469,7 @@ public class MessagesController extends BaseController implements NotificationCe } req2.id.add(entry.getKey()); if (req2.id.size() == 100) { - sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); req2 = null; } } else if (inputPeer.channel_id != 0) { @@ -1469,16 +1479,16 @@ public class MessagesController extends BaseController implements NotificationCe } req3.id.add(getInputChannel(inputPeer)); if (req3.id.size() == 100) { - sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); req3 = null; } } } if (req2 != null) { - sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req2, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } if (req3 != null) { - sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } TLRPC.TL_messages_getPeerDialogs req4 = null; @@ -1491,12 +1501,12 @@ public class MessagesController extends BaseController implements NotificationCe inputDialogPeer.peer = entry.getValue(); req4.peers.add(inputDialogPeer); if (req4.peers.size() == 100) { - sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); req4 = null; } } if (req4 != null) { - sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + sendLoadPeersRequest(req4, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } }); } @@ -7930,13 +7940,29 @@ public class MessagesController extends BaseController implements NotificationCe } boolean isInitialLoading = offset_date == 0 && max_id == 0; boolean reload; + LongSparseArray usersDict = new LongSparseArray<>(); + LongSparseArray chatsDict = new LongSparseArray<>(); + for (int a = 0; a < messagesRes.users.size(); a++) { + TLRPC.User u = messagesRes.users.get(a); + usersDict.put(u.id, u); + } + for (int a = 0; a < messagesRes.chats.size(); a++) { + TLRPC.Chat c = messagesRes.chats.get(a); + chatsDict.put(c.id, c); + } if (mode == 1) { reload = ((SystemClock.elapsedRealtime() - lastScheduledServerQueryTime.get(dialogId, 0L)) > 60 * 1000); } else { reload = resCount == 0 && (!isInitialLoading || (SystemClock.elapsedRealtime() - lastServerQueryTime.get(dialogId, 0L)) > 60 * 1000 || (isCache && isTopic)); - if (mode == 0 && isCache && dialogId < 0 && !dialogs_dict.containsKey(dialogId) && (SystemClock.elapsedRealtime() - lastServerQueryTime.get(dialogId, 0L)) > 24 * 60 * 60 * 1000) { - messagesRes.messages.clear(); - reload = true; + if (isCache && dialogId < 0) { + TLRPC.Chat chat = getChat(-dialogId); + if (chat == null) { + chat = chatsDict.get(-dialogId); + } + if (chat != null && mode == 0 && ChatObject.isNotInChat(chat) && (SystemClock.elapsedRealtime() - lastServerQueryTime.get(dialogId, 0L)) > 24 * 60 * 60 * 1000) { + messagesRes.messages.clear(); + reload = true; + } } } if (!DialogObject.isEncryptedDialog(dialogId) && isCache && reload) { @@ -7965,19 +7991,6 @@ public class MessagesController extends BaseController implements NotificationCe return; } } - LongSparseArray usersDict = new LongSparseArray<>(); - LongSparseArray chatsDict = new LongSparseArray<>(); - for (int a = 0; a < messagesRes.users.size(); a++) { - TLRPC.User u = messagesRes.users.get(a); - if (BuildVars.DEBUG_VERSION) { - FileLog.d("processLoadedMessages(): +usersDict put " + u.id + " " + u); - } - usersDict.put(u.id, u); - } - for (int a = 0; a < messagesRes.chats.size(); a++) { - TLRPC.Chat c = messagesRes.chats.get(a); - chatsDict.put(c.id, c); - } int size = messagesRes.messages.size(); if (!isCache) { Integer inboxValue = dialogs_read_inbox_max.get(dialogId); @@ -8028,15 +8041,11 @@ public class MessagesController extends BaseController implements NotificationCe ArrayList objects = new ArrayList<>(); ArrayList messagesToReload = new ArrayList<>(); HashMap> webpagesToReload = new HashMap<>(); - TLRPC.InputChannel inputChannel = null; - long fileProcessTime = 0; for (int a = 0; a < size; a++) { TLRPC.Message message = messagesRes.messages.get(a); message.dialog_id = dialogId; long checkFileTime = SystemClock.elapsedRealtime(); MessageObject messageObject = new MessageObject(currentAccount, message, usersDict, chatsDict, true, false); - messageObject.createStrippedThumb(); - fileProcessTime += (SystemClock.elapsedRealtime() - checkFileTime); messageObject.scheduled = mode == 1; objects.add(messageObject); if (isCache) { @@ -8061,10 +8070,14 @@ public class MessagesController extends BaseController implements NotificationCe } } } - getFileLoader().checkMediaExistance(objects); + if (MessageObject.canCreateStripedThubms()) { + for (int i = 0; i < objects.size(); i++) { + objects.get(i).createStrippedThumb(); + } + } if (BuildVars.LOGS_ENABLED) { - FileLog.d("process time = " + (SystemClock.elapsedRealtime() - startProcessTime) + " file time = " + fileProcessTime + " for dialog = " + dialogId); + FileLog.d("process time=" + (SystemClock.elapsedRealtime() - startProcessTime) + " count=" + objects.size() + " for dialog " + dialogId); } AndroidUtilities.runOnUIThread(() -> { putUsers(messagesRes.users, isCache); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index ff66289b4..d961c5809 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -15,6 +15,7 @@ import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; +import android.util.Log; import android.util.Pair; import android.util.SparseArray; import android.util.SparseIntArray; @@ -94,7 +95,7 @@ public class MessagesStorage extends BaseController { } } - public final static int LAST_DB_VERSION = 114; + public final static int LAST_DB_VERSION = 115; private boolean databaseMigrationInProgress; public boolean showClearDatabaseAlert; private LongSparseIntArray dialogIsForum = new LongSparseIntArray(); @@ -411,14 +412,9 @@ public class MessagesStorage extends BaseController { } } if (!restored) { - cleanupInternal(true); - for (int a = 0; a < 2; a++) { - getUserConfig().setDialogsLoadOffset(a, 0, 0, 0, 0, 0, 0); - getUserConfig().setTotalDialogsCount(a, 0); - } - getUserConfig().saveConfig(false); openDatabase(1); } + reset(); return restored; } @@ -440,6 +436,7 @@ public class MessagesStorage extends BaseController { "params", "media_v4", "bot_keyboard", + "bot_keyboard_topics", "chat_settings_v2", "user_settings", "chat_pinned_v2", @@ -554,6 +551,9 @@ public class MessagesStorage extends BaseController { database.executeFast("CREATE TABLE bot_keyboard(uid INTEGER PRIMARY KEY, mid INTEGER, info BLOB)").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS bot_keyboard_idx_mid_v2 ON bot_keyboard(mid, uid);").stepThis().dispose(); + database.executeFast("CREATE TABLE bot_keyboard_topics(uid INTEGER, tid INTEGER, mid INTEGER, info BLOB, PRIMARY KEY(uid, tid))").stepThis().dispose(); + database.executeFast("CREATE INDEX IF NOT EXISTS bot_keyboard_topics_idx_mid_v2 ON bot_keyboard_topics(mid, uid, tid);").stepThis().dispose(); + database.executeFast("CREATE TABLE chat_settings_v2(uid INTEGER PRIMARY KEY, info BLOB, pinned INTEGER, online INTEGER, inviter INTEGER, links INTEGER)").stepThis().dispose(); database.executeFast("CREATE INDEX IF NOT EXISTS chat_settings_pinned_idx ON chat_settings_v2(uid, pinned) WHERE pinned != 0;").stepThis().dispose(); @@ -1299,10 +1299,11 @@ public class MessagesStorage extends BaseController { database.executeFast("DELETE FROM messages_v2 WHERE uid = " + did + " AND mid != " + last_mid_i + " AND mid != " + last_mid).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose(); + database.executeFast("DELETE FROM bot_keyboard_topics WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_counts_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_v4 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_holes_v2 WHERE uid = " + did).stepThis().dispose(); - MediaDataController.getInstance(currentAccount).clearBotKeyboard(did, null); + MediaDataController.getInstance(currentAccount).clearBotKeyboard(did); if (messageId != -1) { MessagesStorage.createFirstHoles(did, state5, state6, messageId, 0); } @@ -2767,6 +2768,28 @@ public class MessagesStorage extends BaseController { } } + private ArrayList toPeerIds(ArrayList inputPeers) { + ArrayList array = new ArrayList(); + if (inputPeers == null) { + return array; + } + final int count = inputPeers.size(); + for (int i = 0; i < count; ++i) { + TLRPC.InputPeer peer = inputPeers.get(i); + if (peer == null) { + continue; + } + long id; + if (peer.user_id != 0) { + id = peer.user_id; + } else { + id = -(peer.chat_id != 0 ? peer.chat_id : peer.channel_id); + } + array.add(id); + } + return array; + } + public void checkLoadedRemoteFilters(TLRPC.Vector vector) { storageQueue.postRunnable(() -> { try { @@ -2776,14 +2799,15 @@ public class MessagesStorage extends BaseController { filtersToDelete.put(filter.id, filter); } ArrayList filtersOrder = new ArrayList<>(); + ArrayList usersToLoad = new ArrayList<>(); HashMap usersToLoadMap = new HashMap<>(); ArrayList chatsToLoad = new ArrayList<>(); HashMap chatsToLoadMap = new HashMap<>(); ArrayList dialogsToLoad = new ArrayList<>(); HashMap dialogsToLoadMap = new HashMap<>(); + ArrayList filtersToSave = new ArrayList<>(); - HashMap> filterUserRemovals = new HashMap<>(); HashMap> filterDialogRemovals = new HashMap<>(); HashSet filtersUnreadCounterReset = new HashSet<>(); for (int a = 0, N = vector.objects.size(); a < N; a++) { @@ -2867,7 +2891,6 @@ public class MessagesStorage extends BaseController { } } } - for (int c = 0, N2 = filter.pinnedDialogs.size(); c < N2; c++) { long did = filter.pinnedDialogs.keyAt(c); if (DialogObject.isEncryptedDialog(did)) { @@ -2876,83 +2899,73 @@ public class MessagesStorage extends BaseController { existingDialogsIds.add(did); existingIds.remove(did); } - for (int c = 0; c < 2; c++) { - ArrayList fromArray = c == 0 ? newFilter.include_peers : newFilter.exclude_peers; - ArrayList toArray = c == 0 ? filter.alwaysShow : filter.neverShow; - if (c == 0) { - filter.pinnedDialogs.clear(); - for (int b = 0, N2 = newFilter.pinned_peers.size(); b < N2; b++) { - TLRPC.InputPeer peer = newFilter.pinned_peers.get(b); - Long id; - if (peer.user_id != 0) { - id = peer.user_id; - } else { - id = -(peer.chat_id != 0 ? peer.chat_id : peer.channel_id); - } - if (!filter.alwaysShow.contains(id)) { - filter.alwaysShow.add(id); - } - int index = filter.pinnedDialogs.size(); - if (secretChatsMap != null) { - Long did; - while ((did = secretChatsMap.remove(index)) != null) { - filter.pinnedDialogs.put(did, index); - index++; - } - } - filter.pinnedDialogs.put(id, index); - existingIds.remove(id); - if (!existingDialogsIds.remove(id)) { - changed = true; - if (!dialogsToLoadMap.containsKey(id)) { - dialogsToLoad.add(id); - dialogsToLoadMap.put(id, peer); - } - } - } - if (secretChatsMap != null) { - for (LinkedHashMap.Entry entry : secretChatsMap.entrySet()) { - filter.pinnedDialogs.put(entry.getValue(), filter.pinnedDialogs.size()); - } + filter.pinnedDialogs.clear(); + for (int b = 0, N2 = newFilter.pinned_peers.size(); b < N2; b++) { + TLRPC.InputPeer peer = newFilter.pinned_peers.get(b); + Long id; + if (peer.user_id != 0) { + id = peer.user_id; + } else { + id = -(peer.chat_id != 0 ? peer.chat_id : peer.channel_id); + } + int index = filter.pinnedDialogs.size(); + if (secretChatsMap != null) { + Long did; + while ((did = secretChatsMap.remove(index)) != null) { + filter.pinnedDialogs.put(did, index); + index++; } } - for (int b = 0, N2 = fromArray.size(); b < N2; b++) { - TLRPC.InputPeer peer = fromArray.get(b); - if (peer.user_id != 0) { - Long uid = peer.user_id; - if (!existingIds.remove(uid)) { - changed = true; - if (!toArray.contains(uid)) { - toArray.add(uid); - } - if (!usersToLoadMap.containsKey(uid)) { - usersToLoad.add(uid); - usersToLoadMap.put(uid, peer); - unreadChanged = true; - } - } - } else { - Long chatId = peer.chat_id != 0 ? peer.chat_id : peer.channel_id; - Long dialogId = -chatId; - if (!existingIds.remove(dialogId)) { - changed = true; - if (!toArray.contains(dialogId)) { - toArray.add(dialogId); - } - if (!chatsToLoadMap.containsKey(chatId)) { - chatsToLoad.add(chatId); - chatsToLoadMap.put(chatId, peer); - unreadChanged = true; - } - } + filter.pinnedDialogs.put(id, index); + existingIds.remove(id); + if (!existingDialogsIds.remove(id)) { + changed = true; + if (!dialogsToLoadMap.containsKey(id)) { + dialogsToLoad.add(id); + dialogsToLoadMap.put(id, peer); } } } - if (!existingIds.isEmpty()) { - filterUserRemovals.put(filter.id, existingIds); - unreadChanged = true; - changed = true; + if (secretChatsMap != null) { + for (LinkedHashMap.Entry entry : secretChatsMap.entrySet()) { + filter.pinnedDialogs.put(entry.getValue(), filter.pinnedDialogs.size()); + } + } + + for (int c = 0; c < 2; c++) { + ArrayList fromArray = toPeerIds(c == 0 ? newFilter.include_peers : newFilter.exclude_peers); + ArrayList toArray = c == 0 ? filter.alwaysShow : filter.neverShow; + + if (c == 0) { + // put pinned_peers into include_peers (alwaysShow) + ArrayList pinnedArray = toPeerIds(newFilter.pinned_peers); + for (int i = 0; i < pinnedArray.size(); ++i) { + fromArray.remove(pinnedArray.get(i)); + } + fromArray.addAll(0, pinnedArray); + } + + final int fromArrayCount = fromArray.size(); + boolean isDifferent = fromArray.size() != toArray.size(); + if (!isDifferent) { + for (int i = 0; i < fromArrayCount; ++i) { + if (!toArray.contains(fromArray.get(i))) { + isDifferent = true; + break; + } + } + } + + if (isDifferent) { + unreadChanged = true; + changed = true; + if (c == 0) { + filter.alwaysShow = fromArray; + } else { + filter.neverShow = fromArray; + } + } } if (!existingDialogsIds.isEmpty()) { filterDialogRemovals.put(filter.id, existingDialogsIds); @@ -3048,9 +3061,9 @@ public class MessagesStorage extends BaseController { } if (usersToLoadMap.isEmpty() && chatsToLoadMap.isEmpty() && dialogsToLoadMap.isEmpty()) { - processLoadedFilterPeersInternal(dialogs, null, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + processLoadedFilterPeersInternal(dialogs, null, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } else { - getMessagesController().loadFilterPeers(dialogsToLoadMap, usersToLoadMap, chatsToLoadMap, dialogs, new TLRPC.TL_messages_dialogs(), users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); + getMessagesController().loadFilterPeers(dialogsToLoadMap, usersToLoadMap, chatsToLoadMap, dialogs, new TLRPC.TL_messages_dialogs(), users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset); } } catch (Exception e) { checkSQLException(e); @@ -3058,7 +3071,7 @@ public class MessagesStorage extends BaseController { }); } - private void processLoadedFilterPeersInternal(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashMap> filterUserRemovals, HashSet filtersUnreadCounterReset) { + private void processLoadedFilterPeersInternal(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashSet filtersUnreadCounterReset) { boolean anythingChanged = false; putUsersAndChats(users, chats, true, false); for (int a = 0, N = filtersToDelete.size(); a < N; a++) { @@ -3072,16 +3085,6 @@ public class MessagesStorage extends BaseController { } filter.pendingUnreadCount = -1; } - for (HashMap.Entry> entry : filterUserRemovals.entrySet()) { - MessagesController.DialogFilter filter = dialogFiltersMap.get(entry.getKey()); - if (filter == null) { - continue; - } - HashSet set = entry.getValue(); - filter.alwaysShow.removeAll(set); - filter.neverShow.removeAll(set); - anythingChanged = true; - } for (HashMap.Entry> entry : filterDialogRemovals.entrySet()) { MessagesController.DialogFilter filter = dialogFiltersMap.get(entry.getKey()); if (filter == null) { @@ -3123,8 +3126,8 @@ public class MessagesStorage extends BaseController { getMessagesController().processLoadedDialogFilters(new ArrayList<>(dialogFilters), pinnedDialogs, pinnedRemoteDialogs, users, chats, null, remote); } - protected void processLoadedFilterPeers(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashMap> filterUserRemovals, HashSet filtersUnreadCounterReset) { - storageQueue.postRunnable(() -> processLoadedFilterPeersInternal(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset)); + protected void processLoadedFilterPeers(TLRPC.messages_Dialogs pinnedDialogs, TLRPC.messages_Dialogs pinnedRemoteDialogs, ArrayList users, ArrayList chats, ArrayList filtersToSave, SparseArray filtersToDelete, ArrayList filtersOrder, HashMap> filterDialogRemovals, HashSet filtersUnreadCounterReset) { + storageQueue.postRunnable(() -> processLoadedFilterPeersInternal(pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filtersUnreadCounterReset)); } private void deleteDialogFilterInternal(MessagesController.DialogFilter filter) { @@ -3804,10 +3807,11 @@ public class MessagesStorage extends BaseController { database.executeFast("DELETE FROM messages_v2 WHERE uid = " + did + " AND mid != " + last_mid_i + " AND mid != " + last_mid).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose(); + database.executeFast("DELETE FROM bot_keyboard_topics WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_counts_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_v4 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_holes_v2 WHERE uid = " + did).stepThis().dispose(); - getMediaDataController().clearBotKeyboard(did, null); + getMediaDataController().clearBotKeyboard(did); state5 = database.executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)"); state6 = database.executeFast("REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)"); @@ -3828,11 +3832,12 @@ public class MessagesStorage extends BaseController { database.executeFast("UPDATE dialogs SET unread_count = 0, unread_count_i = 0 WHERE did = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose(); + database.executeFast("DELETE FROM bot_keyboard_topics WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_counts_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_v4 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_holes_v2 WHERE uid = " + did).stepThis().dispose(); - getMediaDataController().clearBotKeyboard(did, null); + getMediaDataController().clearBotKeyboard(did); AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch)); resetAllUnreadCounters(false); updateWidgets(did); @@ -3981,6 +3986,7 @@ public class MessagesStorage extends BaseController { database.executeFast("DELETE FROM messages_v2 WHERE uid IN " + ids).stepThis().dispose(); database.executeFast("DELETE FROM polls_v2 WHERE 1").stepThis().dispose(); database.executeFast("DELETE FROM bot_keyboard WHERE uid IN " + ids).stepThis().dispose(); + database.executeFast("DELETE FROM bot_keyboard_topics WHERE uid IN " + ids).stepThis().dispose(); database.executeFast("DELETE FROM media_v4 WHERE uid IN " + ids).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes WHERE uid IN " + ids).stepThis().dispose(); database.executeFast("DELETE FROM media_holes_v2 WHERE uid IN " + ids).stepThis().dispose(); @@ -9693,6 +9699,7 @@ public class MessagesStorage extends BaseController { database.executeFast("DELETE FROM chat_pinned_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages_v2 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose(); + database.executeFast("DELETE FROM bot_keyboard_topics WHERE uid = " + did).stepThis().dispose(); database.executeFast("UPDATE media_counts_v2 SET old = 1 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM media_v4 WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes WHERE uid = " + did).stepThis().dispose(); @@ -9705,7 +9712,7 @@ public class MessagesStorage extends BaseController { database.executeFast("DELETE FROM messages_topics WHERE uid = " + did).stepThis().dispose(); database.executeFast("DELETE FROM messages_holes_topics WHERE uid = " + did).stepThis().dispose(); - getMediaDataController().clearBotKeyboard(did, null); + getMediaDataController().clearBotKeyboard(did); TLRPC.TL_messages_dialogs dialogs = new TLRPC.TL_messages_dialogs(); dialogs.chats.addAll(difference.chats); @@ -10229,7 +10236,7 @@ public class MessagesStorage extends BaseController { LongSparseIntArray newMentionsCounts = new LongSparseIntArray(); LongSparseIntArray mentionCounts = new LongSparseIntArray(); SparseArray mediaCounts = null; - LongSparseArray botKeyboards = new LongSparseArray<>(); + HashMap botKeyboards = new HashMap<>(); LongSparseArray> dialogMessagesMediaIdsMap = null; LongSparseArray dialogsMediaTypesChange = null; @@ -10403,15 +10410,20 @@ public class MessagesStorage extends BaseController { } } if (isValidKeyboardToSave(message)) { - TLRPC.Message oldMessage = botKeyboards.get(message.dialog_id); + TopicKey topicKey = TopicKey.of(message.dialog_id, topicId); + TLRPC.Message oldMessage = botKeyboards.get(topicKey); if (oldMessage == null || oldMessage.id < message.id) { - botKeyboards.put(message.dialog_id, message); + botKeyboards.put(topicKey, message); } } } - for (int a = 0; a < botKeyboards.size(); a++) { - getMediaDataController().putBotKeyboard(botKeyboards.keyAt(a), botKeyboards.valueAt(a)); + if (botKeyboards != null && !botKeyboards.isEmpty()) { + Iterator iterator = botKeyboards.keySet().iterator(); + while (iterator.hasNext()) { + TopicKey topicKey = iterator.next(); + getMediaDataController().putBotKeyboard(topicKey, botKeyboards.get(topicKey)); + } } if (mediaIdsMap != null) { @@ -12210,6 +12222,7 @@ public class MessagesStorage extends BaseController { database.executeFast(String.format(Locale.US, "DELETE FROM messages_topics WHERE mid IN(%s) AND uid = %d", ids, did)).stepThis().dispose(); database.executeFast(String.format(Locale.US, "DELETE FROM polls_v2 WHERE mid IN(%s) AND uid = %d", ids, did)).stepThis().dispose(); database.executeFast(String.format(Locale.US, "DELETE FROM bot_keyboard WHERE mid IN(%s) AND uid = %d", ids, did)).stepThis().dispose(); + database.executeFast(String.format(Locale.US, "DELETE FROM bot_keyboard_topics WHERE mid IN(%s) AND uid = %d", ids, did)).stepThis().dispose(); if (unknownMessages.isEmpty()) { cursor = database.queryFinalized(String.format(Locale.US, "SELECT uid, type FROM media_v4 WHERE mid IN(%s) AND uid = %d", ids, did)); SparseArray> mediaCounts = null; @@ -12344,7 +12357,7 @@ public class MessagesStorage extends BaseController { database.executeFast(String.format(Locale.US, "UPDATE media_counts_topics SET old = 1 WHERE uid = %d", dialogId)).stepThis().dispose(); } } - getMediaDataController().clearBotKeyboard(0, messages); + getMediaDataController().clearBotKeyboard(null, messages); if (dialogsToUpdate.size() != 0) { resetAllUnreadCounters(false); @@ -13378,7 +13391,7 @@ public class MessagesStorage extends BaseController { state_webpage = null; state_tasks = null; int minDeleteTime = Integer.MAX_VALUE; - TLRPC.Message botKeyboard = null; + HashMap botKeyboards = null; long channelId = 0; for (int a = 0; a < count; a++) { TLRPC.Message message = messages.messages.get(a); @@ -13656,8 +13669,13 @@ public class MessagesStorage extends BaseController { } if (load_type == 0 && isValidKeyboardToSave(message)) { - if (botKeyboard == null || botKeyboard.id < message.id) { - botKeyboard = message; + TopicKey topicKey = TopicKey.of(dialogId, MessageObject.getTopicId(message, isForum(dialogId))); + TLRPC.Message currentBotKeyboard = botKeyboards == null ? null : botKeyboards.get(topicKey); + if (currentBotKeyboard == null || currentBotKeyboard.id < message.id) { + if (botKeyboards == null) { + botKeyboards = new HashMap<>(); + } + botKeyboards.put(topicKey, message); } } } @@ -13680,8 +13698,12 @@ public class MessagesStorage extends BaseController { state_polls.dispose(); state_polls = null; } - if (botKeyboard != null) { - getMediaDataController().putBotKeyboard(dialogId, botKeyboard); + if (botKeyboards != null) { + Iterator iterator = botKeyboards.keySet().iterator(); + while (iterator.hasNext()) { + TopicKey topicKey = iterator.next(); + getMediaDataController().putBotKeyboard(topicKey, botKeyboards.get(topicKey)); + } } deleteFromDownloadQueue(idsToDelete, false); AndroidUtilities.runOnUIThread(() -> getFileLoader().cancelLoadFiles(namesToDelete)); @@ -14362,7 +14384,8 @@ public class MessagesStorage extends BaseController { messageDate = Math.max(message.date, messageDate); if (isValidKeyboardToSave(message)) { - getMediaDataController().putBotKeyboard(dialog.id, message); + TopicKey topicKey = TopicKey.of(dialog.id, MessageObject.getTopicId(message, isForum(dialog.id))); + getMediaDataController().putBotKeyboard(topicKey, message); } fixUnsupportedMedia(message); @@ -15646,5 +15669,13 @@ public class MessagesStorage extends BaseController { public int hashCode() { return Objects.hash(dialogId, topicId); } + + @Override + public String toString() { + return "TopicKey{" + + "dialogId=" + dialogId + + ", topicId=" + topicId + + '}'; + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java index 052babcac..910abd254 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SecretChatHelper.java @@ -1019,7 +1019,7 @@ public class SecretChatHelper extends BaseController { } byte[] thumb = ((TLRPC.TL_decryptedMessageMediaDocument) decryptedMessage.media).thumb; TLRPC.PhotoSize photoSize; - if (thumb != null && thumb.length != 0 && thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) { + if (thumb != null && thumb.length != 0 && thumb.length <= 20000) { photoSize = new TLRPC.TL_photoCachedSize(); photoSize.bytes = thumb; photoSize.w = decryptedMessage.media.thumb_w; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 1b3f34fae..70ce32712 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -1580,17 +1580,25 @@ public class SendMessagesHelper extends BaseController implements NotificationCe if (newDocument.mime_type == null) { newDocument.mime_type = ""; } - TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); - if (thumb instanceof TLRPC.TL_photoSize || thumb instanceof TLRPC.TL_photoSizeProgressive) { - File file = FileLoader.getInstance(currentAccount).getPathToAttach(thumb, true); - if (file.exists()) { - try { - int len = (int) file.length(); - byte[] arr = new byte[(int) file.length()]; - RandomAccessFile reader = new RandomAccessFile(file, "r"); - reader.readFully(arr); - TLRPC.PhotoSize newThumb = new TLRPC.TL_photoCachedSize(); + TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 10); + if (thumb instanceof TLRPC.TL_photoSize || thumb instanceof TLRPC.TL_photoSizeProgressive || thumb instanceof TLRPC.TL_photoStrippedSize) { + File file = FileLoader.getInstance(currentAccount).getPathToAttach(thumb, true); + if (thumb instanceof TLRPC.TL_photoStrippedSize || file.exists()) { + try { + byte[] arr; + TLRPC.PhotoSize newThumb; + if (thumb instanceof TLRPC.TL_photoStrippedSize) { + newThumb = new TLRPC.TL_photoStrippedSize(); + arr = thumb.bytes; + } else { + newThumb = new TLRPC.TL_photoCachedSize(); + int len = (int) file.length(); + arr = new byte[(int) file.length()]; + RandomAccessFile reader = new RandomAccessFile(file, "r"); + reader.readFully(arr); + } + TLRPC.TL_fileLocation_layer82 fileLocation = new TLRPC.TL_fileLocation_layer82(); fileLocation.dc_id = thumb.location.dc_id; fileLocation.volume_id = thumb.location.volume_id; @@ -4538,10 +4546,16 @@ public class SendMessagesHelper extends BaseController implements NotificationCe reqSend.media.caption = caption; TLRPC.PhotoSize thumb = getThumbForSecretChat(document.thumbs); if (thumb != null) { - ImageLoader.fillPhotoSizeWithBytes(thumb); - ((TLRPC.TL_decryptedMessageMediaDocument) reqSend.media).thumb = thumb.bytes; - reqSend.media.thumb_h = thumb.h; - reqSend.media.thumb_w = thumb.w; + if (thumb instanceof TLRPC.TL_photoStrippedSize) { + ((TLRPC.TL_decryptedMessageMediaDocument) reqSend.media).thumb = thumb.bytes; + reqSend.media.thumb_h = thumb.h; + reqSend.media.thumb_w = thumb.w; + } else { + ImageLoader.fillPhotoSizeWithBytes(thumb); + ((TLRPC.TL_decryptedMessageMediaDocument) reqSend.media).thumb = thumb.bytes; + reqSend.media.thumb_h = thumb.h; + reqSend.media.thumb_w = thumb.w; + } } else { ((TLRPC.TL_decryptedMessageMediaDocument) reqSend.media).thumb = new byte[0]; reqSend.media.thumb_h = 0; @@ -4726,9 +4740,12 @@ public class SendMessagesHelper extends BaseController implements NotificationCe } for (int a = 0, N = arrayList.size(); a < N; a++) { TLRPC.PhotoSize size = arrayList.get(a); - if (size == null || size instanceof TLRPC.TL_photoStrippedSize || size instanceof TLRPC.TL_photoPathSize || size instanceof TLRPC.TL_photoSizeEmpty || size.location == null) { + if (size == null || size instanceof TLRPC.TL_photoPathSize || size instanceof TLRPC.TL_photoSizeEmpty || size.location == null) { continue; } + if (size instanceof TLRPC.TL_photoStrippedSize) { + return size; + } TLRPC.TL_photoSize photoSize = new TLRPC.TL_photoSize_layer127(); photoSize.type = size.type; photoSize.w = size.w; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java index 99f0cf050..5ac470400 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java @@ -111,6 +111,7 @@ public class SharedConfig { public static boolean disableVoiceAudioEffects; public static boolean forceDisableTabletMode; public static boolean updateStickersOrderOnSend = true; + public static boolean bigCameraForRound; private static int lastLocalId = -210000; public static String storageCacheDir; @@ -127,6 +128,7 @@ public class SharedConfig { public static int mapPreviewType = 2; public static boolean chatBubbles = Build.VERSION.SDK_INT >= 30; public static boolean raiseToSpeak = false; + public static boolean raiseToListen = true; public static boolean recordViaSco = false; public static boolean customTabs = true; public static boolean directShare = true; @@ -138,6 +140,7 @@ public class SharedConfig { public static boolean streamMkv = false; public static boolean saveStreamMedia = true; public static boolean pauseMusicOnRecord = false; + public static boolean pauseMusicOnMedia = true; public static boolean noiseSupression; public static final boolean noStatusBar = true; public static boolean debugWebView; @@ -448,6 +451,7 @@ public class SharedConfig { preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SaveToGallerySettingsHelper.load(preferences); mapPreviewType = preferences.getInt("mapPreviewType", 2); + raiseToListen = preferences.getBoolean("raise_to_listen", true); raiseToSpeak = preferences.getBoolean("raise_to_speak", false); recordViaSco = preferences.getBoolean("record_via_sco", false); customTabs = preferences.getBoolean("custom_tabs", true); @@ -456,7 +460,7 @@ public class SharedConfig { playOrderReversed = !shuffleMusic && preferences.getBoolean("playOrderReversed", false); inappCamera = preferences.getBoolean("inappCamera", true); hasCameraCache = preferences.contains("cameraCache"); - roundCamera16to9 = true;//preferences.getBoolean("roundCamera16to9", false); + roundCamera16to9 = true; repeatMode = preferences.getInt("repeatMode", 0); fontSize = preferences.getInt("fons_size", AndroidUtilities.isTablet() ? 18 : 16); fontSizeIsDefault = !preferences.contains("fons_size"); @@ -467,6 +471,7 @@ public class SharedConfig { streamMedia = preferences.getBoolean("streamMedia", true); saveStreamMedia = preferences.getBoolean("saveStreamMedia", true); pauseMusicOnRecord = preferences.getBoolean("pauseMusicOnRecord", false); + pauseMusicOnMedia = preferences.getBoolean("pauseMusicOnMedia", true); forceDisableTabletMode = preferences.getBoolean("forceDisableTabletMode", false); streamAllVideo = preferences.getBoolean("streamAllVideo", BuildVars.DEBUG_VERSION); streamMkv = preferences.getBoolean("streamMkv", false); @@ -504,6 +509,7 @@ public class SharedConfig { hasEmailLogin = preferences.getBoolean("hasEmailLogin", false); isFloatingDebugActive = preferences.getBoolean("floatingDebugActive", false); updateStickersOrderOnSend = preferences.getBoolean("updateStickersOrderOnSend", true); + bigCameraForRound = preferences.getBoolean("bigCameraForRound", false); preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true); @@ -949,7 +955,7 @@ public class SharedConfig { editor.commit(); } - public static void toogleRaiseToSpeak() { + public static void toggleRaiseToSpeak() { raiseToSpeak = !raiseToSpeak; SharedPreferences preferences = MessagesController.getGlobalMainSettings(); SharedPreferences.Editor editor = preferences.edit(); @@ -957,6 +963,18 @@ public class SharedConfig { editor.commit(); } + public static void toggleRaiseToListen() { + raiseToListen = !raiseToListen; + SharedPreferences preferences = MessagesController.getGlobalMainSettings(); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("raise_to_listen", raiseToListen); + editor.commit(); + } + + public static boolean enabledRaiseTo(boolean speak) { + return raiseToListen && (!speak || raiseToSpeak); + } + public static void toggleCustomTabs() { customTabs = !customTabs; SharedPreferences preferences = MessagesController.getGlobalMainSettings(); @@ -1031,6 +1049,14 @@ public class SharedConfig { editor.commit(); } + public static void togglePauseMusicOnMedia() { + pauseMusicOnMedia = !pauseMusicOnMedia; + SharedPreferences preferences = MessagesController.getGlobalMainSettings(); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("pauseMusicOnMedia", pauseMusicOnMedia); + editor.commit(); + } + public static void toggleChatBlur() { LiteMode.toggleFlag(LiteMode.FLAG_CHAT_BLUR); } @@ -1475,6 +1501,15 @@ public class SharedConfig { return getDevicePerformanceClass() <= PERFORMANCE_CLASS_AVERAGE; } + public static void toggleRoundCamera() { + bigCameraForRound = !bigCameraForRound; + ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE) + .edit() + .putBoolean("bigCameraForRound", bigCameraForRound) + .apply(); + } + + @Deprecated public static int getLegacyDevicePerformanceClass() { if (legacyDevicePerformanceClass == -1) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java index d2429f207..82baade21 100755 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java @@ -3231,6 +3231,9 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa } public void declineIncomingCall(int reason, final Runnable onDone) { + if (groupCall != null) { + stopScreenCapture(); + } stopRinging(); callDiscardReason = reason; if (currentState == STATE_REQUESTING) { diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index f9647c377..d0ce4099d 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -20,7 +20,6 @@ import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.MessageObject; -import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SvgHelper; import org.telegram.messenger.Utilities; @@ -71,7 +70,7 @@ public class TLRPC { public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800; public static final int MESSAGE_FLAG_EDITED = 0x00008000; - public static final int LAYER = 155; + public static final int LAYER = 156; public static class TL_stats_megagroupStats extends TLObject { public static int constructor = 0xef7ff916; @@ -6839,6 +6838,8 @@ public class TLRPC { public byte[] nonce; public String receipt; public int push_timeout; + public int reset_available_period; + public int reset_pending_date; public boolean verifiedFirebase; //custom public static auth_SentCodeType TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { @@ -6850,7 +6851,7 @@ public class TLRPC { case 0x5353e5a7: result = new TL_auth_sentCodeTypeCall(); break; - case 0x5a159841: + case 0xf450f59b: result = new TL_auth_sentCodeTypeEmailCode(); break; case 0xa5491dea: @@ -6911,7 +6912,7 @@ public class TLRPC { } public static class TL_auth_sentCodeTypeEmailCode extends auth_SentCodeType { - public static int constructor = 0x5a159841; + public static int constructor = 0xf450f59b; public void readParams(AbstractSerializedData stream, boolean exception) { @@ -6920,8 +6921,11 @@ public class TLRPC { google_signin_allowed = (flags & 2) != 0; email_pattern = stream.readString(exception); length = stream.readInt32(exception); - if ((flags & 4) != 0) { - next_phone_login_date = stream.readInt32(exception); + if ((flags & 8) != 0) { + reset_available_period = stream.readInt32(exception); + } + if ((flags & 16) != 0) { + reset_pending_date = stream.readInt32(exception); } } @@ -6932,8 +6936,11 @@ public class TLRPC { stream.writeInt32(flags); stream.writeString(email_pattern); stream.writeInt32(length); - if ((flags & 4) != 0) { - stream.writeInt32(next_phone_login_date); + if ((flags & 8) != 0) { + stream.writeInt32(reset_available_period); + } + if ((flags & 16) != 0) { + stream.writeInt32(reset_pending_date); } } } @@ -11449,6 +11456,7 @@ public class TLRPC { public int flags; public boolean resize; public boolean single_use; + public boolean is_persistent; public boolean selective; public String placeholder; public ArrayList rows = new ArrayList<>(); @@ -11495,6 +11503,7 @@ public class TLRPC { resize = (flags & 1) != 0; single_use = (flags & 2) != 0; selective = (flags & 4) != 0; + is_persistent = (flags & 16) != 0; int magic = stream.readInt32(exception); if (magic != 0x1cb5c415) { if (exception) { @@ -11520,6 +11529,7 @@ public class TLRPC { flags = resize ? (flags | 1) : (flags &~ 1); flags = single_use ? (flags | 2) : (flags &~ 2); flags = selective ? (flags | 4) : (flags &~ 4); + flags = is_persistent ? (flags | 16) : (flags &~ 16); stream.writeInt32(flags); stream.writeInt32(0x1cb5c415); int count = rows.size(); @@ -50878,6 +50888,23 @@ public class TLRPC { } } + public static class TL_auth_resetLoginEmail extends TLObject { + public static int constructor = 0x7e960193; + + public String phone_number; + public String phone_code_hash; + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return auth_SentCode.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + stream.writeString(phone_number); + stream.writeString(phone_code_hash); + } + } + public static class TL_auth_resetAuthorizations extends TLObject { public static int constructor = 0x9fab0d1a; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index 0e00fffae..71277150c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -1416,7 +1416,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F if (delayedAnimationResumed) { delayedOpenAnimationRunnable.run(); } else { - AndroidUtilities.runOnUIThread(delayedOpenAnimationRunnable, 100); + AndroidUtilities.runOnUIThread(delayedOpenAnimationRunnable, 200); } } } @@ -1842,7 +1842,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F @Override public void bringToFront(int i) { - if (fragmentsStack.isEmpty()) { + if (fragmentsStack.isEmpty() || !fragmentsStack.isEmpty() && fragmentsStack.size() - 1 == i && fragmentsStack.get(i).fragmentView != null) { return; } for (int a = 0; a < i; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java index 261db0432..f5703551c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AlertDialog.java @@ -568,7 +568,7 @@ public class AlertDialog extends Dialog implements Drawable.Callback, Notificati } }; containerView.setOrientation(LinearLayout.VERTICAL); - if (blurredBackground || progressViewStyle == ALERT_TYPE_SPINNER) { + if ((blurredBackground || progressViewStyle == ALERT_TYPE_SPINNER) && progressViewStyle != ALERT_TYPE_LOADING) { containerView.setBackgroundDrawable(null); containerView.setPadding(0, 0, 0, 0); if (blurredBackground && !blurredNativeBackground) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java index a75dfc9a5..7bf08053b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -1211,7 +1211,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW)); itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER)); itemInternals.add(new ItemInternal(VIEW_TYPE_CONTACTS_FLICKER)); - } else if (onlineContacts != null) { + } else if (onlineContacts != null && !onlineContacts.isEmpty()) { if (dialogsCount == 0) { isEmpty = true; itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY)); @@ -1223,11 +1223,11 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements } itemInternals.add(new ItemInternal(VIEW_TYPE_SHADOW)); itemInternals.add(new ItemInternal(VIEW_TYPE_HEADER)); - for (int k = 0; k < onlineContacts.size(); k++) { - itemInternals.add(new ItemInternal(VIEW_TYPE_USER, onlineContacts.get(k))); - } - itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY)); } + for (int k = 0; k < onlineContacts.size(); k++) { + itemInternals.add(new ItemInternal(VIEW_TYPE_USER, onlineContacts.get(k))); + } + itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY)); stopUpdate = true; } else if (hasHints) { int count = MessagesController.getInstance(currentAccount).hintDialogs.size(); @@ -1258,18 +1258,20 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements itemInternals.add(new ItemInternal(VIEW_TYPE_DIALOG, array.get(k))); } } - } - if (!forceShowEmptyCell && dialogsType != 7 && dialogsType != 8 && !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) { - itemInternals.add(new ItemInternal(VIEW_TYPE_FLICKER)); - } else if (dialogsCount == 0) { - isEmpty = true; - itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY)); - } else { - if (folderId == 0 && dialogsCount > 10 && dialogsType == DialogsActivity.DIALOGS_TYPE_DEFAULT) { - itemInternals.add(new ItemInternal(VIEW_TYPE_NEW_CHAT_HINT)); + if (!forceShowEmptyCell && dialogsType != 7 && dialogsType != 8 && !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) { + if (dialogsCount != 0) { + itemInternals.add(new ItemInternal(VIEW_TYPE_FLICKER)); + } + } else if (dialogsCount == 0) { + isEmpty = true; + itemInternals.add(new ItemInternal(requestPeerType == null ? VIEW_TYPE_EMPTY : VIEW_TYPE_REQUIRED_EMPTY)); + } else { + if (folderId == 0 && dialogsCount > 10 && dialogsType == DialogsActivity.DIALOGS_TYPE_DEFAULT) { + itemInternals.add(new ItemInternal(VIEW_TYPE_NEW_CHAT_HINT)); + } + itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY)); } - itemInternals.add(new ItemInternal(VIEW_TYPE_LAST_EMPTY)); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index 5a29157dc..63aefd682 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -1139,7 +1139,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD if (isButtonLayout(messageObject)) { canvas.save(); - float x = (previousWidth - giftRectSize) / 2f + AndroidUtilities.dp(8), y = textY + textHeight + giftRectSize * 0.075f + imageSize + AndroidUtilities.dp(4); + float x = (previousWidth - giftRectSize) / 2f + AndroidUtilities.dp(8), y = textY + textHeight + giftRectSize * 0.075f + (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO ? imageSize : stickerSize) + AndroidUtilities.dp(4); if (messageObject.type == MessageObject.TYPE_SUGGEST_PHOTO) { y += +AndroidUtilities.dp(16); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java index 0f97dcc76..1ac0e4122 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java @@ -95,7 +95,7 @@ public class TextDetailSettingsCell extends FrameLayout { } } - public void setTextAndValue(String text, CharSequence value, boolean divider) { + public void setTextAndValue(CharSequence text, CharSequence value, boolean divider) { textView.setText(text); valueTextView.setText(value); needDivider = divider; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 18be0a81b..49a108eda 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -2168,7 +2168,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not getNotificationCenter().addObserver(this, NotificationCenter.screenshotTook); getNotificationCenter().addObserver(this, NotificationCenter.encryptedChatUpdated); getNotificationCenter().addObserver(this, NotificationCenter.messagesReadEncrypted); - getNotificationCenter().addObserver(this, NotificationCenter.botKeyboardDidLoad); getNotificationCenter().addObserver(this, NotificationCenter.updateMentionsCount); getNotificationCenter().addObserver(this, NotificationCenter.newDraftReceived); getNotificationCenter().addObserver(this, NotificationCenter.chatOnlineCountDidLoad); @@ -2186,6 +2185,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not getNotificationCenter().addObserver(this, NotificationCenter.didLoadPinnedMessages); } } + getNotificationCenter().addObserver(this, NotificationCenter.botKeyboardDidLoad); getNotificationCenter().addObserver(this, NotificationCenter.removeAllMessagesFromDialog); getNotificationCenter().addObserver(this, NotificationCenter.messagesReadContent); getNotificationCenter().addObserver(this, NotificationCenter.chatSearchResultsAvailable); @@ -2286,7 +2286,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not getMessagesController().setLastCreatedDialogId(dialog_id, chatMode == MODE_SCHEDULED, true); if (chatMode == 0) { if (currentEncryptedChat == null) { - getMediaDataController().loadBotKeyboard(dialog_id); + getMediaDataController().loadBotKeyboard(MessagesStorage.TopicKey.of(dialog_id, getTopicId())); } getMessagesController().loadPeerSettings(currentUser, currentChat); @@ -2338,21 +2338,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (chatMode != MODE_PINNED && !forceHistoryEmpty) { waitingForLoad.add(lastLoadIndex); + int initialMessagesSize; + if (SharedConfig.deviceIsHigh()) { + initialMessagesSize = (isThreadChat() && !isTopic) ? 30 : 25; + } else { + initialMessagesSize = (isThreadChat() && !isTopic) ? 20 : 15; + } if (startLoadFromDate != 0) { getMessagesController().loadMessages(dialog_id, mergeDialogId, false, 30, 0, startLoadFromDate, true, 0, classGuid, 4, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); } else if (startLoadFromMessageId != 0 && (!isThreadChat() || startLoadFromMessageId == highlightMessageId || isTopic)) { startLoadFromMessageIdSaved = startLoadFromMessageId; if (migrated_to != 0) { mergeDialogId = migrated_to; - getMessagesController().loadMessages(mergeDialogId, 0, loadInfo, loadingFromOldPosition ? 50 : (AndroidUtilities.isTablet() || (isThreadChat() && !isTopic) ? 30 : 20), startLoadFromMessageId, 0, true, 0, classGuid, 3, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); + getMessagesController().loadMessages(mergeDialogId, 0, loadInfo, initialMessagesSize, startLoadFromMessageId, 0, true, 0, classGuid, 3, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); } else { - getMessagesController().loadMessages(dialog_id, mergeDialogId, loadInfo, loadingFromOldPosition ? 50 : (AndroidUtilities.isTablet() || (isThreadChat() && !isTopic) ? 30 : 20), startLoadFromMessageId, 0, true, 0, classGuid, 3, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); + getMessagesController().loadMessages(dialog_id, mergeDialogId, loadInfo, initialMessagesSize, startLoadFromMessageId, 0, true, 0, classGuid, 3, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); } } else { if (historyPreloaded) { lastLoadIndex++; } else { - getMessagesController().loadMessages(dialog_id, mergeDialogId, loadInfo, AndroidUtilities.isTablet() || (isThreadChat() && !isTopic) ? 30 : 20, startLoadFromMessageId, 0, true, 0, classGuid, 2, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); + getMessagesController().loadMessages(dialog_id, mergeDialogId, loadInfo, initialMessagesSize, startLoadFromMessageId, 0, true, 0, classGuid, 2, 0, chatMode, threadMessageId, replyMaxReadId, lastLoadIndex++, isTopic); } } } @@ -5443,7 +5449,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not forceNextPinnedMessageId = 0; } } - } } if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING) { @@ -7359,6 +7364,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } updateTopPanel(true); } + + @Override + protected void onCloseClick() { + MessagesController.getNotificationsSettings(currentAccount).edit().putInt("dialog_show_translate_count" + getDialogId(), 140).commit(); + updateTopPanel(true); + } }; topChatPanelView.addView(translateButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 2)); } @@ -10183,7 +10194,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not SparseArray attachedMessaesTmp = new SparseArray<>(); private void checkAutoDownloadMessages(boolean scrollUp) { - if (chatListView == null || !chatListViewAttached) { + if (chatListView == null || !chatListViewAttached || SharedConfig.deviceIsLow()) { return; } preloadingMessagesTmp.clear(); @@ -10265,30 +10276,30 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void checkAutoDownloadMessage(MessageObject object) { - if (object.mediaExists) { - return; - } - TLRPC.Message message = object.messageOwner; - int canDownload = getDownloadController().canDownloadMedia(message); - if (canDownload == 0) { - return; - } - TLRPC.Document document = object.getDocument(); - TLRPC.PhotoSize photo = document == null ? FileLoader.getClosestPhotoSizeWithSize(object.photoThumbs, AndroidUtilities.getPhotoSize()) : null; - if (document == null && photo == null) { - return; - } - if (canDownload == 2 || canDownload == 1 && object.isVideo()) { -// if (document != null && currentEncryptedChat == null && !object.shouldEncryptPhotoOrVideo() && object.canStreamVideo()) { -// getFileLoader().loadFile(document, object, FileLoader.PRIORITY_LOW, 10); +// if (object.mediaExists) { +// return; +// } +// TLRPC.Message message = object.messageOwner; +// int canDownload = getDownloadController().canDownloadMedia(message); +// if (canDownload == 0) { +// return; +// } +// TLRPC.Document document = object.getDocument(); +// TLRPC.PhotoSize photo = document == null ? FileLoader.getClosestPhotoSizeWithSize(object.photoThumbs, AndroidUtilities.getPhotoSize()) : null; +// if (document == null && photo == null) { +// return; +// } +// if (canDownload == 2 || canDownload == 1 && object.isVideo()) { +//// if (document != null && currentEncryptedChat == null && !object.shouldEncryptPhotoOrVideo() && object.canStreamVideo()) { +//// getFileLoader().loadFile(document, object, FileLoader.PRIORITY_LOW, 10); +//// } +// } else { +// if (document != null) { +// getFileLoader().loadFile(document, object, FileLoader.PRIORITY_LOW, MessageObject.isVideoDocument(document) && object.shouldEncryptPhotoOrVideo() ? 2 : 0); +// } else { +// getFileLoader().loadFile(ImageLocation.getForObject(photo, object.photoThumbsObject), object, null, FileLoader.PRIORITY_LOW, object.shouldEncryptPhotoOrVideo() ? 2 : 0); // } - } else { - if (document != null) { - getFileLoader().loadFile(document, object, FileLoader.PRIORITY_LOW, MessageObject.isVideoDocument(document) && object.shouldEncryptPhotoOrVideo() ? 2 : 0); - } else { - getFileLoader().loadFile(ImageLocation.getForObject(photo, object.photoThumbsObject), object, null, FileLoader.PRIORITY_LOW, object.shouldEncryptPhotoOrVideo() ? 2 : 0); - } - } +// } } public void clearMessagesPreloading() { @@ -10830,7 +10841,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (botButtons.messageOwner.reply_markup instanceof TLRPC.TL_replyKeyboardForceReply) { SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); - if (preferences.getInt("answered_" + dialog_id, 0) != botButtons.getId() && (replyingMessageObject == null || chatActivityEnterView.getFieldText() == null)) { + String tk = isTopic ? dialog_id + "_" + getTopicId() : "" + dialog_id; + if (preferences.getInt("answered_" + tk, 0) != botButtons.getId() && (replyingMessageObject == null || chatActivityEnterView.getFieldText() == null)) { botReplyButtons = botButtons; chatActivityEnterView.setButtons(botButtons); showFieldPanelForReply(botButtons); @@ -11305,7 +11317,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (replyingMessageObject != null && replyingMessageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyKeyboardForceReply) { SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); - preferences.edit().putInt("answered_" + dialog_id, replyingMessageObject.getId()).commit(); + String tk = isTopic ? dialog_id + "_" + getTopicId() : "" + dialog_id; + preferences.edit().putInt("answered_" + tk, replyingMessageObject.getId()).commit(); } if (foundWebPage != null) { foundWebPage = null; @@ -14390,7 +14403,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not replyButtonAnimation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (replyButtonAnimation != null && replyButtonAnimation.equals(animation)) { + if (replyButtonAnimation != null && replyButtonAnimation.equals(animation) && replyButton != null) { if (newVisibilityFinal == View.GONE) { replyButton.setVisibility(View.GONE); } @@ -15501,12 +15514,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } firstLoading = false; - AndroidUtilities.runOnUIThread(() -> { - getNotificationCenter().runDelayedNotifications(); - resumeDelayedFragmentAnimation(); - AndroidUtilities.cancelRunOnUIThread(fragmentTransitionRunnable); - fragmentTransitionRunnable.run(); - }); } if (isThreadChat() && !isTopic && (load_type == 2 || load_type == 3) && !isCache) { @@ -16253,6 +16260,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } chatWasReset = false; + + if (isFirstLoading) { + AndroidUtilities.runOnUIThread(() -> { + resumeDelayedFragmentAnimation(); + + AndroidUtilities.cancelRunOnUIThread(fragmentTransitionRunnable); + fragmentTransitionRunnable.run(); + getNotificationCenter().runDelayedNotifications(); + }); + } } else if (id == NotificationCenter.invalidateMotionBackground) { if (chatListView != null) { chatListView.invalidateViews(); @@ -17745,7 +17762,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateBotButtons(); } } else if (id == NotificationCenter.botKeyboardDidLoad) { - if (dialog_id == (Long) args[1]) { + MessagesStorage.TopicKey topicKey = (MessagesStorage.TopicKey) args[1]; + if (dialog_id == topicKey.dialogId && getTopicId() == topicKey.topicId) { TLRPC.Message message = (TLRPC.Message) args[0]; if (message != null && !userBlocked) { botButtons = new MessageObject(currentAccount, message, false, false); @@ -21803,7 +21821,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - private boolean shownRestartTopic; + private boolean shownRestartTopic, shownTranslateTopic; private void updateTopPanel(boolean animated) { if (chatMode != 0) { return; @@ -21841,6 +21859,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (showRestartTopic) { shownRestartTopic = true; } + if (showTranslate) { + shownTranslateTopic = true; + } boolean showRestartTopic1 = (showRestartTopic || shownRestartTopic) && !(showReport || showBlock || showGeo); if (show || showReport || showBlock || showGeo || showTranslate || showRestartTopic1) { createTopPanel(); @@ -21849,18 +21870,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } - if (reportSpamButton != null) { - reportSpamButton.setVisibility(showReport || showBlock || showGeo ? View.VISIBLE : View.GONE); - } - if (restartTopicButton != null) { - restartTopicButton.setVisibility(showRestartTopic1 ? View.VISIBLE : View.GONE); - } if (showTranslate) { createTranslateButton(); if (translateButton != null) { translateButton.updateText(); } } + if ((shownTranslateTopic || shownRestartTopic) && !show) { + showReport = showGeo = showShare = showBlock = showAdd = showArchive = showAddMembersToGroup = false; + show = true; + } + if (reportSpamButton != null) { + reportSpamButton.setVisibility(showReport || showBlock || showGeo ? View.VISIBLE : View.GONE); + } + if (restartTopicButton != null) { + restartTopicButton.setVisibility(showRestartTopic1 ? View.VISIBLE : View.GONE); + } if (translateButton != null) { translateButton.setVisibility(showTranslate ? View.VISIBLE : View.GONE); } @@ -21871,9 +21896,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (!showRestartTopic) { shownRestartTopic = false; } - - if (showRestartTopic || showTranslate) { - show = true; + if (!showTranslate) { + shownTranslateTopic = false; } addToContactsButtonArchive = false; @@ -26055,7 +26079,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public boolean onBackPressed() { - if (ContentPreviewViewer.getInstance().isVisible()) { + if (selectionReactionsOverlay != null && !selectionReactionsOverlay.onBackPressed()) { + return false; + } else if (ContentPreviewViewer.getInstance().isVisible()) { ContentPreviewViewer.getInstance().closeWithMenu(); return false; } else if (forwardingPreviewView != null && forwardingPreviewView.isShowing()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java index 394369094..8124b1a67 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java @@ -281,7 +281,7 @@ public class ChatRightsEditActivity extends BaseFragment { defaultBannedRights.send_voices = defaultBannedRights.send_roundvideos = false; } - if (!defaultBannedRights.change_info) { + if (!defaultBannedRights.change_info && !isChannel) { adminRights.change_info = true; } if (!defaultBannedRights.pin_messages) { @@ -1477,7 +1477,7 @@ public class ChatRightsEditActivity extends BaseFragment { return false; } if (position == changeInfoRow) { - return myAdminRights.change_info && (defaultBannedRights == null || defaultBannedRights.change_info); + return myAdminRights.change_info && (defaultBannedRights == null || defaultBannedRights.change_info || isChannel); } else if (position == postMessagesRow) { return myAdminRights.post_messages; } else if (position == editMesagesRow) { @@ -1725,7 +1725,7 @@ public class ChatRightsEditActivity extends BaseFragment { } else if (position == changeInfoRow) { if (currentType == TYPE_ADMIN || currentType == TYPE_ADD_BOT) { if (isChannel) { - checkCell.setTextAndCheck(LocaleController.getString("EditAdminChangeChannelInfo", R.string.EditAdminChangeChannelInfo), asAdminValue && adminRights.change_info || !defaultBannedRights.change_info, true); + checkCell.setTextAndCheck(LocaleController.getString("EditAdminChangeChannelInfo", R.string.EditAdminChangeChannelInfo), asAdminValue && adminRights.change_info, true); } else { checkCell.setTextAndCheck(LocaleController.getString("EditAdminChangeGroupInfo", R.string.EditAdminChangeGroupInfo), asAdminValue && adminRights.change_info || !defaultBannedRights.change_info, true); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java index 62a223529..bd9b285d5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java @@ -1133,15 +1133,9 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable, if (renderingBitmap == null && nextRenderingBitmap == null) { scheduleNextGetFrame(); } else if (nextRenderingBitmap != null && (renderingBitmap == null || (Math.abs(now - lastFrameTime) >= invalidateAfter && !skipFrameUpdate))) { - //if (precache) { - backgroundBitmap = renderingBitmap; - // } renderingBitmap = nextRenderingBitmap; renderingBitmapTime = nextRenderingBitmapTime; for (int i = 0; i < backgroundShader.length; i++) { - // if (precache) { - backgroundShader[i] = renderingShader[i]; - // } renderingShader[i] = nextRenderingShader[i]; nextRenderingShader[i] = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 7493582c1..c8a422842 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -2454,7 +2454,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific giftButton.setBackground(Theme.createSelectorDrawable(getThemedColor(Theme.key_listSelector))); } attachLayout.addView(giftButton, 0, LayoutHelper.createFrame(48, 48, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); - giftButton.setOnClickListener(v -> new GiftPremiumBottomSheet(getParentFragment(), getParentFragment().getCurrentUser()).show()); + giftButton.setOnClickListener(v -> { + MessagesController.getInstance(currentAccount).getMainSettings().edit().putBoolean("show_gift_for_" + parentFragment.getDialogId(), false).apply(); + AndroidUtilities.updateViewVisibilityAnimated(giftButton, false); + new GiftPremiumBottomSheet(getParentFragment(), getParentFragment().getCurrentUser()).show(); + }); } private void createBotButton() { @@ -4864,7 +4868,9 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific botMessageObject = botButtonsMessageObject; } replyingMessageObject = messageObject; - setButtons(replyingMessageObject, true); + if (!(parentFragment != null && parentFragment.isTopic && parentFragment.getThreadMessage() == replyingMessageObject)) { + setButtons(replyingMessageObject, true); + } } else if (replyingMessageObject == botButtonsMessageObject) { replyingMessageObject = null; setButtons(botMessageObject, false); @@ -7412,7 +7418,8 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific boolean visible = !MessagesController.getInstance(currentAccount).premiumLocked && MessagesController.getInstance(currentAccount).giftAttachMenuIcon && MessagesController.getInstance(currentAccount).giftTextFieldIcon && getParentFragment() != null && getParentFragment().getCurrentUser() != null && !BuildVars.IS_BILLING_UNAVAILABLE && !getParentFragment().getCurrentUser().self && !getParentFragment().getCurrentUser().premium && - getParentFragment().getCurrentUserInfo() != null && !getParentFragment().getCurrentUserInfo().premium_gifts.isEmpty() && !isInScheduleMode(); + getParentFragment().getCurrentUserInfo() != null && !getParentFragment().getCurrentUserInfo().premium_gifts.isEmpty() && !isInScheduleMode() && + MessagesController.getInstance(currentAccount).getMainSettings().getBoolean("show_gift_for_" + parentFragment.getDialogId(), true); if (!visible && giftButton == null) { return; @@ -7671,7 +7678,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific boolean wasVisible = botButton != null && botButton.getVisibility() == VISIBLE; if (hasBotWebView || hasBotCommands || botReplyMarkup != null) { if (botReplyMarkup != null) { - if (isPopupShowing() && currentPopupContentType == POPUP_CONTENT_BOT_KEYBOARD) { + if (isPopupShowing() && currentPopupContentType == POPUP_CONTENT_BOT_KEYBOARD && botReplyMarkup.is_persistent) { if (botButton != null && botButton.getVisibility() != GONE) { botButton.setVisibility(GONE); } @@ -7782,9 +7789,10 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific botKeyboardView.setVisibility(GONE); botKeyboardViewVisible = false; botKeyboardView.setDelegate(button -> { - MessageObject object = replyingMessageObject != null ? replyingMessageObject : (DialogObject.isChatDialog(dialog_id) ? botButtonsMessageObject : null); - boolean open = didPressedBotButton(button, object, replyingMessageObject != null ? replyingMessageObject : botButtonsMessageObject); - if (replyingMessageObject != null) { + boolean replyingIsTopicStarter = replyingMessageObject != null && parentFragment != null && parentFragment.isTopic && parentFragment.getTopicId() == replyingMessageObject.getId(); + MessageObject object = replyingMessageObject != null && !replyingIsTopicStarter ? replyingMessageObject : (DialogObject.isChatDialog(dialog_id) ? botButtonsMessageObject : null); + boolean open = didPressedBotButton(button, object, replyingMessageObject != null && !replyingIsTopicStarter ? replyingMessageObject : botButtonsMessageObject); + if (replyingMessageObject != null && !replyingIsTopicStarter) { openKeyboardInternal(); setButtons(botMessageObject, false); } else if (botButtonsMessageObject != null && botButtonsMessageObject.messageOwner.reply_markup.single_use) { @@ -7794,7 +7802,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific showPopup(0, 0); } SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); - preferences.edit().putInt("answered_" + dialog_id, botButtonsMessageObject.getId()).commit(); + preferences.edit().putInt("answered_" + getTopicKeyString(), botButtonsMessageObject.getId()).commit(); } if (delegate != null) { delegate.onMessageSend(null, true, 0); @@ -7810,8 +7818,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific if (botReplyMarkup != null) { SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); boolean showPopup = true; - if (botButtonsMessageObject != replyingMessageObject && botReplyMarkup.single_use) { - if (preferences.getInt("answered_" + dialog_id, 0) == messageObject.getId()) { + if (botButtonsMessageObject != replyingMessageObject) { + if (messageObject != null && ( + botReplyMarkup.single_use && preferences.getInt("answered_" + getTopicKeyString(), 0) == messageObject.getId() || + !botReplyMarkup.is_persistent && preferences.getInt("closed_botkeyboard_" + getTopicKeyString(), 0) == messageObject.getId() + )) { showPopup = false; } } @@ -8529,6 +8540,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific botKeyboardView.setVisibility(VISIBLE); currentView = botKeyboardView; animatingContentType = POPUP_CONTENT_BOT_KEYBOARD; + MessagesController.getMainSettings(currentAccount).edit().remove("closed_botkeyboard_" + getTopicKeyString()).apply(); } currentPopupContentType = contentType; @@ -8682,6 +8694,9 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific } botKeyboardViewVisible = false; } + if (contentType == POPUP_CONTENT_BOT_KEYBOARD && botButtonsMessageObject != null) { + MessagesController.getMainSettings(currentAccount).edit().putInt("closed_botkeyboard_" + getTopicKeyString(), botButtonsMessageObject.getId()).apply(); + } updateBotButton(true); } @@ -8695,6 +8710,13 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific checkBotMenu(); } + private String getTopicKeyString() { + if (parentFragment != null && parentFragment.isTopic) { + return dialog_id + "_" + parentFragment.getTopicId(); + } + return "" + dialog_id; + } + private void setEmojiButtonImage(boolean byOpen, boolean animated) { if (emojiButton == null) { return; @@ -8757,8 +8779,11 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific public boolean hidePopup(boolean byBackButton, boolean forceAnimate) { if (isPopupShowing()) { - if (currentPopupContentType == POPUP_CONTENT_BOT_KEYBOARD && byBackButton && botButtonsMessageObject != null) { - return false; + if (currentPopupContentType == POPUP_CONTENT_BOT_KEYBOARD && botReplyMarkup != null && byBackButton && botButtonsMessageObject != null) { + if (botReplyMarkup.is_persistent) { + return false; + } + MessagesController.getMainSettings(currentAccount).edit().putInt("closed_botkeyboard_" + getTopicKeyString(), botButtonsMessageObject.getId()).apply(); } if (byBackButton && searchingType != 0 || forceAnimate) { setSearchingTypeInternal(0, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java index a3ca79bbd..cbaeaec6b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAvatarContainer.java @@ -1080,6 +1080,7 @@ public class ChatAvatarContainer extends FrameLayout implements NotificationCent sb.append("\n"); sb.append(subtitleTextView.getText()); info.setContentDescription(sb); + setContentDescription(sb); if (info.isClickable() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { info.addAction(new AccessibilityNodeInfo.AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, LocaleController.getString("OpenProfile", R.string.OpenProfile))); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java index 408974633..db4930957 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EditTextCaption.java @@ -571,6 +571,7 @@ public class EditTextCaption extends EditTextBoldCursor { stringBuilder.append(getText().subSequence(end, getText().length())); } setText(stringBuilder); + setSelection(start, start); return true; } catch (Exception e) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java index b50ec4ae4..46a9e4b8e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/InstantCameraView.java @@ -174,9 +174,9 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter private float panTranslationY; private float animationTranslationY; - private float[] mMVPMatrix = new float[16]; - private float[] mSTMatrix = new float[16]; - private float[] moldSTMatrix = new float[16]; + private final float[] mMVPMatrix = new float[16]; + private final float[] mSTMatrix = new float[16]; + private final float[] moldSTMatrix = new float[16]; private static final String VERTEX_SHADER = "uniform mat4 uMVPMatrix;\n" + "uniform mat4 uSTMatrix;\n" + @@ -229,6 +229,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter private static final int[] ALLOW_BIG_CAMERA_WHITELIST = { 285904780, // XIAOMI (Redmi Note 7) + -1394191079 // samsung a31 }; @@ -1038,6 +1039,26 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter } private boolean allowBigSizeCamera() { + if (SharedConfig.bigCameraForRound) { + return true; + } + if (SharedConfig.deviceIsAboveAverage()) { + return true; + } + int devicePerformanceClass = Math.max(SharedConfig.getDevicePerformanceClass(), SharedConfig.getLegacyDevicePerformanceClass()); + if (devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_HIGH) { + return true; + } + int hash = (Build.MANUFACTURER + " " + Build.DEVICE).toUpperCase().hashCode(); + for (int i = 0; i < ALLOW_BIG_CAMERA_WHITELIST.length; ++i) { + if (ALLOW_BIG_CAMERA_WHITELIST[i] == hash) { + return true; + } + } + return false; + } + + public static boolean allowBigSizeCameraDebug() { int devicePerformanceClass = Math.max(SharedConfig.getDevicePerformanceClass(), SharedConfig.getLegacyDevicePerformanceClass()); if (devicePerformanceClass == SharedConfig.PERFORMANCE_CLASS_HIGH) { return true; @@ -1340,7 +1361,6 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter finish(); return false; } - GL gl = eglContext.getGL(); float tX = 1.0f / scaleX / 2.0f; float tY = 1.0f / scaleY / 2.0f; @@ -2090,16 +2110,25 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter } videoLast = timestampNanos; - GLES20.glUseProgram(drawProgram); - GLES20.glUniformMatrix4fv(vertexMatrixHandle, 1, false, mMVPMatrix, 0); + FloatBuffer textureBuffer = InstantCameraView.this.textureBuffer; + FloatBuffer vertexBuffer = InstantCameraView.this.vertexBuffer; + FloatBuffer oldTextureBuffer = oldTextureTextureBuffer; + if (textureBuffer == null || vertexBuffer == null) { + FileLog.d("handleVideoFrameAvailable skip frame " + textureBuffer + " " + vertexBuffer); + return; + } + GLES20.glUseProgram(drawProgram); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); + GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer); GLES20.glEnableVertexAttribArray(positionHandle); + GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer); GLES20.glEnableVertexAttribArray(textureHandle); + GLES20.glUniformMatrix4fv(vertexMatrixHandle, 1, false, mMVPMatrix, 0); GLES20.glUniform2f(resolutionHandle, videoWidth, videoHeight); - if (oldCameraTexture[0] != 0 && oldTextureTextureBuffer != null) { + if (oldCameraTexture[0] != 0 && oldTextureBuffer != null) { if (!blendEnabled) { GLES20.glEnable(GLES20.GL_BLEND); blendEnabled = true; @@ -2107,7 +2136,7 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter if (oldTexturePreviewSize != null) { GLES20.glUniform2f(previewSizeHandle, oldTexturePreviewSize.getWidth(), oldTexturePreviewSize.getHeight()); } - GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, oldTextureTextureBuffer); + GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, oldTextureBuffer); GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, moldSTMatrix, 0); GLES20.glUniform1f(alphaHandle, 1.0f); @@ -2115,14 +2144,10 @@ public class InstantCameraView extends FrameLayout implements NotificationCenter GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4); } - if (previewSize != null) { GLES20.glUniform2f(previewSizeHandle, previewSize.getWidth(), previewSize.getHeight()); } - GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer); - GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer); - GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, mSTMatrix, 0); GLES20.glUniform1f(alphaHandle, cameraTextureAlpha); GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexture[0]); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java index 7df0ad428..badfd965c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProfileGalleryView.java @@ -902,17 +902,33 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio } ImageLocation location = ImageLocation.getForPhoto(sizeFull, photo); if (location != null) { - if (prevImageLocation != null && prevImageLocation.photoId == location.photoId) { + if (prevImageLocation != null && prevImageLocation.photoId == location.photoId && !isProfileFragment && dialogId != UserConfig.getInstance(currentAccount).getClientUserId()) { thumbsFileNames.add(null); - videoFileNames.add(null); + imagesLocations.add(prevImageLocation); ImageLocation thumbLocation = prevThumbLocation; if (thumbLocation == null) { thumbLocation = ImageLocation.getForPhoto(sizeThumb, photo); } thumbsLocations.add(thumbLocation); - vectorAvatars.add(prevVectorAvatarThumbDrawable); - videoLocations.add(null); + + if (!photo.video_sizes.isEmpty()) { + final TLRPC.VideoSize videoSize = FileLoader.getClosestVideoSizeWithSize(photo.video_sizes, 1000); + final TLRPC.VideoSize vectorMarkupVideoSize = FileLoader.getVectorMarkupVideoSize(photo); + if (vectorMarkupVideoSize != null) { + vectorAvatars.add(new VectorAvatarThumbDrawable(vectorMarkupVideoSize, user != null && user.premium, VectorAvatarThumbDrawable.TYPE_PROFILE)); + videoLocations.add(null); + videoFileNames.add(null); + } else { + vectorAvatars.add(null); + videoLocations.add(ImageLocation.getForPhoto(videoSize, photo)); + videoFileNames.add(FileLoader.getAttachFileName(videoSize)); + } + } else { + vectorAvatars.add(prevVectorAvatarThumbDrawable); + videoLocations.add(null); + videoFileNames.add(null); + } photos.add(null); imagesLocationsSizes.add(-1); imagesUploadProgress.add(null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ChatSelectionReactionMenuOverlay.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ChatSelectionReactionMenuOverlay.java index 28298b7cd..9926104d1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ChatSelectionReactionMenuOverlay.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ChatSelectionReactionMenuOverlay.java @@ -303,7 +303,7 @@ public class ChatSelectionReactionMenuOverlay extends FrameLayout { boolean visible = false; - if (parentFragment.getCurrentChatInfo() != null && parentFragment.getCurrentChatInfo().available_reactions instanceof TLRPC.TL_chatReactionsNone) { + if (parentFragment.isSecretChat() || parentFragment.getCurrentChatInfo() != null && parentFragment.getCurrentChatInfo().available_reactions instanceof TLRPC.TL_chatReactionsNone) { visible = false; } else if (!messages.isEmpty()) { visible = true; @@ -373,6 +373,14 @@ public class ChatSelectionReactionMenuOverlay extends FrameLayout { } } + public boolean onBackPressed() { + if (reactionsContainerLayout != null && reactionsContainerLayout.getReactionsWindow() != null) { + reactionsContainerLayout.dismissWindow(); + return false; + } + return true; + } + public void setHiddenByScroll(boolean hiddenByScroll) { this.hiddenByScroll = hiddenByScroll; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/CustomEmojiReactionsWindow.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/CustomEmojiReactionsWindow.java index d3bd631b7..954eb7cab 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/CustomEmojiReactionsWindow.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/CustomEmojiReactionsWindow.java @@ -446,7 +446,7 @@ public class CustomEmojiReactionsWindow { }); } - private void dismiss() { + public void dismiss() { if (dismissed) { return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java index e41654f2e..c2afa1a11 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java @@ -494,6 +494,14 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio } } + public void dismissWindow() { + reactionsWindow.dismiss(); + } + + public CustomEmojiReactionsWindow getReactionsWindow() { + return reactionsWindow; + } + private void showCustomEmojiReactionDialog() { if (reactionsWindow != null) { return; @@ -1363,7 +1371,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio if (currentReaction.emojicon != null) { TLRPC.TL_availableReaction defaultReaction = MediaDataController.getInstance(currentAccount).getReactionsMap().get(currentReaction.emojicon); if (defaultReaction != null) { - SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(defaultReaction.activate_animation, Theme.key_windowBackgroundWhiteGrayIcon, 1.0f); + SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(defaultReaction.activate_animation, Theme.key_windowBackgroundWhiteGrayIcon, 0.2f); if (!LiteMode.isEnabled(LiteMode.FLAG_ANIMATED_EMOJI_REACTIONS)) { if (SharedConfig.getDevicePerformanceClass() <= SharedConfig.PERFORMANCE_CLASS_LOW) { loopImageView.getImageReceiver().setImage(ImageLocation.getForDocument(defaultReaction.select_animation), "60_60_firstframe", null, null, hasEnterAnimation ? null : svgThumb, 0, "tgs", currentReaction, 0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java index 90a485861..eb299f468 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ShareAlert.java @@ -2022,6 +2022,10 @@ public class ShareAlert extends BottomSheet implements NotificationCenter.Notifi } + protected boolean doSend(LongSparseArray dids, TLRPC.TL_forumTopic topic) { + return false; + } + private int getCurrentTop() { if (gridView.getChildCount() != 0) { View child = gridView.getChildAt(0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java index bdda008ef..80e4847cc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TranslateButton.java @@ -86,7 +86,13 @@ public class TranslateButton extends FrameLayout { menuView.setImageResource(R.drawable.msg_mini_customize); menuView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_addContact, resourcesProvider), PorterDuff.Mode.MULTIPLY)); menuView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_chat_addContact, resourcesProvider) & 0x19ffffff, Theme.RIPPLE_MASK_ROUNDRECT_6DP)); - menuView.setOnClickListener(e -> onMenuClick()); + menuView.setOnClickListener(e -> { + if (UserConfig.getInstance(currentAccount).isPremium()) { + onMenuClick(); + } else { + onCloseClick(); + } + }); addView(menuView, LayoutHelper.createFrame(32, 32, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 0, 8, 0)); } @@ -94,6 +100,10 @@ public class TranslateButton extends FrameLayout { } + protected void onCloseClick() { + + } + protected void onMenuClick() { TranslateController translateController = MessagesController.getInstance(currentAccount).getTranslateController(); @@ -303,7 +313,6 @@ public class TranslateButton extends FrameLayout { } textView.setText(TextUtils.concat(translateIcon, " ", text)); } - - menuView.setVisibility(UserConfig.getInstance(currentAccount).isPremium() ? VISIBLE : GONE); + menuView.setImageResource(UserConfig.getInstance(currentAccount).isPremium() ? R.drawable.msg_mini_customize : R.drawable.msg_close); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilersTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilersTextView.java index 8ecc3b510..df9c9e28c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilersTextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilersTextView.java @@ -124,6 +124,12 @@ public class SpoilersTextView extends TextView { } } + @Override + protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + super.onLayout(changed, left, top, right, bottom); + invalidateSpoilers(); + } + private void invalidateSpoilers() { if (spoilers == null) return; // Check for a super constructor spoilersPool.addAll(spoilers); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java index b7db929c5..13974175a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContentPreviewViewer.java @@ -394,7 +394,7 @@ public class ContentPreviewViewer { ActionBarPopupWindow.ActionBarPopupWindowLayout previewMenu = new ActionBarPopupWindow.ActionBarPopupWindowLayout(containerView.getContext(), R.drawable.popup_fixed_alert2, resourcesProvider); View.OnClickListener onItemClickListener = v -> { - if (parentActivity == null) { + if (parentActivity == null || delegate == null) { return; } int which = (int) v.getTag(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 64cde3997..5b8575c9b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -1082,7 +1082,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. public boolean onTouchEvent(MotionEvent ev) { if (parentLayout != null && filterTabsView != null && !filterTabsView.isEditing() && !searching && !rightSlidingDialogContainer.hasFragment() && !parentLayout.checkTransitionAnimation() && !parentLayout.isInPreviewMode() && !parentLayout.isPreviewOpenAnimationInProgress() && !parentLayout.getDrawerLayoutContainer().isDrawerOpened() && - (ev == null || startedTracking || ev.getY() > actionBar.getMeasuredHeight() + actionBar.getTranslationY()) && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS) { + (ev == null || startedTracking || ev.getY() > actionBar.getMeasuredHeight() + actionBar.getTranslationY()) && (SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS || SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_ARCHIVE && viewPages[0] != null && (viewPages[0].dialogsAdapter.getDialogsType() == 7 || viewPages[0].dialogsAdapter.getDialogsType() == 8))) { if (ev != null) { if (velocityTracker == null) { velocityTracker = VelocityTracker.obtain(); @@ -2001,7 +2001,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. swipeFolderBack = false; return makeMovementFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0); } else { - if ((filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS) || !allowSwipeDuringCurrentTouch || ((dialogId == getUserConfig().clientUserId || dialogId == 777000) && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_ARCHIVE) || getMessagesController().isPromoDialog(dialogId, false) && getMessagesController().promoDialogType != MessagesController.PROMO_TYPE_PSA) { + int currentDialogsType = initialDialogsType; + try { + currentDialogsType = parentPage.dialogsAdapter.getDialogsType(); + } catch (Exception ignore) {} + if ((filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_FOLDERS) || !allowSwipeDuringCurrentTouch || ((dialogId == getUserConfig().clientUserId || dialogId == 777000 || currentDialogsType == 7 || currentDialogsType == 8) && SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_ARCHIVE) || getMessagesController().isPromoDialog(dialogId, false) && getMessagesController().promoDialogType != MessagesController.PROMO_TYPE_PSA) { return 0; } boolean canSwipeBack = folderId == 0 && (SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_MUTE || SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_READ || SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_PIN || SharedConfig.getChatSwipeAction(currentAccount) == SwipeGestureSettingsView.SWIPE_GESTURE_DELETE) && !rightSlidingDialogContainer.hasFragment(); @@ -2133,6 +2137,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. cell.checkCurrentDialogIndex(true); cell.animateArchiveAvatar(); } + AndroidUtilities.runOnUIThread(() -> setDialogsListFrozen(false), 300); } SharedPreferences preferences = MessagesController.getGlobalMainSettings(); boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden; @@ -2992,8 +2997,29 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. linearLayout.setMinimumWidth(AndroidUtilities.dp(200)); linearLayout.setOrientation(LinearLayout.VERTICAL); - scrimPopupWindowItems = new ActionBarMenuSubItem[3]; - for (int a = 0, N = (tabView.getId() == filterTabsView.getDefaultTabId() ? 2 : 3); a < N; a++) { + scrimPopupWindowItems = new ActionBarMenuSubItem[4]; + + + boolean defaultTab = tabView.getId() == filterTabsView.getDefaultTabId(); + boolean hasUnread = false; + + + ArrayList dialogs = new ArrayList<>(defaultTab ? getMessagesController().getDialogs(folderId) : getMessagesController().getAllDialogs()); + if (!defaultTab) { + MessagesController.DialogFilter filter = getMessagesController().dialogFilters.get(tabView.getId()); + for (int i = 0; i < dialogs.size(); i++) { + if (!filter.includesDialog(getAccountInstance(), dialogs.get(i).id)) { + dialogs.remove(i); + i--; + } + } + } + for (int i = 0; i < dialogs.size(); i++) { + if (dialogs.get(i).unread_mark || dialogs.get(i).unread_count > 0) { + hasUnread = true; + } + } + for (int a = 0, N = 2 + (!defaultTab ? 1 : 0) + (hasUnread ? 1 : 0); a < N; a++) { ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1); if (a == 0) { if (getMessagesController().dialogFilters.size() <= 1) { @@ -3001,28 +3027,33 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder); } else if (a == 1) { - if (N == 2) { + if (defaultTab) { cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.msg_edit); } else { cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.msg_edit); } + } else if (a == 2 && hasUnread) { + cell.setTextAndIcon(LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead), R.drawable.msg_markread); } else { cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.msg_delete); } scrimPopupWindowItems[a] = cell; linearLayout.addView(cell); final int i = a; + boolean finalHasUnread = hasUnread; cell.setOnClickListener(v1 -> { if (i == 0) { resetScroll(); filterTabsView.setIsEditing(true); showDoneItem(true); } else if (i == 1) { - if (N == 2) { + if (defaultTab) { presentFragment(new FiltersSetupActivity()); } else { presentFragment(new FilterCreateActivity(dialogFilter)); } + } else if (i == 2 && finalHasUnread) { + markDialogsAsRead(dialogs); } else if (i == 2) { showDeleteAlert(dialogFilter); } @@ -7727,6 +7758,28 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. getMessagesController().markDialogAsUnread(did, null, 0); } + private void markDialogsAsRead(ArrayList dialogs) { + debugLastUpdateAction = 2; + int selectedDialogIndex = -1; + + setDialogsListFrozen(true); + checkAnimationFinished(); + for (int i = 0; i < dialogs.size(); i++) { + long did = dialogs.get(i).id; + TLRPC.Dialog dialog = dialogs.get(i); + if (getMessagesController().isForum(did)) { + getMessagesController().markAllTopicsAsRead(did); + } + getMessagesController().markMentionsAsRead(did, 0); + getMessagesController().markDialogAsRead(did, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, 0, true, 0); + } + if (selectedDialogIndex >= 0) { + frozenDialogsList.remove(selectedDialogIndex); + viewPages[0].dialogsItemAnimator.prepareForRemove(); + viewPages[0].updateList(true); + } + } + private void performDeleteOrClearDialogAction(int action, long selectedDialog, TLRPC.Chat chat, boolean isBot, boolean revoke) { if (action == clear) { getMessagesController().deleteDialog(selectedDialog, 1, revoke); @@ -8062,7 +8115,14 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } else { blockItem.setVisibility(View.VISIBLE); } - if (filterTabsView == null || filterTabsView.getVisibility() != View.VISIBLE || filterTabsView.currentTabIsDefault()) { + boolean cantRemoveFromFolder = filterTabsView == null || filterTabsView.getVisibility() != View.VISIBLE || filterTabsView.currentTabIsDefault(); + if (!cantRemoveFromFolder) { + try { + final int dialogsCount = getDialogsArray(currentAccount, viewPages[0].dialogsAdapter.getDialogsType(), folderId, dialogsListFrozen).size(); + cantRemoveFromFolder = count >= dialogsCount; + } catch (Exception ignore) {} + } + if (cantRemoveFromFolder) { removeFromFolderItem.setVisibility(View.GONE); } else { removeFromFolderItem.setVisibility(View.VISIBLE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java index a98b2f449..dce758794 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCallActivity.java @@ -4811,7 +4811,7 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter containerView.invalidate(); } }; - avatarsViewPager.setImagesLayerNum(8192); + avatarsViewPager.setImagesLayerNum(Integer.MAX_VALUE); avatarsViewPager.setInvalidateWithParent(true); avatarPagerIndicator.setProfileGalleryView(avatarsViewPager); avatarPreviewContainer = new FrameLayout(context) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index 15e7ead31..16fb9dbf0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -12,6 +12,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.SharedPreferences; import android.graphics.Canvas; +import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; @@ -408,6 +409,23 @@ public class LanguageSelectActivity extends BaseFragment implements Notification Collections.sort(unofficialLanguages, comparator); } + private static boolean patching = false; + + @Override + public void onBecomeFullyVisible() { + super.onBecomeFullyVisible(); + boolean shouldPatch = getMessagesController().checkResetLangpack > 0 && !MessagesController.getGlobalMainSettings().getBoolean("langpack_patched", false) && !patching; + if (shouldPatch) { + patching = true; + LocaleController.getInstance().reloadCurrentRemoteLocale(currentAccount, null, true, () -> { + AndroidUtilities.runOnUIThread(() -> { + MessagesController.getGlobalMainSettings().edit().putBoolean("langpack_patched", true).apply(); + updateLanguage(); + }); + }); + } + } + @Override public void onResume() { super.onResume(); @@ -431,7 +449,10 @@ public class LanguageSelectActivity extends BaseFragment implements Notification private void updateLanguage() { if (actionBar != null) { - actionBar.setTitleAnimated(LocaleController.getString("Language", R.string.Language), true, 350, CubicBezierInterpolator.EASE_OUT_QUINT); + String newTitle = LocaleController.getString("Language", R.string.Language); + if (!TextUtils.equals(actionBar.getTitle(), newTitle)) { + actionBar.setTitleAnimated(newTitle, true, 350, CubicBezierInterpolator.EASE_OUT_QUINT); + } } if (listAdapter != null) { listAdapter.notifyItemRangeChanged(0, listAdapter.getItemCount()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index f581d7cd5..1d67b36ba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -73,7 +73,6 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.arch.core.util.Function; import androidx.core.app.ActivityCompat; import androidx.core.content.pm.ShortcutInfoCompat; @@ -2486,6 +2485,12 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati open_settings = 4; } else if (url.contains("change_number")) { open_settings = 5; + } else if (url.contains("?enablelogs")) { + open_settings = 7; + } else if (url.contains("?sendlogs")) { + open_settings = 8; + } else if (url.contains("?disablelogs")) { + open_settings = 9; } else { open_settings = 1; } @@ -2809,6 +2814,27 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati dids.add(MessagesStorage.TopicKey.of(dialogId, 0)); didSelectDialogs(null, dids, null, false, null); } + } else if (open_settings == 7 || open_settings == 8 || open_settings == 9) { + CharSequence bulletinText = null; + boolean can = BuildVars.DEBUG_PRIVATE_VERSION; // TODO: check source + if (!can) { + bulletinText = "Locked in release."; + } else if (open_settings == 7) { + bulletinText = "Logs enabled."; + ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE).edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED = true).commit(); + } else if (open_settings == 8) { + ProfileActivity.sendLogs(LaunchActivity.this, false); + } else if (open_settings == 9) { + bulletinText = "Logs disabled."; + ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE).edit().putBoolean("logsEnabled", BuildVars.LOGS_ENABLED = false).commit(); + } + + if (bulletinText != null) { + BaseFragment fragment = actionBarLayout.getLastFragment(); + if (fragment != null) { + BulletinFactory.of(fragment).createSimpleBulletin(R.raw.info, bulletinText).show(); + } + } } else if (open_settings != 0) { BaseFragment fragment; boolean closePrevious = false; @@ -5408,21 +5434,6 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati } } - @Override - public void onRestoreInstanceState(@Nullable Bundle savedInstanceState) { - super.onRestoreInstanceState(savedInstanceState); - - if (actionBarLayout != null) { - actionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - } - if (rightActionBarLayout != null) { - rightActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - } - if (layersActionBarLayout != null) { - layersActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - } - } - @Override protected void onPause() { super.onPause(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index aaa6c8194..36e107c52 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -54,6 +54,7 @@ import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.PasswordTransformationMethod; import android.text.style.ClickableSpan; +import android.text.style.ForegroundColorSpan; import android.text.style.ImageSpan; import android.text.style.ReplacementSpan; import android.util.Base64; @@ -100,6 +101,7 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.AuthTokensHelper; import org.telegram.messenger.BuildVars; +import org.telegram.messenger.CallReceiver; import org.telegram.messenger.ContactsController; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLog; @@ -1447,6 +1449,10 @@ public class LoginActivity extends BaseFragment { public void setPage(@ViewNumber int page, boolean animated, Bundle params, boolean back) { boolean needFloatingButton = page == VIEW_PHONE_INPUT || page == VIEW_REGISTER || page == VIEW_PASSWORD || page == VIEW_NEW_PASSWORD_STAGE_1 || page == VIEW_NEW_PASSWORD_STAGE_2 || page == VIEW_ADD_EMAIL; + if (page == currentViewNum) { + animated = false; + } + if (needFloatingButton) { if (page == VIEW_PHONE_INPUT) { checkPermissions = true; @@ -1770,6 +1776,8 @@ public class LoginActivity extends BaseFragment { params.putString("emailPattern", res.type.email_pattern); params.putInt("length", res.type.length); params.putInt("nextPhoneLoginDate", res.type.next_phone_login_date); + params.putInt("resetAvailablePeriod", res.type.reset_available_period); + params.putInt("resetPendingDate", res.type.reset_pending_date); setPage(VIEW_CODE_EMAIL, animate, params, false); } } @@ -2987,6 +2995,8 @@ public class LoginActivity extends BaseFragment { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("InvalidCode", R.string.InvalidCode)); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + onBackPressed(true); + setPage(VIEW_PHONE_INPUT, true, null, true); needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("CodeExpired", R.string.CodeExpired)); } else if (error.text.startsWith("FLOOD_WAIT")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("FloodWait", R.string.FloodWait)); @@ -3897,6 +3907,9 @@ public class LoginActivity extends BaseFragment { } else if (currentType == AUTH_TYPE_FLASH_CALL) { AndroidUtilities.setWaitingForCall(true); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall); + AndroidUtilities.runOnUIThread(() -> { + CallReceiver.checkLastReceivedCall(); + }); } currentParams = params; @@ -4653,6 +4666,7 @@ public class LoginActivity extends BaseFragment { AndroidUtilities.endIncomingCall(); } onNextPressed(num); + CallReceiver.clearLastCall(); } } @@ -5433,7 +5447,7 @@ public class LoginActivity extends BaseFragment { requestPhone = currentParams.getString("phoneFormated"); phoneHash = currentParams.getString("phoneHash"); - int v = params.getBoolean("googleSignInAllowed") ? VISIBLE : GONE; + int v = params.getBoolean("googleSignInAllowed") && PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices() ? VISIBLE : GONE; loginOrView.setVisibility(v); signInWithGoogleView.setVisibility(v); @@ -5545,6 +5559,8 @@ public class LoginActivity extends BaseFragment { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("InvalidCode", R.string.InvalidCode)); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + onBackPressed(true); + setPage(VIEW_PHONE_INPUT, true, null, true); needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("CodeExpired", R.string.CodeExpired)); } else if (error.text.startsWith("FLOOD_WAIT")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("FloodWait", R.string.FloodWait)); @@ -5598,14 +5614,19 @@ public class LoginActivity extends BaseFragment { private TextView signInWithGoogleView; private FrameLayout resendFrameLayout; private TextView resendCodeView; + private FrameLayout cantAccessEmailFrameLayout; + private TextView cantAccessEmailView; + private TextView emailResetInView; private TextView wrongCodeView; private LoginOrView loginOrView; private RLottieImageView inboxImageView; + private boolean resetRequestPending; private Bundle currentParams; private boolean nextPressed; private GoogleSignInAccount googleAccount; + private int resetAvailablePeriod, resetPendingDate; private String phone, emailPhone, email; private String requestPhone, phoneHash; private boolean isFromSetup; @@ -5623,9 +5644,11 @@ public class LoginActivity extends BaseFragment { if (errorViewSwitcher.getCurrentView() != resendFrameLayout) { errorViewSwitcher.showNext(); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, resendCodeView.getVisibility() != VISIBLE && activityMode != MODE_CHANGE_LOGIN_EMAIL && !isSetup, 1f, true); } }; private Runnable resendCodeTimeout = () -> showResendCodeView(true); + private Runnable updateResetPendingDateCallback = this::updateResetPendingDate; public LoginActivityEmailCodeView(Context context, boolean setup) { super(context); @@ -5718,6 +5741,83 @@ public class LoginActivity extends BaseFragment { googleClient.signOut().addOnCompleteListener(command -> getParentActivity().startActivityForResult(googleClient.getSignInIntent(), BasePermissionsActivity.REQUEST_CODE_SIGN_IN_WITH_GOOGLE)); }); + cantAccessEmailFrameLayout = new FrameLayout(context); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, activityMode != MODE_CHANGE_LOGIN_EMAIL && !isSetup, 1f, false); + + cantAccessEmailView = new TextView(context) { + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.AT_MOST)); + } + }; + cantAccessEmailView.setText(LocaleController.getString(R.string.LoginCantAccessThisEmail)); + cantAccessEmailView.setGravity(Gravity.CENTER); + cantAccessEmailView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + cantAccessEmailView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16)); + cantAccessEmailView.setMaxLines(2); + cantAccessEmailView.setOnClickListener(v -> { + String rawPattern = currentParams.getString("emailPattern"); + SpannableStringBuilder email = new SpannableStringBuilder(rawPattern); + int startIndex = rawPattern.indexOf('*'), endIndex = rawPattern.lastIndexOf('*'); + if (startIndex != endIndex && startIndex != -1 && endIndex != -1) { + TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun(); + run.flags |= TextStyleSpan.FLAG_STYLE_SPOILER; + run.start = startIndex; + run.end = endIndex + 1; + email.setSpan(new TextStyleSpan(run), startIndex, endIndex + 1, 0); + } + + new AlertDialog.Builder(context) + .setTitle(LocaleController.getString(R.string.LoginEmailResetTitle)) + .setMessage(AndroidUtilities.formatSpannable(AndroidUtilities.replaceTags(LocaleController.getString(R.string.LoginEmailResetMessage)), email, getTimePattern(resetAvailablePeriod))) + .setPositiveButton(LocaleController.getString(R.string.LoginEmailResetButton), (dialog, which) -> { + Bundle params = new Bundle(); + params.putString("phone", phone); + params.putString("ephone", emailPhone); + params.putString("phoneFormated", requestPhone); + + TLRPC.TL_auth_resetLoginEmail req = new TLRPC.TL_auth_resetLoginEmail(); + req.phone_number = requestPhone; + req.phone_code_hash = phoneHash; + getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { + if (response instanceof TLRPC.TL_auth_sentCode) { + TLRPC.TL_auth_sentCode sentCode = (TLRPC.TL_auth_sentCode) response; + if (sentCode.type instanceof TLRPC.TL_auth_sentCodeTypeEmailCode) { + sentCode.type.email_pattern = currentParams.getString("emailPattern"); + resetRequestPending = true; + } + fillNextCodeParams(params, sentCode); + } else if (error != null && error.text != null) { + if (error.text.contains("PHONE_CODE_EXPIRED")) { + onBackPressed(true); + setPage(VIEW_PHONE_INPUT, true, null, true); + needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("CodeExpired", R.string.CodeExpired)); + } else { + AlertsCreator.processError(currentAccount, error, LoginActivity.this, req); + } + } + }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); + }) + .setNegativeButton(LocaleController.getString(R.string.Cancel), null) + .show(); + }); + cantAccessEmailFrameLayout.addView(cantAccessEmailView); + + emailResetInView = new TextView(context) { + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Math.max(MeasureSpec.getSize(heightMeasureSpec), AndroidUtilities.dp(100)), MeasureSpec.AT_MOST)); + } + }; + emailResetInView.setGravity(Gravity.CENTER); + emailResetInView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + emailResetInView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); + emailResetInView.setMaxLines(3); + emailResetInView.setOnClickListener(v -> requestEmailReset()); + emailResetInView.setPadding(0, AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16)); + emailResetInView.setVisibility(GONE); + cantAccessEmailFrameLayout.addView(emailResetInView); + resendCodeView = new TextView(context); resendCodeView.setGravity(Gravity.CENTER); resendCodeView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); @@ -5780,20 +5880,59 @@ public class LoginActivity extends BaseFragment { wrongCodeView.setLineSpacing(AndroidUtilities.dp(2), 1.0f); wrongCodeView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); wrongCodeView.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); - wrongCodeView.setPadding(0, AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4)); + wrongCodeView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16)); errorViewSwitcher.addView(wrongCodeView); FrameLayout bottomContainer = new FrameLayout(context); if (setup) { bottomContainer.addView(errorViewSwitcher, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 32)); } else { - bottomContainer.addView(errorViewSwitcher, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP, 0, 8, 0, 0)); + bottomContainer.addView(errorViewSwitcher, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP)); + bottomContainer.addView(cantAccessEmailFrameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP)); bottomContainer.addView(loginOrView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.CENTER, 0, 0, 0, 16)); bottomContainer.addView(signInWithGoogleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 16)); } addView(bottomContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 0, 1f)); } + private boolean requestingEmailReset; + private void requestEmailReset() { + if (requestingEmailReset) { + return; + } + requestingEmailReset = true; + + Bundle params = new Bundle(); + params.putString("phone", phone); + params.putString("ephone", emailPhone); + params.putString("phoneFormated", requestPhone); + + TLRPC.TL_auth_resetLoginEmail req = new TLRPC.TL_auth_resetLoginEmail(); + req.phone_number = requestPhone; + req.phone_code_hash = phoneHash; + getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { + requestingEmailReset = false; + if (response instanceof TLRPC.TL_auth_sentCode) { + TLRPC.TL_auth_sentCode sentCode = (TLRPC.TL_auth_sentCode) response; + fillNextCodeParams(params, sentCode); + } else if (error != null && error.text != null) { + if (error.text.contains("TASK_ALREADY_EXISTS")) { + new AlertDialog.Builder(getContext()) + .setTitle(LocaleController.getString(R.string.LoginEmailResetPremiumRequiredTitle)) + .setMessage(AndroidUtilities.replaceTags(LocaleController.formatString(R.string.LoginEmailResetPremiumRequiredMessage, LocaleController.addNbsp(PhoneFormat.getInstance().format("+" + requestPhone))))) + .setPositiveButton(LocaleController.getString(R.string.OK), null) + .show(); + } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + onBackPressed(true); + setPage(VIEW_PHONE_INPUT, true, null, true); + needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("CodeExpired", R.string.CodeExpired)); + } else { + AlertsCreator.processError(currentAccount, error, LoginActivity.this, req); + } + } + }), ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); + } + @Override public void updateColors() { titleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); @@ -5801,6 +5940,8 @@ public class LoginActivity extends BaseFragment { signInWithGoogleView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)); loginOrView.updateColors(); resendCodeView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)); + cantAccessEmailView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4)); + emailResetInView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6)); wrongCodeView.setTextColor(Theme.getColor(Theme.key_dialogTextRed)); codeFieldContainer.invalidate(); @@ -5815,6 +5956,7 @@ public class LoginActivity extends BaseFragment { private void showResendCodeView(boolean show) { AndroidUtilities.updateViewVisibilityAnimated(resendCodeView, show); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, !show && activityMode != MODE_CHANGE_LOGIN_EMAIL && !isSetup); if (loginOrView.getVisibility() != GONE) { loginOrView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.CENTER, 0, 0, 0, show ? 8 : 16)); @@ -5851,11 +5993,23 @@ public class LoginActivity extends BaseFragment { isFromSetup = currentParams.getBoolean("setup"); length = currentParams.getInt("length"); email = currentParams.getString("email"); + resetAvailablePeriod = currentParams.getInt("resetAvailablePeriod"); + resetPendingDate = currentParams.getInt("resetPendingDate"); if (activityMode == MODE_CHANGE_LOGIN_EMAIL) { confirmTextView.setText(LocaleController.formatString(R.string.CheckYourNewEmailSubtitle, email)); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, false, 1f, false); } else if (isSetup) { confirmTextView.setText(LocaleController.formatString(R.string.VerificationCodeSubtitle, email)); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, false, 1f, false); + } else { + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, true, 1f, false); + + cantAccessEmailView.setVisibility(resetPendingDate == 0 ? VISIBLE : GONE); + emailResetInView.setVisibility(resetPendingDate != 0 ? VISIBLE : GONE); + if (resetPendingDate != 0) { + updateResetPendingDate(); + } } codeFieldContainer.setNumbersCount(length, AUTH_TYPE_MESSAGE); @@ -5900,7 +6054,7 @@ public class LoginActivity extends BaseFragment { confirmTextView.setText(AndroidUtilities.formatSpannable(LocaleController.getString(R.string.CheckYourEmailSubtitle), confirmText)); } - int v = params.getBoolean("googleSignInAllowed") ? VISIBLE : GONE; + int v = params.getBoolean("googleSignInAllowed") && PushListenerController.GooglePushListenerServiceProvider.INSTANCE.hasServices() ? VISIBLE : GONE; loginOrView.setVisibility(v); signInWithGoogleView.setVisibility(v); @@ -5910,6 +6064,81 @@ public class LoginActivity extends BaseFragment { if (!restore && params.containsKey("nextType")) { AndroidUtilities.runOnUIThread(resendCodeTimeout, params.getInt("timeout")); } + + if (resetPendingDate != 0) { + AndroidUtilities.runOnUIThread(updateResetPendingDateCallback, 1000); + } + } + + @Override + public void onHide() { + super.onHide(); + + if (resetPendingDate != 0) { + AndroidUtilities.cancelRunOnUIThread(updateResetPendingDateCallback); + } + } + + private String getTimePatternForTimer(int timeRemaining) { + int days = timeRemaining / 86400; + int hours = (timeRemaining % 86400) / 3600; + int minutes = ((timeRemaining % 86400) % 3600) / 60; + int seconds = ((timeRemaining % 86400) % 3600) % 60; + + String time; + if (days != 0) { + time = LocaleController.formatString(R.string.LoginEmailResetInSinglePattern, LocaleController.formatPluralString("Days", days)); + } else { + String timer = (hours != 0 ? String.format(Locale.ROOT, "%02d:", hours) : "") + String.format(Locale.ROOT, "%02d:", minutes) + String.format(Locale.ROOT, "%02d", seconds); + time = LocaleController.formatString(R.string.LoginEmailResetInSinglePattern, timer); + } + return time; + } + + private String getTimePattern(int timeRemaining) { + int days = timeRemaining / 86400; + int hours = (timeRemaining % 86400) / 3600; + int minutes = ((timeRemaining % 86400) % 3600) / 60; + + if (days == 0 && hours == 0) { + minutes = Math.max(1, minutes); + } + + String time; + if (days != 0 && hours != 0) { + time = LocaleController.formatString(R.string.LoginEmailResetInDoublePattern, LocaleController.formatPluralString("Days", days), LocaleController.formatPluralString("Hours", hours)); + } else if (hours != 0 && minutes != 0) { + time = LocaleController.formatString(R.string.LoginEmailResetInDoublePattern, LocaleController.formatPluralString("Hours", hours), LocaleController.formatPluralString("Minutes", minutes)); + } else if (days != 0) { + time = LocaleController.formatString(R.string.LoginEmailResetInSinglePattern, LocaleController.formatPluralString("Days", days)); + } else if (hours != 0) { + time = LocaleController.formatString(R.string.LoginEmailResetInSinglePattern, LocaleController.formatPluralString("Hours", days)); + } else { + time = LocaleController.formatString(R.string.LoginEmailResetInSinglePattern, LocaleController.formatPluralString("Minutes", minutes)); + } + return time; + } + + private void updateResetPendingDate() { + int timeRemaining = (int) (resetPendingDate - System.currentTimeMillis() / 1000L); + if (resetPendingDate <= 0 || timeRemaining <= 0) { + emailResetInView.setVisibility(VISIBLE); + emailResetInView.setText(LocaleController.getString(R.string.LoginEmailResetPleaseWait)); + AndroidUtilities.runOnUIThread(this::requestEmailReset, 1000); + return; + } + String str = LocaleController.formatString(R.string.LoginEmailResetInTime, getTimePatternForTimer(timeRemaining)); + SpannableStringBuilder ssb = SpannableStringBuilder.valueOf(str); + int startIndex = str.indexOf('*'), endIndex = str.lastIndexOf('*'); + if (startIndex != endIndex && startIndex != -1 && endIndex != -1) { + ssb.replace(endIndex, endIndex + 1, ""); + ssb.replace(startIndex, startIndex + 1, ""); + ssb.setSpan(new ForegroundColorSpan(getThemedColor(Theme.key_windowBackgroundWhiteBlueText4)), startIndex, endIndex - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + + emailResetInView.setText(ssb); + + AndroidUtilities.runOnUIThread(updateResetPendingDateCallback, 1000); } private void onPasscodeError(boolean clear) { @@ -6134,6 +6363,7 @@ public class LoginActivity extends BaseFragment { } if (errorViewSwitcher.getCurrentView() == resendFrameLayout) { errorViewSwitcher.showNext(); + AndroidUtilities.updateViewVisibilityAnimated(cantAccessEmailFrameLayout, false, 1f, true); } codeFieldContainer.codeField[0].requestFocus(); AndroidUtilities.shakeViewSpring(codeFieldContainer, 10f, () -> { @@ -6154,6 +6384,10 @@ public class LoginActivity extends BaseFragment { @Override public void onShow() { super.onShow(); + if (resetRequestPending) { + resetRequestPending = false; + return; + } AndroidUtilities.runOnUIThread(() -> { inboxImageView.getAnimatedDrawable().setCurrentFrame(0, false); inboxImageView.playAnimation(); @@ -7420,6 +7654,8 @@ public class LoginActivity extends BaseFragment { } else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("InvalidCode", R.string.InvalidCode)); } else if (error.text.contains("PHONE_CODE_EXPIRED")) { + onBackPressed(true); + setPage(VIEW_PHONE_INPUT, true, null, true); needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("CodeExpired", R.string.CodeExpired)); } else if (error.text.contains("FIRSTNAME_INVALID")) { needShowAlert(LocaleController.getString(R.string.RestorePasswordNoEmailTitle), LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 7dc2eab66..51271bc4d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -183,6 +183,7 @@ import org.telegram.ui.Components.FragmentContextView; import org.telegram.ui.Components.HintView; import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.ImageUpdater; +import org.telegram.ui.Components.InstantCameraView; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LinkSpanDrawable; import org.telegram.ui.Components.Premium.GiftPremiumBottomSheet; @@ -3347,7 +3348,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. BuildVars.DEBUG_PRIVATE_VERSION ? LocaleController.getString(SharedConfig.isFloatingDebugActive ? R.string.FloatingDebugDisable : R.string.FloatingDebugEnable) : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Force remove premium suggestions" : null, BuildVars.DEBUG_PRIVATE_VERSION ? "Share device info" : null, - BuildVars.DEBUG_PRIVATE_VERSION ? "Force performance class" : null + BuildVars.DEBUG_PRIVATE_VERSION ? "Force performance class" : null, + BuildVars.DEBUG_PRIVATE_VERSION && !InstantCameraView.allowBigSizeCameraDebug() ? (!SharedConfig.bigCameraForRound ? "Force big camera for round" : "Disable big camera for round") : null }; builder.setItems(items, (dialog, which) -> { @@ -3552,6 +3554,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); builder2.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder2.show(); + } else if (which == 21) { + SharedConfig.toggleRoundCamera(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java index c8caefff1..1ab0e89e7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SelectAnimatedEmojiDialog.java @@ -4121,7 +4121,7 @@ public class SelectAnimatedEmojiDialog extends FrameLayout implements Notificati if (categoriesListView != null || getContext() == null) { return; } - if (type != TYPE_REACTIONS && type != TYPE_EMOJI_STATUS && type != TYPE_AVATAR_CONSTRUCTOR) { + if (type != TYPE_REACTIONS && type != TYPE_SET_DEFAULT_REACTION && type != TYPE_EMOJI_STATUS && type != TYPE_AVATAR_CONSTRUCTOR) { return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java index 9d1af865e..b17b4e393 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StickersActivity.java @@ -667,31 +667,39 @@ public class StickersActivity extends BaseFragment implements NotificationCenter if (currentType == MediaDataController.TYPE_IMAGE) { featuredRow = rowCount++; masksRow = -1; + if (mediaDataController.getArchivedStickersCount(currentType) != 0) { + boolean inserted = archivedRow == -1; + archivedRow = rowCount++; + if (listAdapter != null && inserted) { + listAdapter.notifyItemRangeInserted(archivedRow, 1); + } + } + archivedInfoRow = -1; emojiPacksRow = rowCount++; } else { featuredRow = -1; masksRow = -1; emojiPacksRow = -1; - } - if (mediaDataController.getArchivedStickersCount(currentType) != 0 && currentType != MediaDataController.TYPE_EMOJIPACKS) { - boolean inserted = archivedRow == -1; + if (mediaDataController.getArchivedStickersCount(currentType) != 0 && currentType != MediaDataController.TYPE_EMOJIPACKS) { + boolean inserted = archivedRow == -1; - archivedRow = rowCount++; - archivedInfoRow = currentType == MediaDataController.TYPE_MASK ? rowCount++ : -1; + archivedRow = rowCount++; + archivedInfoRow = currentType == MediaDataController.TYPE_MASK ? rowCount++ : -1; - if (listAdapter != null && inserted) { - listAdapter.notifyItemRangeInserted(archivedRow, archivedInfoRow != -1 ? 2 : 1); - } - } else { - int oldArchivedRow = archivedRow; - int oldArchivedInfoRow = archivedInfoRow; + if (listAdapter != null && inserted) { + listAdapter.notifyItemRangeInserted(archivedRow, archivedInfoRow != -1 ? 2 : 1); + } + } else { + int oldArchivedRow = archivedRow; + int oldArchivedInfoRow = archivedInfoRow; - archivedRow = -1; - archivedInfoRow = -1; + archivedRow = -1; + archivedInfoRow = -1; - if (listAdapter != null && oldArchivedRow != -1) { - listAdapter.notifyItemRangeRemoved(oldArchivedRow, oldArchivedInfoRow != -1 ? 2 : 1); + if (listAdapter != null && oldArchivedRow != -1) { + listAdapter.notifyItemRangeRemoved(oldArchivedRow, oldArchivedInfoRow != -1 ? 2 : 1); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java index ea55a5668..ee874e9fb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemeActivity.java @@ -50,10 +50,8 @@ import androidx.recyclerview.widget.RecyclerView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.BuildVars; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; -import org.telegram.messenger.LiteMode; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessagesController; @@ -87,6 +85,7 @@ import org.telegram.ui.Cells.ThemePreviewMessagesCell; import org.telegram.ui.Cells.ThemeTypeCell; import org.telegram.ui.Cells.ThemesHorizontalListCell; import org.telegram.ui.Components.AlertsCreator; +import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RecyclerListView; @@ -137,6 +136,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No private int customTabsRow; private int directShareRow; private int raiseToSpeakRow; + private int raiseToListenRow; private int sendByEnterRow; private int saveToGalleryOption1Row; private int saveToGalleryOption2Row; @@ -180,6 +180,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No private int themeInfoRow; private int chatBlurRow; private int pauseOnRecordRow; + private int pauseOnMediaRow; private int swipeGestureHeaderRow; private int swipeGestureRow; @@ -485,6 +486,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No int prevThemeAccentListRow = themeAccentListRow; int prevEditThemeRow = editThemeRow; + int prevRaiseToSpeakRow = raiseToSpeakRow; rowCount = 0; contactsReimportRow = -1; @@ -521,6 +523,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No chatListInfoRow = -1; chatBlurRow = -1; pauseOnRecordRow = -1; + pauseOnMediaRow = -1; stickersRow = -1; stickersInfoRow = -1; liteModeRow = -1; @@ -533,6 +536,7 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No directShareRow = -1; enableAnimationsRow = -1; raiseToSpeakRow = -1; + raiseToListenRow = -1; sendByEnterRow = -1; saveToGalleryOption1Row = -1; saveToGalleryOption2Row = -1; @@ -633,8 +637,12 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No customTabsRow = rowCount++; directShareRow = rowCount++; // enableAnimationsRow = rowCount++; - raiseToSpeakRow = rowCount++; + raiseToListenRow = rowCount++; + if (SharedConfig.raiseToListen) { + raiseToSpeakRow = rowCount++; + } sendByEnterRow = rowCount++; + pauseOnMediaRow = rowCount++; pauseOnRecordRow = rowCount++; bluetoothScoRow = rowCount++; // if (SharedConfig.canBlurChat()) { @@ -705,6 +713,12 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No } else if (prevEditThemeRow != -1 && editThemeRow == -1) { listAdapter.notifyItemRemoved(prevEditThemeRow); } + + if (prevRaiseToSpeakRow == -1 && raiseToSpeakRow != -1) { + listAdapter.notifyItemInserted(raiseToSpeakRow); + } else if (prevRaiseToSpeakRow != -1 && raiseToSpeakRow == -1) { + listAdapter.notifyItemRemoved(prevRaiseToSpeakRow); + } } } else { int start = nightTypeInfoRow + 1; @@ -1028,15 +1042,34 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No ((TextCheckCell) view).setChecked(!send); } } else if (position == raiseToSpeakRow) { - SharedConfig.toogleRaiseToSpeak(); + SharedConfig.toggleRaiseToSpeak(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(SharedConfig.raiseToSpeak); } + } else if (position == raiseToListenRow) { + SharedConfig.toggleRaiseToListen(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(SharedConfig.raiseToListen); + } + if (!SharedConfig.raiseToListen && raiseToSpeakRow != -1) { + for (int i = 0; i < listView.getChildCount(); ++i) { + View child = listView.getChildAt(i); + if (child instanceof TextCheckCell && listView.getChildAdapterPosition(child) == raiseToSpeakRow) { + ((TextCheckCell) child).setChecked(false); + } + } + } + updateRows(false); } else if (position == pauseOnRecordRow) { SharedConfig.togglePauseMusicOnRecord(); if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(SharedConfig.pauseMusicOnRecord); } + } else if (position == pauseOnMediaRow) { + SharedConfig.togglePauseMusicOnMedia(); + if (view instanceof TextCheckCell) { + ((TextCheckCell) view).setChecked(SharedConfig.pauseMusicOnMedia); + } } else if (position == distanceRow) { if (getParentActivity() == null) { return; @@ -1274,6 +1307,14 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No presentFragment(new LiteModeSettingsActivity()); } }); + if (currentType == THEME_TYPE_BASIC) { + DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); + itemAnimator.setDurations(350); + itemAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); + itemAnimator.setDelayAnimations(false); + itemAnimator.setSupportsChangeAnimations(false); + listView.setItemAnimator(itemAnimator); + } return fragmentView; } @@ -2254,8 +2295,12 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No textCheckCell.setTextAndCheck(LocaleController.getString("SendByEnter", R.string.SendByEnter), preferences.getBoolean("send_by_enter", false), true); } else if (position == raiseToSpeakRow) { textCheckCell.setTextAndCheck(LocaleController.getString("RaiseToSpeak", R.string.RaiseToSpeak), SharedConfig.raiseToSpeak, true); + } else if (position == raiseToListenRow) { + textCheckCell.setTextAndCheck(LocaleController.getString("RaiseToListen", R.string.RaiseToListen), SharedConfig.raiseToListen, true); } else if (position == pauseOnRecordRow) { textCheckCell.setTextAndCheck(LocaleController.getString(R.string.PauseMusicOnRecord), SharedConfig.pauseMusicOnRecord, true); + } else if (position == pauseOnMediaRow) { + textCheckCell.setTextAndCheck(LocaleController.getString(R.string.PauseMusicOnMedia), SharedConfig.pauseMusicOnMedia, true); } else if (position == customTabsRow) { textCheckCell.setTextAndValueAndCheck(LocaleController.getString("ChromeCustomTabs", R.string.ChromeCustomTabs), LocaleController.getString("ChromeCustomTabsInfo", R.string.ChromeCustomTabsInfo), SharedConfig.customTabs, false, true); } else if (position == directShareRow) { @@ -2377,8 +2422,8 @@ public class ThemeActivity extends BaseFragment implements NotificationCenter.No } else if (position == automaticBrightnessRow) { return TYPE_BRIGHTNESS; } else if (position == scheduleLocationRow || position == enableAnimationsRow || position == sendByEnterRow || - position == raiseToSpeakRow || position == pauseOnRecordRow || position == customTabsRow || - position == directShareRow || position == chatBlurRow) { + position == raiseToSpeakRow || position == raiseToListenRow || position == pauseOnRecordRow || position == customTabsRow || + position == directShareRow || position == chatBlurRow || position == pauseOnMediaRow) { return TYPE_TEXT_CHECK; } else if (position == textSizeRow) { return TYPE_TEXT_SIZE; diff --git a/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java b/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java index 25ec0cc38..b7f9bb04e 100644 --- a/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java +++ b/TMessagesProj/src/main/java/org/webrtc/HardwareVideoEncoderFactory.java @@ -22,6 +22,7 @@ import android.os.Build; import androidx.annotation.Nullable; +import org.telegram.messenger.FileLog; import org.telegram.messenger.voip.Instance; import org.telegram.messenger.voip.VoIPService; @@ -175,6 +176,20 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory { info2 = info; } } + if (info2 == null) { + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < count; ++i) { + MediaCodecInfo info = infos.get(i); + if (info == null || !info.isEncoder()) { + continue; + } + if (MediaCodecUtils.codecSupportsType(info, type)) { + stringBuilder.append(info.getName()).append(", "); + } + } + + FileLog.e("can't create video encoder " + type.mimeType() + ", supported codecs" + stringBuilder); + } return info2; } diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index f3f7d061c..7fe1968b4 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -2287,6 +2287,7 @@ The account was hidden by the user Auto-play media Raise to Speak + Raise to Listen Save to Gallery Sound muted Edit name @@ -6358,4 +6359,16 @@ %s%% Rate up Rate down + Pause music while playing media + Checking + Can\'t access this email? + Email will be reset in %1$s.\n*Reset now via SMS* + %1$s + %1$s and %2$s + Reset Email + You can change your login email if you are logged into Telegram from another device. Otherwise, if you don\'t have access to email %1$s, you can reset this email with an **SMS** code in **%2$s**. + Reset Login Email + Telegram Premium Required + Due to the high cost of SMS in your country, you need a **Telegram Premium** account to immediately reset this email via an SMS code.\n\nYou can ask a friend to gift a Premium subscription for your account **%1$s** + Resetting email, please wait... diff --git a/gradle.properties b/gradle.properties index c4925b122..2b238f9fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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_CODE=3213 -APP_VERSION_NAME=9.5.3 +APP_VERSION_CODE=3227 +APP_VERSION_NAME=9.5.4 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=android RELEASE_KEY_ALIAS=androidkey