diff --git a/TMessagesProj/jni/gifvideo.cpp b/TMessagesProj/jni/gifvideo.cpp
index b65148290..c3bc4ff65 100644
--- a/TMessagesProj/jni/gifvideo.cpp
+++ b/TMessagesProj/jni/gifvideo.cpp
@@ -840,7 +840,7 @@ enum PARAM_NUM {
PARAM_NUM_COUNT = 11,
};
-extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoInfo(JNIEnv *env, jclass clazz,jint sdkVersion, jstring src, jintArray data) {
+extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDrawable_getVideoInfo(JNIEnv *env, jclass clazz, jint sdkVersion, jstring src, jintArray data) {
VideoInfo *info = new VideoInfo();
char const *srcString = env->GetStringUTFChars(src, 0);
diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index be5cda368..1de192a08 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -87,6 +87,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
segments = new ArrayList<>(uri.getPathSegments());
- if (segments.size() > 0 && segments.get(0).equals("s")) {
- segments.remove(0);
- }
- if (segments.size() > 0) {
- if (segments.size() >= 3 && "s".equals(segments.get(1))) {
- return false;
- } else if (segments.size() > 1) {
- return !TextUtils.isEmpty(segments.get(1));
- } else if (segments.size() == 1) {
- return !TextUtils.isEmpty(uri.getQueryParameter("startapp"));
+ String host = uri.getHost().toLowerCase();
+ Matcher prefixMatcher = LaunchActivity.PREFIX_T_ME_PATTERN.matcher(host);
+ boolean isPrefix = prefixMatcher.find();
+ if (host.equals("telegram.me") || host.equals("t.me") || host.equals("telegram.dog") || isPrefix) {
+ ArrayList segments = new ArrayList<>(uri.getPathSegments());
+ if (segments.size() > 0 && segments.get(0).equals("s")) {
+ segments.remove(0);
+ }
+ if (segments.size() > 0) {
+ if (segments.size() >= 3 && "s".equals(segments.get(1))) {
+ return false;
+ } else if (segments.size() > 1) {
+ final String segment = segments.get(1);
+ if (TextUtils.isEmpty(segment)) return false;
+ switch (segment) {
+ case "joinchat":
+ case "login":
+ case "addstickers":
+ case "addemoji":
+ case "msg":
+ case "share":
+ case "confirmphone":
+ case "setlanguage":
+ case "addtheme":
+ case "boost":
+ case "c":
+ case "contact":
+ case "folder":
+ case "addlist":
+ return false;
+ }
+ return true;
+ } else if (segments.size() == 1) {
+ return !TextUtils.isEmpty(uri.getQueryParameter("startapp"));
+ }
}
}
break;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
index e807de748..2e84eb3e1 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
@@ -379,48 +379,50 @@ public class ContactsController extends BaseController {
}
public void checkAppAccount() {
- AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
- try {
- Account[] accounts = am.getAccountsByType("org.telegram.messenger");
- systemAccount = null;
- for (int a = 0; a < accounts.length; a++) {
- Account acc = accounts[a];
- boolean found = false;
- for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) {
- TLRPC.User user = UserConfig.getInstance(b).getCurrentUser();
- if (user != null) {
- if (acc.name.equals("" + user.id)) {
- if (b == currentAccount) {
- systemAccount = acc;
+ systemAccount = null;
+ Utilities.globalQueue.postRunnable(() -> {
+ AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
+ try {
+ Account[] accounts = am.getAccountsByType("org.telegram.messenger");
+ for (int a = 0; a < accounts.length; a++) {
+ Account acc = accounts[a];
+ boolean found = false;
+ for (int b = 0; b < UserConfig.MAX_ACCOUNT_COUNT; b++) {
+ TLRPC.User user = UserConfig.getInstance(b).getCurrentUser();
+ if (user != null) {
+ if (acc.name.equals("" + user.id)) {
+ if (b == currentAccount) {
+ systemAccount = acc;
+ }
+ found = true;
+ break;
}
- found = true;
- break;
}
}
+ if (!found) {
+ try {
+ am.removeAccount(accounts[a], null, null);
+ } catch (Exception ignore) {
+
+ }
+ }
+
}
- if (!found) {
+ } catch (Throwable ignore) {
+
+ }
+ if (getUserConfig().isClientActivated()) {
+ readContacts();
+ if (systemAccount == null) {
try {
- am.removeAccount(accounts[a], null, null);
+ systemAccount = new Account("" + getUserConfig().getClientUserId(), "org.telegram.messenger");
+ am.addAccountExplicitly(systemAccount, "", null);
} catch (Exception ignore) {
}
}
-
}
- } catch (Throwable ignore) {
-
- }
- if (getUserConfig().isClientActivated()) {
- readContacts();
- if (systemAccount == null) {
- try {
- systemAccount = new Account("" + getUserConfig().getClientUserId(), "org.telegram.messenger");
- am.addAccountExplicitly(systemAccount, "", null);
- } catch (Exception ignore) {
-
- }
- }
- }
+ });
}
public void deleteUnknownAppAccounts() {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
index 1f102aaff..f041026ef 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ImageLoader.java
@@ -1103,7 +1103,11 @@ public class ImageLoader {
if ((isAnimatedAvatar(cacheImage.filter) || AUTOPLAY_FILTER.equals(cacheImage.filter)) && !(cacheImage.imageLocation.document instanceof TLRPC.TL_documentEncrypted) && !precache) {
TLRPC.Document document = cacheImage.imageLocation.document instanceof TLRPC.Document ? cacheImage.imageLocation.document : null;
long size = document != null ? cacheImage.size : cacheImage.imageLocation.currentSize;
- fileDrawable = new AnimatedFileDrawable(cacheImage.finalFilePath, fistFrame, notCreateStream ? 0 : size, cacheImage.priority, notCreateStream ? null : document, document == null && !notCreateStream ? cacheImage.imageLocation : null, cacheImage.parentObject, seekTo, cacheImage.currentAccount, false, cacheOptions);
+ int cacheType = document != null ? 1 : 0;
+ if (cacheImage.cacheType > 1) {
+ cacheType = cacheImage.cacheType;
+ }
+ fileDrawable = new AnimatedFileDrawable(cacheImage.finalFilePath, fistFrame, notCreateStream ? 0 : size, cacheImage.priority, notCreateStream ? null : document, document == null && !notCreateStream ? cacheImage.imageLocation : null, cacheImage.parentObject, seekTo, cacheImage.currentAccount, false, 0, 0, cacheOptions, cacheType);
fileDrawable.setIsWebmSticker(MessageObject.isWebM(document) || MessageObject.isVideoSticker(document) || isAnimatedAvatar(cacheImage.filter));
} else {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
index cf62e3a7b..282d92e94 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocaleController.java
@@ -18,27 +18,26 @@ import android.content.res.Configuration;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.text.format.DateFormat;
+import android.util.Log;
import android.util.Xml;
import androidx.annotation.StringRes;
import org.telegram.messenger.time.FastDateFormat;
import org.telegram.ui.Stars.StarsController;
-import org.telegram.ui.Stars.StarsIntroActivity;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.RestrictedLanguagesSelectActivity;
import org.xmlpull.v1.XmlPullParser;
+import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.FileWriter;
import java.text.NumberFormat;
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.format.TextStyle;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
@@ -61,26 +60,291 @@ public class LocaleController {
public static boolean isRTL = false;
public static int nameDisplayOrder = 1;
public static boolean is24HourFormat = false;
- public FastDateFormat formatterDay;
- public FastDateFormat formatterConstDay;
- public FastDateFormat formatterWeek;
- public FastDateFormat formatterWeekLong;
- public FastDateFormat formatterDayMonth;
- public FastDateFormat formatterYear;
- public FastDateFormat formatterYearMax;
- public FastDateFormat formatterStats;
- public FastDateFormat formatterBannedUntil;
- public FastDateFormat formatterBannedUntilThisYear;
- public FastDateFormat chatDate;
- public FastDateFormat chatFullDate;
- public FastDateFormat formatterScheduleDay;
- public FastDateFormat formatterScheduleYear;
- public FastDateFormat formatterMonthYear;
- public FastDateFormat formatterGiveawayCard;
- public FastDateFormat formatterBoostExpired;
- public FastDateFormat formatterGiveawayMonthDay;
- public FastDateFormat formatterGiveawayMonthDayYear;
- public FastDateFormat[] formatterScheduleSend = new FastDateFormat[15];
+
+ private volatile FastDateFormat formatterDay;
+ public FastDateFormat getFormatterDay() {
+ if (formatterDay == null) {
+ synchronized (this) {
+ if (formatterDay == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ String lang = locale.getLanguage();
+ if (lang == null) {
+ lang = "en";
+ }
+ lang = lang.toLowerCase();
+ formatterDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, is24HourFormat ? getStringInternal("formatterDay24H", R.string.formatterDay24H) : getStringInternal("formatterDay12H", R.string.formatterDay12H), is24HourFormat ? "HH:mm" : "h:mm a");
+ }
+ }
+ }
+ return formatterDay;
+ }
+
+ private volatile FastDateFormat formatterConstDay;
+ public FastDateFormat getFormatterConstDay() {
+ if (formatterConstDay == null) {
+ synchronized (this) {
+ if (formatterConstDay == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ String lang = locale.getLanguage();
+ if (lang == null) {
+ lang = "en";
+ }
+ lang = lang.toLowerCase();
+ formatterConstDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, is24HourFormat ? "HH:mm" : "h:mm a", is24HourFormat ? "HH:mm" : "h:mm a");
+ }
+ }
+ }
+ return formatterConstDay;
+ }
+
+ private volatile FastDateFormat formatterWeek;
+ public FastDateFormat getFormatterWeek() {
+ if (formatterWeek == null) {
+ synchronized (this) {
+ if (formatterWeek == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterWeek = createFormatter(locale, getStringInternal("formatterWeek", R.string.formatterWeek), "EEE");
+ }
+ }
+ }
+ return formatterWeek;
+ }
+
+ private volatile FastDateFormat formatterWeekLong;
+ public FastDateFormat getFormatterWeekLong() {
+ if (formatterWeekLong == null) {
+ synchronized (this) {
+ if (formatterWeekLong == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterWeekLong = createFormatter(locale, getStringInternal("formatterWeekLong", R.string.formatterWeekLong), "EEEE");
+ }
+ }
+ }
+ return formatterWeekLong;
+ }
+
+ private volatile FastDateFormat formatterDayMonth;
+ public FastDateFormat getFormatterDayMonth() {
+ if (formatterDayMonth == null) {
+ synchronized (this) {
+ if (formatterDayMonth == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterDayMonth = createFormatter(locale, getStringInternal("formatterMonth", R.string.formatterMonth), "dd MMM");
+ }
+ }
+ }
+ return formatterDayMonth;
+ }
+
+ private volatile FastDateFormat formatterYear;
+ public FastDateFormat getFormatterYear() {
+ if (formatterYear == null) {
+ synchronized (this) {
+ if (formatterYear == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterYear = createFormatter(locale, getStringInternal("formatterYear", R.string.formatterYear), "dd.MM.yy");
+ }
+ }
+ }
+ return formatterYear;
+ }
+
+ private volatile FastDateFormat formatterYearMax;
+ public FastDateFormat getFormatterYearMax() {
+ if (formatterYearMax == null) {
+ synchronized (this) {
+ if (formatterYearMax == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterYearMax = createFormatter(locale, getStringInternal("formatterYearMax", R.string.formatterYearMax), "dd.MM.yyyy");
+ }
+ }
+ }
+ return formatterYearMax;
+ }
+
+ private volatile FastDateFormat formatterStats;
+ public FastDateFormat getFormatterStats() {
+ if (formatterStats == null) {
+ synchronized (this) {
+ if (formatterStats == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterStats = createFormatter(locale, is24HourFormat ? getStringInternal("formatterStats24H", R.string.formatterStats24H) : getStringInternal("formatterStats12H", R.string.formatterStats12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a");
+ }
+ }
+ }
+ return formatterStats;
+ }
+
+ private volatile FastDateFormat formatterBannedUntil;
+ public FastDateFormat getFormatterBannedUntil() {
+ if (formatterBannedUntil == null) {
+ synchronized (this) {
+ if (formatterBannedUntil == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterBannedUntil = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntil24H", R.string.formatterBannedUntil24H) : getStringInternal("formatterBannedUntil12H", R.string.formatterBannedUntil12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a");
+ }
+ }
+ }
+ return formatterBannedUntil;
+ }
+
+ private volatile FastDateFormat formatterBannedUntilThisYear;
+ public FastDateFormat getFormatterBannedUntilThisYear() {
+ if (formatterBannedUntilThisYear == null) {
+ synchronized (this) {
+ if (formatterBannedUntilThisYear == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterBannedUntilThisYear = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntilThisYear24H", R.string.formatterBannedUntilThisYear24H) : getStringInternal("formatterBannedUntilThisYear12H", R.string.formatterBannedUntilThisYear12H), is24HourFormat ? "MMM dd, HH:mm" : "MMM dd, h:mm a");
+ }
+ }
+ }
+ return formatterBannedUntilThisYear;
+ }
+
+ private volatile FastDateFormat chatDate;
+ public FastDateFormat getChatDate() {
+ if (chatDate == null) {
+ synchronized (this) {
+ if (chatDate == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ chatDate = createFormatter(locale, getStringInternal("chatDate", R.string.chatDate), "d MMMM");
+ }
+ }
+ }
+ return chatDate;
+ }
+
+ private volatile FastDateFormat chatFullDate;
+ public FastDateFormat getChatFullDate() {
+ if (chatFullDate == null) {
+ synchronized (this) {
+ if (chatFullDate == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ chatFullDate = createFormatter(locale, getStringInternal("chatFullDate", R.string.chatFullDate), "d MMMM yyyy");
+ }
+ }
+ }
+ return chatFullDate;
+ }
+
+ private volatile FastDateFormat formatterScheduleDay;
+ public FastDateFormat getFormatterScheduleDay() {
+ if (formatterScheduleDay == null) {
+ synchronized (this) {
+ if (formatterScheduleDay == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterScheduleDay = createFormatter(locale, getStringInternal("formatDateSchedule", R.string.formatDateSchedule), "MMM d");
+ }
+ }
+ }
+ return formatterScheduleDay;
+ }
+
+ private volatile FastDateFormat formatterScheduleYear;
+ public FastDateFormat getFormatterScheduleYear() {
+ if (formatterScheduleYear == null) {
+ synchronized (this) {
+ if (formatterScheduleYear == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterScheduleYear = createFormatter(locale, getStringInternal("formatDateScheduleYear", R.string.formatDateScheduleYear), "MMM d yyyy");
+ }
+ }
+ }
+ return formatterScheduleYear;
+ }
+
+ private volatile FastDateFormat formatterMonthYear;
+ public FastDateFormat getFormatterMonthYear() {
+ if (formatterMonthYear == null) {
+ synchronized (this) {
+ if (formatterMonthYear == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterMonthYear = createFormatter(locale, getStringInternal("formatterMonthYear", R.string.formatterMonthYear), "MMM yyyy");
+ }
+ }
+ }
+ return formatterMonthYear;
+ }
+
+ private volatile FastDateFormat formatterGiveawayCard;
+ public FastDateFormat getFormatterGiveawayCard() {
+ if (formatterGiveawayCard == null) {
+ synchronized (this) {
+ if (formatterGiveawayCard == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterGiveawayCard = createFormatter(locale, getStringInternal("formatterGiveawayCard", R.string.formatterGiveawayCard), "dd MMM yyyy");
+ }
+ }
+ }
+ return formatterGiveawayCard;
+ }
+
+ private volatile FastDateFormat formatterBoostExpired;
+ public FastDateFormat getFormatterBoostExpired() {
+ if (formatterBoostExpired == null) {
+ synchronized (this) {
+ if (formatterBoostExpired == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterBoostExpired = createFormatter(locale, getStringInternal("formatterBoostExpired", R.string.formatterBoostExpired), "MMM dd, yyyy");
+ }
+ }
+ }
+ return formatterBoostExpired;
+ }
+
+ private volatile FastDateFormat formatterGiveawayMonthDay;
+ public FastDateFormat getFormatterGiveawayMonthDay() {
+ if (formatterGiveawayMonthDay == null) {
+ synchronized (this) {
+ if (formatterGiveawayMonthDay == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterGiveawayMonthDay = createFormatter(locale, getStringInternal("formatterGiveawayMonthDay", R.string.formatterGiveawayMonthDay), "MMMM dd");
+ }
+ }
+ }
+ return formatterGiveawayMonthDay;
+ }
+
+ private volatile FastDateFormat formatterGiveawayMonthDayYear;
+ public FastDateFormat getFormatterGiveawayMonthDayYear() {
+ if (formatterGiveawayMonthDayYear == null) {
+ synchronized (this) {
+ if (formatterGiveawayMonthDayYear == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ formatterGiveawayMonthDayYear = createFormatter(locale, getStringInternal("formatterGiveawayMonthDayYear", R.string.formatterGiveawayMonthDayYear), "MMMM dd, yyyy");
+ }
+ }
+ }
+ return formatterGiveawayMonthDayYear;
+ }
+
+ private final FastDateFormat[] formatterScheduleSend = new FastDateFormat[15];
+ public FastDateFormat getFormatterScheduleSend(int n) {
+ if (n < 0 || n >= formatterScheduleSend.length)
+ return null;
+ if (formatterScheduleSend[n] == null) {
+ final Locale locale = currentLocale == null ? Locale.getDefault() : currentLocale;
+ switch (n) {
+ case 0: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("SendTodayAt", R.string.SendTodayAt), "'Send today at' HH:mm"); break;
+ case 1: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("SendDayAt", R.string.SendDayAt), "'Send on' MMM d 'at' HH:mm"); break;
+ case 2: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("SendDayYearAt", R.string.SendDayYearAt), "'Send on' MMM d yyyy 'at' HH:mm"); break;
+ case 3: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("RemindTodayAt", R.string.RemindTodayAt), "'Remind today at' HH:mm"); break;
+ case 4: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("RemindDayAt", R.string.RemindDayAt), "'Remind on' MMM d 'at' HH:mm"); break;
+ case 5: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("RemindDayYearAt", R.string.RemindDayYearAt), "'Remind on' MMM d yyyy 'at' HH:mm"); break;
+ case 6: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartTodayAt", R.string.StartTodayAt), "'Start today at' HH:mm"); break;
+ case 7: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartDayAt", R.string.StartDayAt), "'Start on' MMM d 'at' HH:mm"); break;
+ case 8: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartDayYearAt", R.string.StartDayYearAt), "'Start on' MMM d yyyy 'at' HH:mm"); break;
+ case 9: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartShortTodayAt", R.string.StartShortTodayAt), "'Today,' HH:mm"); break;
+ case 10: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartShortDayAt", R.string.StartShortDayAt), "MMM d',' HH:mm"); break;
+ case 11: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartShortDayYearAt", R.string.StartShortDayYearAt), "MMM d yyyy, HH:mm"); break;
+ case 12: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartsTodayAt", R.string.StartsTodayAt), "'Starts today at' HH:mm"); break;
+ case 13: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartsDayAt", R.string.StartsDayAt), "'Starts on' MMM d 'at' HH:mm"); break;
+ case 14: formatterScheduleSend[n] = createFormatter(locale, getStringInternal("StartsDayYearAt", R.string.StartsDayYearAt), "'Starts on' MMM d yyyy 'at' HH:mm"); break;
+ }
+ }
+ return formatterScheduleSend[n];
+ }
+
private static HashMap resourcesCacheMap = new HashMap<>();
@@ -105,7 +369,7 @@ public class LocaleController {
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.applicationHandler.post(() -> {
- if (!formatterDayMonth.getTimeZone().equals(TimeZone.getDefault())) {
+ if (!getFormatterDayMonth().getTimeZone().equals(TimeZone.getDefault())) {
LocaleController.getInstance().recreateFormatters();
}
});
@@ -862,7 +1126,7 @@ public class LocaleController {
if (!file.exists()) {
return new HashMap<>();
}
- HashMap stringMap = new HashMap<>();
+ HashMap stringMap = new HashMap<>(10_000);
XmlPullParser parser = Xml.newPullParser();
//AndroidUtilities.copyFile(file, new File(ApplicationLoader.applicationContext.getExternalFilesDir(null), "locale10.xml"));
stream = new FileInputStream(file);
@@ -1649,9 +1913,9 @@ public class LocaleController {
calendar.setTimeInMillis(date);
if (checkYear && currentYear == calendar.get(Calendar.YEAR) || !checkYear && Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return getInstance().chatDate.format(date);
+ return getInstance().getChatDate().format(date);
}
- return getInstance().chatFullDate.format(date);
+ return getInstance().getChatFullDate().format(date);
} catch (Exception e) {
FileLog.e(e);
}
@@ -1670,9 +1934,9 @@ public class LocaleController {
calendar.setTimeInMillis(date);
if (!full && currentYear == calendar.get(Calendar.YEAR)) {
- return getInstance().formatterDayMonth.format(date);
+ return getInstance().getFormatterDayMonth().format(date);
}
- return getInstance().formatterDayMonth.format(date) + ", " + calendar.get(Calendar.YEAR);
+ return getInstance().getFormatterDayMonth().format(date) + ", " + calendar.get(Calendar.YEAR);
} catch (Exception e) {
FileLog.e(e);
}
@@ -1690,13 +1954,13 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
- return getInstance().formatterDay.format(new Date(date));
+ return getInstance().getFormatterDay().format(new Date(date));
} else if (dateDay + 1 == day && year == dateYear) {
return getString("Yesterday", R.string.Yesterday);
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return getInstance().formatterDayMonth.format(new Date(date));
+ return getInstance().getFormatterDayMonth().format(new Date(date));
} else {
- return getInstance().formatterYear.format(new Date(date));
+ return getInstance().getFormatterYear().format(new Date(date));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1716,16 +1980,16 @@ public class LocaleController {
if (dateDay == day && year == dateYear) {
if (shortFormat) {
- return LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().getFormatterDay().format(new Date(date)));
}
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1744,13 +2008,13 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
- return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().getFormatterDay().format(new Date(date)));
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1769,13 +2033,13 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
- return LocaleController.formatString(R.string.PmReadTodayAt, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString(R.string.PmReadTodayAt, getInstance().getFormatterDay().format(new Date(date)));
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString(R.string.PmReadYesterdayAt, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString(R.string.PmReadYesterdayAt, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString(R.string.PmReadDateTimeAt, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString(R.string.PmReadDateTimeAt, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString(R.string.PmReadDateTimeAt, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString(R.string.PmReadDateTimeAt, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1809,9 +2073,9 @@ public class LocaleController {
} else if (dateDay + 1 == day && year == dateYear) {
return LocaleController.getString(R.string.ShortYesterday);
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return getInstance().formatterDayMonth.format(new Date(date));
+ return getInstance().getFormatterDayMonth().format(new Date(date));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1836,13 +2100,13 @@ public class LocaleController {
int minutesAgo = (int) ((timeInMillis - date) / (1000 * 60));
return LocaleController.formatPluralString("MinutesAgo", minutesAgo, minutesAgo);
} else if (dateDay == day && year == dateYear) {
- return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().getFormatterDay().format(new Date(date)));
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1861,13 +2125,13 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
- return getInstance().formatterDay.format(new Date(date));
+ return getInstance().getFormatterDay().format(new Date(date));
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().chatDate.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getChatDate().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().chatFullDate.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getChatFullDate().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1886,11 +2150,11 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear) {
- return LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return getInstance().formatterScheduleDay.format(new Date(date));
+ return getInstance().getFormatterScheduleDay().format(new Date(date));
} else {
- return getInstance().chatFullDate.format(new Date(date));
+ return getInstance().getChatFullDate().format(new Date(date));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1909,13 +2173,13 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (dateDay == day && year == dateYear && useToday) {
- return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("TodayAtFormattedWithToday", R.string.TodayAtFormattedWithToday, getInstance().getFormatterDay().format(new Date(date)));
} else if (dateDay + 1 == day && year == dateYear && useToday) {
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().chatDate.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getChatDate().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().chatFullDate.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getChatFullDate().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1927,9 +2191,9 @@ public class LocaleController {
try {
date *= 1000;
if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- return getInstance().formatterScheduleDay.format(new Date(date)) + ", " + getInstance().formatterDay.format(new Date(date));
+ return getInstance().getFormatterScheduleDay().format(new Date(date)) + ", " + getInstance().getFormatterDay().format(new Date(date));
} else {
- return getInstance().formatterScheduleYear.format(new Date(date)) + ", " + getInstance().formatterDay.format(new Date(date));
+ return getInstance().getFormatterScheduleYear().format(new Date(date)) + ", " + getInstance().getFormatterDay().format(new Date(date));
}
} catch (Exception e) {
FileLog.e(e);
@@ -1954,14 +2218,14 @@ public class LocaleController {
} else if (diff < 60) {
return LocaleController.formatPluralString("UpdatedMinutes", diff);
}
- return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().formatterDay.format(new Date(date))));
+ return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().getFormatterDay().format(new Date(date))));
} else if (dateDay + 1 == day && year == dateYear) {
- return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date))));
+ return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date))));
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, format);
} else {
- String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
return LocaleController.formatString("LocationUpdatedFormatted", R.string.LocationUpdatedFormatted, format);
}
} catch (Exception e) {
@@ -1999,7 +2263,7 @@ public class LocaleController {
int dateHour = rightNow.get(Calendar.HOUR_OF_DAY);
if (dateDay == day && year == dateYear) {
- return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().formatterDay.format(new Date(date))));
+ return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, LocaleController.formatString("TodayAtFormatted", R.string.TodayAtFormatted, getInstance().getFormatterDay().format(new Date(date))));
/*int diff = (int) (ConnectionsManager.getInstance().getCurrentTime() - date) / 60;
if (diff < 1) {
return LocaleController.getString("LastSeenNow", R.string.LastSeenNow);
@@ -2012,17 +2276,17 @@ public class LocaleController {
if (madeShorter != null) {
madeShorter[0] = true;
if (hour <= 6 && dateHour > 18 && is24HourFormat) {
- return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, getInstance().getFormatterDay().format(new Date(date)));
}
- return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date)));
+ return LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date)));
} else {
- return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().formatterDay.format(new Date(date))));
+ return LocaleController.formatString("LastSeenFormatted", R.string.LastSeenFormatted, LocaleController.formatString("YesterdayAtFormatted", R.string.YesterdayAtFormatted, getInstance().getFormatterDay().format(new Date(date))));
}
} else if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
return LocaleController.formatString("LastSeenDateFormatted", R.string.LastSeenDateFormatted, format);
} else {
- String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ String format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
return LocaleController.formatString("LastSeenDateFormatted", R.string.LastSeenDateFormatted, format);
}
} catch (Exception e) {
@@ -2060,40 +2324,28 @@ public class LocaleController {
|| currentLocaleInfo != null && currentLocaleInfo.isRtl;
nameDisplayOrder = lang.equals("ko") ? 2 : 1;
- formatterBoostExpired = createFormatter(locale, getStringInternal("formatterBoostExpired", R.string.formatterBoostExpired), "MMM dd, yyyy");
- formatterGiveawayCard = createFormatter(locale, getStringInternal("formatterGiveawayCard", R.string.formatterGiveawayCard), "dd MMM yyyy");
- formatterGiveawayMonthDay = createFormatter(locale, getStringInternal("formatterGiveawayMonthDay", R.string.formatterGiveawayMonthDay), "MMMM dd");
- formatterGiveawayMonthDayYear = createFormatter(locale, getStringInternal("formatterGiveawayMonthDayYear", R.string.formatterGiveawayMonthDayYear), "MMMM dd, yyyy");
- formatterMonthYear = createFormatter(locale, getStringInternal("formatterMonthYear", R.string.formatterMonthYear), "MMM yyyy");
- formatterDayMonth = createFormatter(locale, getStringInternal("formatterMonth", R.string.formatterMonth), "dd MMM");
- formatterYear = createFormatter(locale, getStringInternal("formatterYear", R.string.formatterYear), "dd.MM.yy");
- formatterYearMax = createFormatter(locale, getStringInternal("formatterYearMax", R.string.formatterYearMax), "dd.MM.yyyy");
- chatDate = createFormatter(locale, getStringInternal("chatDate", R.string.chatDate), "d MMMM");
- chatFullDate = createFormatter(locale, getStringInternal("chatFullDate", R.string.chatFullDate), "d MMMM yyyy");
- formatterWeek = createFormatter(locale, getStringInternal("formatterWeek", R.string.formatterWeek), "EEE");
- formatterWeekLong = createFormatter(locale, getStringInternal("formatterWeekLong", R.string.formatterWeekLong), "EEEE");
- formatterScheduleDay = createFormatter(locale, getStringInternal("formatDateSchedule", R.string.formatDateSchedule), "MMM d");
- formatterScheduleYear = createFormatter(locale, getStringInternal("formatDateScheduleYear", R.string.formatDateScheduleYear), "MMM d yyyy");
- formatterDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, is24HourFormat ? getStringInternal("formatterDay24H", R.string.formatterDay24H) : getStringInternal("formatterDay12H", R.string.formatterDay12H), is24HourFormat ? "HH:mm" : "h:mm a");
- formatterConstDay = createFormatter(lang.toLowerCase().equals("ar") || lang.toLowerCase().equals("ko") ? locale : Locale.US, is24HourFormat ? "HH:mm" : "h:mm a", is24HourFormat ? "HH:mm" : "h:mm a");
- formatterStats = createFormatter(locale, is24HourFormat ? getStringInternal("formatterStats24H", R.string.formatterStats24H) : getStringInternal("formatterStats12H", R.string.formatterStats12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a");
- formatterBannedUntil = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntil24H", R.string.formatterBannedUntil24H) : getStringInternal("formatterBannedUntil12H", R.string.formatterBannedUntil12H), is24HourFormat ? "MMM dd yyyy, HH:mm" : "MMM dd yyyy, h:mm a");
- formatterBannedUntilThisYear = createFormatter(locale, is24HourFormat ? getStringInternal("formatterBannedUntilThisYear24H", R.string.formatterBannedUntilThisYear24H) : getStringInternal("formatterBannedUntilThisYear12H", R.string.formatterBannedUntilThisYear12H), is24HourFormat ? "MMM dd, HH:mm" : "MMM dd, h:mm a");
- formatterScheduleSend[0] = createFormatter(locale, getStringInternal("SendTodayAt", R.string.SendTodayAt), "'Send today at' HH:mm");
- formatterScheduleSend[1] = createFormatter(locale, getStringInternal("SendDayAt", R.string.SendDayAt), "'Send on' MMM d 'at' HH:mm");
- formatterScheduleSend[2] = createFormatter(locale, getStringInternal("SendDayYearAt", R.string.SendDayYearAt), "'Send on' MMM d yyyy 'at' HH:mm");
- formatterScheduleSend[3] = createFormatter(locale, getStringInternal("RemindTodayAt", R.string.RemindTodayAt), "'Remind today at' HH:mm");
- formatterScheduleSend[4] = createFormatter(locale, getStringInternal("RemindDayAt", R.string.RemindDayAt), "'Remind on' MMM d 'at' HH:mm");
- formatterScheduleSend[5] = createFormatter(locale, getStringInternal("RemindDayYearAt", R.string.RemindDayYearAt), "'Remind on' MMM d yyyy 'at' HH:mm");
- formatterScheduleSend[6] = createFormatter(locale, getStringInternal("StartTodayAt", R.string.StartTodayAt), "'Start today at' HH:mm");
- formatterScheduleSend[7] = createFormatter(locale, getStringInternal("StartDayAt", R.string.StartDayAt), "'Start on' MMM d 'at' HH:mm");
- formatterScheduleSend[8] = createFormatter(locale, getStringInternal("StartDayYearAt", R.string.StartDayYearAt), "'Start on' MMM d yyyy 'at' HH:mm");
- formatterScheduleSend[9] = createFormatter(locale, getStringInternal("StartShortTodayAt", R.string.StartShortTodayAt), "'Today,' HH:mm");
- formatterScheduleSend[10] = createFormatter(locale, getStringInternal("StartShortDayAt", R.string.StartShortDayAt), "MMM d',' HH:mm");
- formatterScheduleSend[11] = createFormatter(locale, getStringInternal("StartShortDayYearAt", R.string.StartShortDayYearAt), "MMM d yyyy, HH:mm");
- formatterScheduleSend[12] = createFormatter(locale, getStringInternal("StartsTodayAt", R.string.StartsTodayAt), "'Starts today at' HH:mm");
- formatterScheduleSend[13] = createFormatter(locale, getStringInternal("StartsDayAt", R.string.StartsDayAt), "'Starts on' MMM d 'at' HH:mm");
- formatterScheduleSend[14] = createFormatter(locale, getStringInternal("StartsDayYearAt", R.string.StartsDayYearAt), "'Starts on' MMM d yyyy 'at' HH:mm");
+ formatterBoostExpired = null;
+ formatterGiveawayCard = null;
+ formatterGiveawayMonthDay = null;
+ formatterGiveawayMonthDayYear = null;
+ formatterMonthYear = null;
+ formatterDayMonth = null;
+ formatterYear = null;
+ formatterYearMax = null;
+ chatDate = null;
+ chatFullDate = null;
+ formatterWeek = null;
+ formatterWeekLong = null;
+ formatterScheduleDay = null;
+ formatterScheduleYear = null;
+ formatterDay = null;
+ formatterConstDay = null;
+ formatterStats = null;
+ formatterBannedUntil = null;
+ formatterBannedUntilThisYear = null;
+ for (int i = 0; i < formatterScheduleSend.length; ++i) {
+ formatterScheduleSend[i] = null;
+ }
}
public static boolean isRTLCharacter(char ch) {
@@ -2133,7 +2385,7 @@ public class LocaleController {
} else if (type == 4) {
num += 12;
}
- return LocaleController.getInstance().formatterScheduleSend[num].format(calendar.getTimeInMillis());
+ return LocaleController.getInstance().getFormatterScheduleSend(num).format(calendar.getTimeInMillis());
}
public static String formatSectionDate(long date) {
@@ -2184,9 +2436,9 @@ public class LocaleController {
int dateYear = rightNow.get(Calendar.YEAR);
if (year == dateYear) {
- return getInstance().formatterBannedUntilThisYear.format(new Date(date));
+ return getInstance().getFormatterBannedUntilThisYear().format(new Date(date));
} else {
- return getInstance().formatterBannedUntil.format(new Date(date));
+ return getInstance().getFormatterBannedUntil().format(new Date(date));
}
} catch (Exception e) {
FileLog.e(e);
@@ -2198,7 +2450,7 @@ public class LocaleController {
try {
date *= 1000;
if (Math.abs(System.currentTimeMillis() - date) >= 31536000000L) {
- return getInstance().formatterYear.format(new Date(date));
+ return getInstance().getFormatterYear().format(new Date(date));
} else {
Calendar rightNow = Calendar.getInstance();
int day = rightNow.get(Calendar.DAY_OF_YEAR);
@@ -2207,11 +2459,11 @@ public class LocaleController {
int dayDiff = dateDay - day;
if (dayDiff == 0 || dayDiff == -1 && System.currentTimeMillis() - date < 60 * 60 * 8 * 1000) {
- return getInstance().formatterDay.format(new Date(date));
+ return getInstance().getFormatterDay().format(new Date(date));
} else if (dayDiff > -7 && dayDiff <= -1) {
- return getInstance().formatterWeek.format(new Date(date));
+ return getInstance().getFormatterWeek().format(new Date(date));
} else {
- return getInstance().formatterDayMonth.format(new Date(date));
+ return getInstance().getFormatterDayMonth().format(new Date(date));
}
}
} catch (Exception e) {
@@ -2259,9 +2511,9 @@ public class LocaleController {
date *= 1000;
String format;
if (Math.abs(System.currentTimeMillis() - date) < 31536000000L) {
- format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterDayMonth.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterDayMonth().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
} else {
- format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().formatterYear.format(new Date(date)), getInstance().formatterDay.format(new Date(date)));
+ format = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, getInstance().getFormatterYear().format(new Date(date)), getInstance().getFormatterDay().format(new Date(date)));
}
return formatString("ChannelOtherSubscriberJoined", R.string.ChannelOtherSubscriberJoined, format);
} catch (Exception e) {
@@ -2274,7 +2526,7 @@ public class LocaleController {
try {
date *= 1000;
Date dt = new Date(date);
- return String.format("%1$s, %2$s", getInstance().formatterYear.format(dt), getInstance().formatterDay.format(dt));
+ return String.format("%1$s, %2$s", getInstance().getFormatterYear().format(dt), getInstance().getFormatterDay().format(dt));
} 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 fecd15f35..5e6eccac3 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java
@@ -4437,8 +4437,8 @@ public class MessageObject {
} else if (messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
String date;
long time = ((long) messageOwner.date) * 1000;
- if (LocaleController.getInstance().formatterDay != null && LocaleController.getInstance().formatterYear != null) {
- date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(time), LocaleController.getInstance().formatterDay.format(time));
+ if (LocaleController.getInstance().getFormatterDay() != null && LocaleController.getInstance().getFormatterYear() != null) {
+ date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().getFormatterYear().format(time), LocaleController.getInstance().getFormatterDay().format(time));
} else {
date = "" + messageOwner.date;
}
@@ -6611,10 +6611,13 @@ public class MessageObject {
} else if (messageOwner.fwd_from != null && messageOwner.fwd_from.from_id instanceof TLRPC.TL_peerChannel && !isOutOwner()) {
return true;
} else if (isFromUser()) {
+ TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageOwner.from_id.user_id);
+ if (user != null && user.bot && ("reviews_bot".equals(UserObject.getPublicUsername(user)) || "ReviewInsightsBot".equals(UserObject.getPublicUsername(user)))) {
+ return true;
+ }
if (getMedia(messageOwner) instanceof TLRPC.TL_messageMediaEmpty || getMedia(messageOwner) == null || getMedia(messageOwner) instanceof TLRPC.TL_messageMediaWebPage && !(getMedia(messageOwner).webpage instanceof TLRPC.TL_webPage)) {
return false;
}
- TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(messageOwner.from_id.user_id);
if (user != null && user.bot && !hasExtendedMedia()) {
return true;
}
@@ -8022,6 +8025,9 @@ public class MessageObject {
if (message != null && message.media != null && (isVoiceDocument(getDocument(message)) || isRoundVideoMessage(message)) && message.media.ttl_seconds == 0x7FFFFFFF) {
return true;
}
+ if (getMedia(message) instanceof TLRPC.TL_messageMediaPaidMedia) {
+ return true;
+ }
// if (MessagesController.getInstance(currentAccount).isChatNoForwards(getChatId(message)) || message != null && message.noforwards) {
// 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 81417e17e..6689bafed 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java
@@ -11433,7 +11433,7 @@ public class MessagesController extends BaseController implements NotificationCe
req.offset_id = offset;
req.offset_date = offsetDate;
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("start migrate with id " + offset + " date " + LocaleController.getInstance().formatterStats.format((long) offsetDate * 1000));
+ FileLog.d("start migrate with id " + offset + " date " + LocaleController.getInstance().getFormatterStats().format((long) offsetDate * 1000));
}
if (offset == 0) {
req.offset_peer = new TLRPC.TL_inputPeerEmpty();
@@ -11462,14 +11462,14 @@ public class MessagesController extends BaseController implements NotificationCe
for (int a = 0; a < dialogsRes.messages.size(); a++) {
TLRPC.Message message = dialogsRes.messages.get(a);
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("search migrate id " + message.id + " date " + LocaleController.getInstance().formatterStats.format((long) message.date * 1000));
+ FileLog.d("search migrate id " + message.id + " date " + LocaleController.getInstance().getFormatterStats().format((long) message.date * 1000));
}
if (lastMessage == null || message.date < lastMessage.date) {
lastMessage = message;
}
}
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("migrate step with id " + lastMessage.id + " date " + LocaleController.getInstance().formatterStats.format((long) lastMessage.date * 1000));
+ FileLog.d("migrate step with id " + lastMessage.id + " date " + LocaleController.getInstance().getFormatterStats().format((long) lastMessage.date * 1000));
}
if (dialogsRes.dialogs.size() >= 100) {
offsetId = lastMessage.id;
@@ -11547,7 +11547,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
offsetId = -1;
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format((long) date * 1000));
+ FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().getFormatterStats().format((long) date * 1000));
}
}
dialogsRes.messages.remove(a);
@@ -11572,7 +11572,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
offsetId = -1;
if (BuildVars.LOGS_ENABLED) {
- FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format((long) date * 1000));
+ FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().getFormatterStats().format((long) date * 1000));
}
}
}
@@ -19824,6 +19824,10 @@ public class MessagesController extends BaseController implements NotificationCe
}
public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment, MessageObject originalMessage) {
+ return checkCanOpenChat(bundle, fragment, originalMessage, null);
+ }
+
+ public boolean checkCanOpenChat(Bundle bundle, BaseFragment fragment, MessageObject originalMessage, Browser.Progress progress) {
if (bundle == null || fragment == null) {
return true;
}
@@ -19853,7 +19857,13 @@ public class MessagesController extends BaseController implements NotificationCe
if (messageId != 0 && originalMessage != null && chat != null && chat.access_hash == 0) {
long did = originalMessage.getDialogId();
if (!DialogObject.isEncryptedDialog(did)) {
- AlertDialog progressDialog = new AlertDialog(fragment.getParentActivity(), AlertDialog.ALERT_TYPE_SPINNER);
+ final AlertDialog progressDialog;
+ if (progress != null) {
+ progressDialog = null;
+ progress.init();
+ } else {
+ progressDialog = new AlertDialog(fragment.getParentActivity(), AlertDialog.ALERT_TYPE_SPINNER);
+ }
TLObject req;
if (did < 0) {
chat = getChat(-did);
@@ -19873,7 +19883,12 @@ public class MessagesController extends BaseController implements NotificationCe
if (response != null) {
AndroidUtilities.runOnUIThread(() -> {
try {
- progressDialog.dismiss();
+ if (progressDialog != null) {
+ progressDialog.dismiss();
+ }
+ if (progress != null) {
+ progress.end();
+ }
} catch (Exception e) {
FileLog.e(e);
}
@@ -19885,14 +19900,38 @@ public class MessagesController extends BaseController implements NotificationCe
});
}
});
- progressDialog.setOnCancelListener(dialog -> {
- getConnectionsManager().cancelRequest(reqId, true);
- fragment.setVisibleDialog(null);
- });
- fragment.setVisibleDialog(progressDialog);
- progressDialog.show();
+ if (progressDialog != null) {
+ progressDialog.setOnCancelListener(dialog -> {
+ getConnectionsManager().cancelRequest(reqId, true);
+ fragment.setVisibleDialog(null);
+ });
+ fragment.setVisibleDialog(progressDialog);
+ progressDialog.show();
+ } else {
+ progress.onCancel(() -> {
+ getConnectionsManager().cancelRequest(reqId, true);
+ fragment.setVisibleDialog(null);
+ });
+ progress.init();
+ }
return false;
}
+ } else if (messageId != 0 && originalMessage != null && progress != null) {
+ progress.init();
+ progress.onCancel(ensureMessagesLoaded(-chatId, messageId, new MessagesLoadedCallback() {
+ @Override
+ public void onMessagesLoaded(boolean fromCache) {
+ progress.end();
+ fragment.presentFragment(new ChatActivity(bundle), true);
+ }
+
+ @Override
+ public void onError() {
+ progress.end();
+ fragment.presentFragment(new ChatActivity(bundle), true);
+ }
+ }));
+ return false;
}
return true;
}
@@ -20026,7 +20065,7 @@ public class MessagesController extends BaseController implements NotificationCe
}
}
- public void ensureMessagesLoaded(long dialogId, int messageId, MessagesLoadedCallback callback) {
+ public Runnable ensureMessagesLoaded(long dialogId, int messageId, MessagesLoadedCallback callback) {
SharedPreferences sharedPreferences = MessagesController.getNotificationsSettings(currentAccount);
if (messageId == 0) {
messageId = sharedPreferences.getInt("diditem" + dialogId, 0);
@@ -20046,13 +20085,17 @@ public class MessagesController extends BaseController implements NotificationCe
if (chatId != 0) {
currentChat = getMessagesController().getChat(chatId);
if (currentChat == null) {
+ final boolean[] cancelled = new boolean[1];
+ final Runnable[] cancel = new Runnable[1];
MessagesStorage messagesStorage = getMessagesStorage();
messagesStorage.getStorageQueue().postRunnable(() -> {
+ if (cancelled[0]) return;
TLRPC.Chat chat = messagesStorage.getChat(chatId);
AndroidUtilities.runOnUIThread(() -> {
+ if (cancelled[0]) return;
if (chat != null) {
getMessagesController().putChat(chat, true);
- ensureMessagesLoaded(dialogId, finalMessageId, callback);
+ cancel[0] = ensureMessagesLoaded(dialogId, finalMessageId, callback);
} else {
if (callback != null) {
callback.onError();
@@ -20060,7 +20103,12 @@ public class MessagesController extends BaseController implements NotificationCe
}
});
});
- return;
+ return () -> {
+ cancelled[0] = true;
+ if (cancel[0] != null) {
+ cancel[0].run();
+ }
+ };
}
}
@@ -20106,6 +20154,8 @@ public class MessagesController extends BaseController implements NotificationCe
} else {
loadMessagesInternal(dialogId, 0, true, count, finalMessageId, 0, true, 0, classGuid, 2, 0, 0, 0, -1, 0, 0, 0, false, 0, true, false, false, null, 0L);
}
+
+ return () -> getConnectionsManager().cancelRequestsForGuid(classGuid);
}
public int getChatPendingRequestsOnClosed(long chatId) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
index a86e87b09..35da0073c 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java
@@ -1785,7 +1785,7 @@ public class NotificationsController extends BaseController {
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
return LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, name);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
- String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(((long) messageObject.messageOwner.date) * 1000), LocaleController.getInstance().formatterDay.format(((long) messageObject.messageOwner.date) * 1000));
+ String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().getFormatterYear().format(((long) messageObject.messageOwner.date) * 1000), LocaleController.getInstance().getFormatterDay().format(((long) messageObject.messageOwner.date) * 1000));
return LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, getUserConfig().getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGameScore || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent) {
return messageObject.messageText.toString();
@@ -2384,7 +2384,7 @@ public class NotificationsController extends BaseController {
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
msg = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, name);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
- String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(((long) messageObject.messageOwner.date) * 1000), LocaleController.getInstance().formatterDay.format(((long) messageObject.messageOwner.date) * 1000));
+ String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().getFormatterYear().format(((long) messageObject.messageOwner.date) * 1000), LocaleController.getInstance().getFormatterDay().format(((long) messageObject.messageOwner.date) * 1000));
msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, getUserConfig().getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionGameScore || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPaymentSent) {
msg = messageObject.messageText.toString();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
index 36c543a24..58c0536b9 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java
@@ -5963,6 +5963,31 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
return sendingMessages.indexOfKey(mid) >= 0 || editingMessages.indexOfKey(mid) >= 0;
}
+
+ public boolean isSendingPaidMessage(int mid, int index) {
+ DelayedMessage delayedMessage = null;
+ if (delayedMessages != null) {
+ for (ArrayList arr : delayedMessages.values()) {
+ if (arr == null) continue;
+ for (DelayedMessage m : arr) {
+ if (m.messages == null) continue;
+ for (TLRPC.Message msg : m.messages) {
+ if (msg != null && msg.id == mid) {
+ delayedMessage = m;
+ break;
+ }
+ }
+ if (delayedMessage != null) break;
+ }
+ if (delayedMessage != null) break;
+ }
+ }
+ if (delayedMessage != null && index >= 0 && index < delayedMessage.messages.size()) {
+ mid = delayedMessage.messages.get(index).id;
+ }
+ return sendingMessages.indexOfKey(mid) >= 0 || editingMessages.indexOfKey(mid) >= 0;
+ }
+
public boolean isSendingMessageIdDialog(long did) {
return sendingMessagesIdDialogs.get(did, 0) > 0;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
index a1a0bab9b..c24bb729f 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
@@ -473,6 +473,10 @@ public class Utilities {
return Math.max(Math.min(value, maxValue), minValue);
}
+ public static float clamp01(float value) {
+ return clamp(value, 1f, 0f);
+ }
+
public static double clamp(double value, double maxValue, double minValue) {
if (Double.isNaN(value)) {
return minValue;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
index f7afa9da7..a9d1a335f 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java
@@ -13,6 +13,7 @@ import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.BitmapFactory;
import android.net.Uri;
@@ -237,20 +238,28 @@ public class Browser {
}
public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph) {
- openUrl(context, uri, allowCustom, tryTelegraph, false, null);
+ openUrl(context, uri, allowCustom, tryTelegraph, false, null, null);
}
public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph, Progress inCaseLoading) {
- openUrl(context, uri, allowCustom, tryTelegraph, false, inCaseLoading);
+ openUrl(context, uri, allowCustom, tryTelegraph, false, inCaseLoading, null);
}
- public static void openUrl(final Context context, Uri uri, final boolean allowCustom, boolean tryTelegraph, boolean forceNotInternalForApps, Progress inCaseLoading) {
+ public static void openUrl(final Context context, Uri uri, boolean _allowCustom, boolean tryTelegraph, boolean forceNotInternalForApps, Progress inCaseLoading, String browser) {
if (context == null || uri == null) {
return;
}
final int currentAccount = UserConfig.selectedAccount;
boolean[] forceBrowser = new boolean[]{false};
boolean internalUri = isInternalUri(uri, forceBrowser);
+ String browserPackage = getBrowserPackageName(browser);
+ if (isBrowserPackageInstalled(context, browserPackage, uri)) {
+ tryTelegraph = false;
+ _allowCustom = false;
+ } else {
+ browserPackage = null;
+ }
+ final boolean allowCustom = _allowCustom;
if (tryTelegraph) {
try {
String host = AndroidUtilities.getHostAuthority(uri);
@@ -413,6 +422,9 @@ public class Browser {
ComponentName componentName = new ComponentName(context.getPackageName(), LaunchActivity.class.getName());
intent.setComponent(componentName);
}
+ if (!TextUtils.isEmpty(browserPackage)) {
+ intent.setPackage(browserPackage);
+ }
intent.putExtra(android.provider.Browser.EXTRA_CREATE_NEW_TAB, true);
intent.putExtra(android.provider.Browser.EXTRA_APPLICATION_ID, context.getPackageName());
if (internalUri && context instanceof LaunchActivity) {
@@ -535,7 +547,55 @@ public class Browser {
return false;
}
- // © ChatGPT. All puns reserved. 🤖📜
+ public static String getBrowserPackageName(String browser) {
+ if (browser == null) return null;
+ switch (browser) {
+ case "google-chrome":
+ case "chrome":
+ return "com.android.chrome";
+ case "mozilla-firefox":
+ case "firefox":
+ return "org.mozilla.firefox";
+ case "microsoft-edge":
+ case "edge":
+ return "com.microsoft.emmx";
+ case "opera":
+ return "com.opera.browser";
+ case "opera-mini":
+ return "com.opera.mini.native";
+ case "brave":
+ case "brave-browser":
+ return "com.brave.browser";
+ case "duckduckgo":
+ case "duckduckgo-browser":
+ return "com.duckduckgo.mobile.android";
+ case "samsung":
+ case "samsung-browser":
+ return "com.sec.android.app.sbrowser";
+ case "vivaldi":
+ case "vivaldi-browser":
+ return "com.vivaldi.browser";
+ case "kiwi":
+ case "kiwi-browser":
+ return "com.kiwibrowser.browser";
+ case "uc":
+ case "uc-browser":
+ return "com.UCMobile.intl";
+ case "tor":
+ case "tor-browser":
+ return "org.torproject.torbrowser";
+ }
+ return null;
+ }
+
+ public static boolean isBrowserPackageInstalled(Context context, String packageName, Uri uri) {
+ if (packageName == null) return false;
+ PackageManager packageManager = context.getPackageManager();
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ intent.setPackage(packageName);
+ return packageManager.resolveActivity(intent, 0) != null;
+ }
+
public static String replaceHostname(Uri originalUri, String newHostname) {
String scheme = originalUri.getScheme();
String userInfo = originalUri.getUserInfo();
diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
index 8d03b90f5..7fac04eac 100644
--- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
+++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
@@ -13053,6 +13053,7 @@ public class TLRPC {
public int boosts_unrestrict;
public StickerSet emojiset;
public boolean can_view_revenue;
+ public boolean can_view_stars_revenue;
public boolean paid_media_allowed;
public long inviterId; //custom
public int invitesCount; //custom
@@ -15687,6 +15688,7 @@ public class TLRPC {
view_forum_as_messages = (flags2 & 64) != 0;
restricted_sponsored = (flags2 & 2048) != 0;
can_view_revenue = (flags2 & 4096) != 0;
+ can_view_stars_revenue = (flags2 & 32768) != 0;
paid_media_allowed = (flags2 & 16384) != 0;
id = stream.readInt64(exception);
about = stream.readString(exception);
@@ -15849,6 +15851,7 @@ public class TLRPC {
flags2 = restricted_sponsored ? (flags2 | 2048) : (flags2 &~ 2048);
flags2 = can_view_revenue ? (flags2 | 4096) : (flags2 &~ 4096);
flags2 = paid_media_allowed ? (flags2 | 16384) : (flags2 &~ 16384);
+ flags2 = can_view_stars_revenue ? (flags2 | 32768) : (flags2 &~ 32768);
stream.writeInt32(flags2);
stream.writeInt64(id);
stream.writeString(about);
@@ -15996,6 +15999,7 @@ public class TLRPC {
view_forum_as_messages = (flags2 & 64) != 0;
restricted_sponsored = (flags2 & 2048) != 0;
can_view_revenue = (flags2 & 4096) != 0;
+ can_view_stars_revenue = (flags2 & 32768) != 0;
id = stream.readInt64(exception);
about = stream.readString(exception);
if ((flags & 1) != 0) {
@@ -16153,6 +16157,7 @@ public class TLRPC {
flags2 = view_forum_as_messages ? (flags2 | 64) : (flags2 &~ 64);
flags2 = restricted_sponsored ? (flags2 | 2048) : (flags2 &~ 2048);
flags2 = can_view_revenue ? (flags2 | 4096) : (flags2 &~ 4096);
+ flags2 = can_view_stars_revenue ? (flags2 | 32768) : (flags2 &~ 32768);
stream.writeInt32(flags2);
stream.writeInt64(id);
stream.writeString(about);
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 3fb73ffea..cb33c51af 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
@@ -188,7 +188,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
for (int a = 0; a < count; a++) {
View child = getChildAt(a);
if (!(child instanceof ActionBar)) {
- if (child.getFitsSystemWindows()) {
+ if (child.getFitsSystemWindows() || child instanceof BaseFragment.AttachedSheetWindow) {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, bottomTabsHeight);
} else {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, actionBarHeight + bottomTabsHeight);
@@ -214,7 +214,7 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
View child = getChildAt(a);
if (!(child instanceof ActionBar)) {
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) child.getLayoutParams();
- if (child.getFitsSystemWindows()) {
+ if (child.getFitsSystemWindows() || child instanceof BaseFragment.AttachedSheetWindow) {
child.layout(
layoutParams.leftMargin,
layoutParams.topMargin,
@@ -822,9 +822,9 @@ public class ActionBarLayout extends FrameLayout implements INavigationLayout, F
float opacity = MathUtils.clamp(widthOffset / (float) width, 0, 0.8f);
scrimPaint.setColor(Color.argb((int)(0x99 * opacity), 0x00, 0x00, 0x00));
if (overrideWidthOffset != -1) {
- canvas.drawRect(0, 0, getWidth(), getHeight() - getBottomTabsHeight(true), scrimPaint);
+ canvas.drawRect(0, 0, getWidth(), getHeight() * 1.5f, scrimPaint);
} else {
- canvas.drawRect(clipLeft, 0, clipRight, getHeight() - getBottomTabsHeight(true), scrimPaint);
+ canvas.drawRect(clipLeft, 0, clipRight, getHeight() * 1.5f, scrimPaint);
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java
index 35989a915..2565ab4ff 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/AdjustPanLayoutHelper.java
@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.AnimationNotificationsLocker;
import org.telegram.messenger.UserConfig;
+import org.telegram.ui.LaunchActivity;
import java.util.ArrayList;
import java.util.List;
@@ -172,7 +173,11 @@ public class AdjustPanLayoutHelper {
additionalContentHeight = ((View) viewParent).getHeight() - contentHeight;
}
}
- setViewHeight(Math.max(previousHeight, contentHeight + additionalContentHeight));
+ int bottomTabsHeight = 0;
+ if (LaunchActivity.instance != null && LaunchActivity.instance.getBottomSheetTabs() != null) {
+ bottomTabsHeight += LaunchActivity.instance.getBottomSheetTabs().getExpandedHeight();
+ }
+ setViewHeight(Math.max(previousHeight, contentHeight + additionalContentHeight + bottomTabsHeight));
resizableView.requestLayout();
onTransitionStart(isKeyboardVisible, previousHeight, contentHeight);
@@ -186,7 +191,7 @@ public class AdjustPanLayoutHelper {
parent.setTranslationY(-dy);
onPanTranslationUpdate(dy, 1f, isKeyboardVisible);
from = -dy;
- to = 0;
+ to = -bottomTabsHeight;
inverse = true;
} else {
parent.setTranslationY(previousStartOffset);
@@ -219,7 +224,7 @@ public class AdjustPanLayoutHelper {
setViewHeight(ViewGroup.LayoutParams.MATCH_PARENT);
viewsToHeightSet.clear();
resizableView.requestLayout();
- onPanTranslationUpdate(0, isKeyboardVisible ? 1f : 0f, isKeyboardVisible);
+ onPanTranslationUpdate(0, isKeyboardVisible ? 1f : 0f, isKeyboardVisible);
parent.setTranslationY(0);
onTransitionEnd();
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
index 7dd1f25d6..9b3a90d43 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
@@ -92,6 +92,7 @@ public abstract class BaseFragment {
public View getWindowView();
public boolean isShown();
public void dismiss();
+ default void dismiss(boolean tabs) { dismiss(); }
public void release();
public boolean isFullyVisible();
@@ -108,6 +109,8 @@ public abstract class BaseFragment {
public void setOnDismissListener(Runnable onDismiss);
}
+ public static interface AttachedSheetWindow {}
+
@Nullable
public StoryViewer getLastStoryViewer() {
if (sheetsStack == null || sheetsStack.isEmpty())
@@ -143,7 +146,7 @@ public abstract class BaseFragment {
if (sheetsStack == null || sheetsStack.isEmpty())
return;
for (int i = sheetsStack.size() - 1; i >= 0; --i) {
- sheetsStack.get(i).release();
+ sheetsStack.get(i).dismiss(true);
}
sheetsStack.clear();
}
@@ -283,7 +286,7 @@ public abstract class BaseFragment {
}
public void onRemoveFromParent() {
-
+ clearSheets();
}
public void setParentFragment(BaseFragment fragment) {
@@ -663,6 +666,16 @@ public abstract class BaseFragment {
}
}
}
+ if (fullyVisibleListener != null) {
+ Runnable c = fullyVisibleListener;
+ fullyVisibleListener = null;
+ c.run();
+ }
+ }
+
+ private Runnable fullyVisibleListener;
+ public void whenFullyVisible(Runnable callback) {
+ fullyVisibleListener = callback;
}
public int getPreviewHeight() {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabs.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabs.java
index 99ab9c182..cf6788616 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabs.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabs.java
@@ -6,25 +6,19 @@ import static org.telegram.messenger.AndroidUtilities.lerp;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.Path;
-import android.graphics.PixelFormat;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
-import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.graphics.ColorUtils;
-import org.checkerframework.checker.units.qual.A;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.FileLog;
@@ -38,7 +32,6 @@ import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.Components.AnimatedColor;
import org.telegram.ui.Components.AnimatedFloat;
-import org.telegram.ui.Components.AnimatedTextView;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.Text;
import org.telegram.ui.LaunchActivity;
@@ -46,7 +39,6 @@ import org.telegram.ui.bots.BotWebViewAttachedSheet;
import org.telegram.ui.bots.BotWebViewContainer;
import org.telegram.ui.bots.BotWebViewSheet;
-import java.io.CharArrayReader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -92,12 +84,16 @@ public class BottomSheetTabs extends FrameLayout {
}
boolean closed = closeAttachedSheets();
Utilities.Callback open = fragment -> {
+ if (fragment == null) return;
if (fragment instanceof ChatActivity) {
if (((ChatActivity) fragment).getChatActivityEnterView() != null) {
((ChatActivity) fragment).getChatActivityEnterView().closeKeyboard();
((ChatActivity) fragment).getChatActivityEnterView().hidePopup(true, false);
}
}
+ if (fragment.getContext() == null) {
+ return;
+ }
if (AndroidUtilities.isTablet()) {
BotWebViewSheet sheet = new BotWebViewSheet(fragment.getContext(), fragment.getResourceProvider());
sheet.setParentActivity(fragment.getParentActivity());
@@ -106,20 +102,24 @@ public class BottomSheetTabs extends FrameLayout {
sheet.show();
}
} else {
+ BottomSheetTabsOverlay overlay = LaunchActivity.instance.getBottomSheetTabsOverlay();
BotWebViewAttachedSheet webViewSheet = fragment.createBotViewer();
webViewSheet.setParentActivity(fragment.getParentActivity());
if (webViewSheet.restoreState(fragment, tab)) {
- removeTab(tab, false);
- webViewSheet.show(closed);
+// if (overlay != null && overlay.isOpened() && overlay.openSheet(webViewSheet, tab, null)) {
+// removeTab(tab, false);
+// webViewSheet.show(closed, true);
+// } else {
+ removeTab(tab, false);
+ webViewSheet.show(closed);
+// }
}
}
};
if (tab.needsContext && (!(lastFragment instanceof ChatActivity) || ((ChatActivity) lastFragment).getDialogId() != tab.props.botId)) {
BaseFragment chatActivity = ChatActivity.of(tab.props.botId);
+ chatActivity.whenFullyVisible(() -> open.run(chatActivity));
lastFragment.presentFragment(chatActivity);
- AndroidUtilities.runOnUIThread(() -> {
- open.run(chatActivity);
- }, 200);
} else {
open.run(lastFragment);
}
@@ -460,7 +460,7 @@ public class BottomSheetTabs extends FrameLayout {
getTabBounds(rect, position);
drawable.setExpandProgress(0f);
drawable.setBackgroundColor(tabColor, tabIsDark > .5f);
- drawable.draw(canvas, rect, dp(10), alpha);
+ drawable.draw(canvas, rect, dp(10), alpha, 1f);
}
}
}
@@ -583,7 +583,7 @@ public class BottomSheetTabs extends FrameLayout {
private final Path closePath = new Path();
private final Path expandPath = new Path();
- public void draw(Canvas canvas, RectF bounds, float r, float alpha) {
+ public void draw(Canvas canvas, RectF bounds, float r, float alpha, float contentAlpha) {
final int backgroundColor = ColorUtils.blendARGB(this.backgroundColor, this.tabColor, expandProgress);
backgroundPaint.setColor(backgroundColor);
backgroundPaint.setAlpha((int) (0xFF * alpha));
@@ -618,24 +618,24 @@ public class BottomSheetTabs extends FrameLayout {
canvas.save();
canvas.translate(bounds.left + dp(22 - 4), bounds.centerY() - dp(6));
- iconPaint.setAlpha((int) (0xFF * alpha));
+ iconPaint.setAlpha((int) (0xFF * alpha * contentAlpha));
canvas.drawPath(closePath, iconPaint);
canvas.restore();
canvas.save();
canvas.translate(bounds.right - dp(22 - 4 + 12.66f), bounds.centerY());
- iconPaint.setAlpha((int) (0xFF * alpha * (1f - expandProgress)));
+ iconPaint.setAlpha((int) (0xFF * alpha * contentAlpha * (1f - expandProgress)));
canvas.drawPath(expandPath, iconPaint);
canvas.restore();
if (overrideTitle != null) {
overrideTitle
.ellipsize((int) (bounds.width() - dp(100)))
- .draw(canvas, bounds.left + dp(60), bounds.centerY(), iconColor, (1f - expandProgress) * alpha);
+ .draw(canvas, bounds.left + dp(60), bounds.centerY(), iconColor, (1f - expandProgress) * alpha * contentAlpha);
}
title
.ellipsize((int) (bounds.width() - dp(100)))
- .draw(canvas, bounds.left + dp(60), bounds.centerY(), iconColor, (overrideTitle == null ? 1f : expandProgress) * alpha);
+ .draw(canvas, bounds.left + dp(60), bounds.centerY(), iconColor, (overrideTitle == null ? 1f : expandProgress) * alpha * contentAlpha);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabsOverlay.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabsOverlay.java
index 94df343e2..88ee535fa 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabsOverlay.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BottomSheetTabsOverlay.java
@@ -3,6 +3,7 @@ package org.telegram.ui.ActionBar;
import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.AndroidUtilities.lerp;
import static org.telegram.messenger.LocaleController.getString;
+import static org.telegram.messenger.Utilities.clamp01;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -10,17 +11,14 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
-import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
-import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.RectF;
-import android.graphics.RenderEffect;
import android.graphics.RenderNode;
import android.graphics.Shader;
import android.graphics.SurfaceTexture;
@@ -34,7 +32,6 @@ import android.view.Surface;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
-import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.OverScroller;
@@ -42,7 +39,6 @@ import android.widget.OverScroller;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
-import com.google.firebase.encoders.ValueEncoder;
import com.google.zxing.common.detector.MathUtils;
import org.telegram.messenger.AndroidUtilities;
@@ -52,7 +48,6 @@ import org.telegram.messenger.Utilities;
import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.ButtonBounce;
import org.telegram.ui.Components.CubicBezierInterpolator;
-import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.Text;
import org.telegram.ui.GradientClip;
import org.telegram.ui.bots.BotWebViewAttachedSheet;
@@ -67,10 +62,14 @@ public class BottomSheetTabsOverlay extends FrameLayout {
private BotWebViewAttachedSheet dismissingSheet;
private BotWebViewSheet dismissingSheet2;
+ private BotWebViewAttachedSheet openingSheet;
private BotWebViewMenuContainer dismissingMenuContainer;
private BottomSheetTabs.TabDrawable dismissingTab;
- private ValueAnimator dismissingAnimator;
+ private BottomSheetTabs.TabDrawable openingTab;
+ private float openingTabScroll;
+ private ValueAnimator animator;
private float dismissProgress;
+ private float openingProgress;
private final AnimatedFloat animatedCount = new AnimatedFloat(this, 0, 350, CubicBezierInterpolator.EASE_OUT_QUINT);
@@ -88,6 +87,10 @@ public class BottomSheetTabsOverlay extends FrameLayout {
minimumVelocity = configuration.getScaledMinimumFlingVelocity();
}
+ public boolean isOpened() {
+ return openProgress > .1f;
+ }
+
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
return false;
@@ -398,14 +401,68 @@ public class BottomSheetTabsOverlay extends FrameLayout {
this.slowerDismiss = slowerDismiss;
}
+ public boolean openSheet(BotWebViewAttachedSheet sheet, BottomSheetTabs.WebTabData tab, Runnable whenOpened) {
+ if (sheet == null) return false;
+ if (tabsView == null) return false;
+
+ if (dismissingSheet != null || openingSheet != null) {
+ if (animator != null) {
+ animator.end();
+ animator = null;
+ }
+ }
+
+ openingSheet = sheet;
+ sheet.getWindowView().setDrawingFromOverlay(true);
+ invalidate();
+
+ if (animator != null) {
+ animator.cancel();
+ }
+
+ openingTab = tabsView.findTabDrawable(tab);
+ openingTabScroll = openingTab != null ? ((animatedCount.get() - 1 - openingTab.getPosition()) - Math.max(getScrollMin(), getScrollOffset())) / getScrollWindow() : 0;
+
+ openingProgress = 0;
+ animator = ValueAnimator.ofFloat(0, 1);
+ animator.addUpdateListener(anm -> {
+ openingProgress = (float) anm.getAnimatedValue();
+ invalidate();
+ });
+ animator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ sheet.getWindowView().setDrawingFromOverlay(false);
+ sheet.getWindowView().post(() -> {
+ openingSheet = null;
+ openingTab = null;
+ if (!isOpen) {
+ clearTabs();
+ }
+ openingProgress = 0;
+ invalidate();
+ });
+
+ if (whenOpened != null) {
+ whenOpened.run();
+ }
+ }
+ });
+ AndroidUtilities.applySpring(animator, 260, 30, 1);
+// animator.setDuration(5000);
+ animator.start();
+
+ return true;
+ }
+
public boolean dismissSheet(BotWebViewAttachedSheet sheet) {
if (sheet == null) return false;
if (tabsView == null) return false;
- if (dismissingSheet != null) {
- if (dismissingAnimator != null) {
- dismissingAnimator.end();
- dismissingAnimator = null;
+ if (dismissingSheet != null || openingSheet != null) {
+ if (animator != null) {
+ animator.end();
+ animator = null;
}
}
@@ -413,8 +470,8 @@ public class BottomSheetTabsOverlay extends FrameLayout {
sheet.getWindowView().setDrawingFromOverlay(true);
invalidate();
- if (dismissingAnimator != null) {
- dismissingAnimator.cancel();
+ if (animator != null) {
+ animator.cancel();
}
BottomSheetTabs.WebTabData tab = sheet.saveState();
@@ -425,12 +482,12 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
dismissProgress = 0;
- dismissingAnimator = ValueAnimator.ofFloat(0, 1);
- dismissingAnimator.addUpdateListener(anm -> {
+ animator = ValueAnimator.ofFloat(0, 1);
+ animator.addUpdateListener(anm -> {
dismissProgress = (float) anm.getAnimatedValue();
invalidate();
});
- dismissingAnimator.addListener(new AnimatorListenerAdapter() {
+ animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (tab.webView != null && tab.previewBitmap == null && tab.webViewWidth > 0 && tab.webViewHeight > 0) {
@@ -447,11 +504,11 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
});
if (slowerDismiss || sheet.getFullSize()) {
- AndroidUtilities.applySpring(dismissingAnimator, 260, 30, 1);
+ AndroidUtilities.applySpring(animator, 260, 30, 1);
} else {
- AndroidUtilities.applySpring(dismissingAnimator, 350, 30, 1);
+ AndroidUtilities.applySpring(animator, 350, 30, 1);
}
- dismissingAnimator.start();
+ animator.start();
slowerDismiss = false;
@@ -462,10 +519,10 @@ public class BottomSheetTabsOverlay extends FrameLayout {
if (sheet == null) return false;
if (tabsView == null) return false;
- if (dismissingSheet2 != null) {
- if (dismissingAnimator != null) {
- dismissingAnimator.end();
- dismissingAnimator = null;
+ if (dismissingSheet != null || openingSheet != null) {
+ if (animator != null) {
+ animator.end();
+ animator = null;
}
}
@@ -473,8 +530,8 @@ public class BottomSheetTabsOverlay extends FrameLayout {
sheet.getWindowView().setDrawingFromOverlay(true);
invalidate();
- if (dismissingAnimator != null) {
- dismissingAnimator.cancel();
+ if (animator != null) {
+ animator.cancel();
}
BottomSheetTabs.WebTabData tab = sheet.saveState();
@@ -485,12 +542,12 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
dismissProgress = 0;
- dismissingAnimator = ValueAnimator.ofFloat(0, 1);
- dismissingAnimator.addUpdateListener(anm -> {
+ animator = ValueAnimator.ofFloat(0, 1);
+ animator.addUpdateListener(anm -> {
dismissProgress = (float) anm.getAnimatedValue();
invalidate();
});
- dismissingAnimator.addListener(new AnimatorListenerAdapter() {
+ animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (tab.webView != null && tab.previewBitmap == null && tab.webViewWidth > 0 && tab.webViewHeight > 0) {
@@ -506,9 +563,9 @@ public class BottomSheetTabsOverlay extends FrameLayout {
invalidate();
}
});
- AndroidUtilities.applySpring(dismissingAnimator, 350, 30, 1);
- dismissingAnimator.setDuration(dismissingAnimator.getDuration() * 2);
- dismissingAnimator.start();
+ AndroidUtilities.applySpring(animator, 350, 30, 1);
+ animator.setDuration(animator.getDuration() * 2);
+ animator.start();
slowerDismiss = false;
@@ -523,8 +580,8 @@ public class BottomSheetTabsOverlay extends FrameLayout {
menuContainer.setDrawingFromOverlay(true);
invalidate();
- if (dismissingAnimator != null) {
- dismissingAnimator.cancel();
+ if (animator != null) {
+ animator.cancel();
}
BottomSheetTabs.WebTabData tab = menuContainer.saveState();
@@ -535,12 +592,12 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
dismissProgress = 0;
- dismissingAnimator = ValueAnimator.ofFloat(0, 1);
- dismissingAnimator.addUpdateListener(anm -> {
+ animator = ValueAnimator.ofFloat(0, 1);
+ animator.addUpdateListener(anm -> {
dismissProgress = (float) anm.getAnimatedValue();
invalidate();
});
- dismissingAnimator.addListener(new AnimatorListenerAdapter() {
+ animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (tab.webView != null && tab.previewBitmap == null && tab.webViewWidth > 0 && tab.webViewHeight > 0) {
@@ -557,9 +614,9 @@ public class BottomSheetTabsOverlay extends FrameLayout {
invalidate();
}
});
- AndroidUtilities.applySpring(dismissingAnimator, 350, 30, 1);
- dismissingAnimator.setDuration(dismissingAnimator.getDuration());
- dismissingAnimator.start();
+ AndroidUtilities.applySpring(animator, 350, 30, 1);
+ animator.setDuration(animator.getDuration());
+ animator.start();
return true;
}
@@ -589,12 +646,17 @@ public class BottomSheetTabsOverlay extends FrameLayout {
private final RectF tabsViewBounds = new RectF();
private final ArrayList tabs = new ArrayList<>();
+ private View actionBarLayout;
public void openTabsView() {
if (tabsView == null || !(tabsView.getParent() instanceof View)) return;
- View actionBarLayout = (View) tabsView.getParent();
- actionBarLayout.getLocationOnScreen(pos);
+ actionBarLayout = (View) tabsView.getParent();
+ if (actionBarLayout != null) {
+ actionBarLayout.getLocationOnScreen(pos);
+ } else {
+ pos[0] = pos[1] = 0;
+ }
getLocationOnScreen(pos2);
tabsViewBounds.set(pos[0] - pos2[0], pos[1] - pos2[1], pos[0] - pos2[0] + actionBarLayout.getWidth(), pos[1] - pos2[1] + actionBarLayout.getHeight());
@@ -605,13 +667,6 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
private void clearTabs() {
-// for (int i = 0; i < tabs.size(); ++i) {
-// TabPreview tab = tabs.get(i);
-// if (tab.webView != null) {
-// tab.webView.onPause();
-// AndroidUtilities.removeFromParent(tab.webView);
-// }
-// }
tabs.clear();
}
@@ -621,12 +676,6 @@ public class BottomSheetTabsOverlay extends FrameLayout {
for (int i = tabs.size() - 1; i >= 0; --i) {
BottomSheetTabs.WebTabData tabData = tabs.get(i);
-// if (tabData.webView != null) {
-// AndroidUtilities.removeFromParent(tabData.webView);
-// tabData.webView.onResume();
-// tabData.webView.post(tabData.webView::onPause);
-// addView(tabData.webView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
-// }
BottomSheetTabs.TabDrawable tabDrawable = null;
for (int j = 0; j < tabDrawables.size(); ++j) {
BottomSheetTabs.TabDrawable d = tabDrawables.get(j);
@@ -690,7 +739,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
openProgress = isOpen ? 1f : 0f;
invalidate();
- if (!isOpen) {
+ if (!isOpen && openingSheet == null) {
clearTabs();
}
}
@@ -714,7 +763,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
tabsView.getLocationOnScreen(pos);
tabsView.getTabBounds(rect, 0);
rect.offset(pos[0] - pos2[0], pos[1] - pos2[1]);
- float radius = dismissingSheet.getWindowView().drawInto(canvas, rect, dismissProgress, clipRect);
+ float radius = dismissingSheet.getWindowView().drawInto(canvas, rect, dismissProgress, clipRect, dismissProgress, false);
if (dismissingTab != null) {
clipPath.rewind();
@@ -724,7 +773,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
final float y = clipRect.top - dp(50) * (1f - dismissProgress);
rect.set(clipRect.left, y, clipRect.right, y + dp(50));
tabsView.setupTab(dismissingTab);
- dismissingTab.draw(canvas, rect, radius, dismissProgress);
+ dismissingTab.draw(canvas, rect, radius, dismissProgress, 1f);
canvas.restore();
}
}
@@ -745,7 +794,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
final float y = clipRect.top - dp(50) * (1f - dismissProgress);
rect.set(clipRect.left, y, clipRect.right, y + dp(50));
tabsView.setupTab(dismissingTab);
- dismissingTab.draw(canvas, rect, radius, dismissProgress);
+ dismissingTab.draw(canvas, rect, radius, dismissProgress, 1f);
canvas.restore();
}
}
@@ -766,7 +815,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
final float y = clipRect.top - dp(50) * (1f - dismissProgress);
rect.set(clipRect.left, y, clipRect.right, y + dp(50));
tabsView.setupTab(dismissingTab);
- dismissingTab.draw(canvas, rect, radius, dismissProgress);
+ dismissingTab.draw(canvas, rect, radius, dismissProgress, 1f);
canvas.restore();
}
}
@@ -784,9 +833,19 @@ public class BottomSheetTabsOverlay extends FrameLayout {
private GradientClip gradientClip;
private void drawTabsPreview(Canvas canvas) {
- if (openProgress <= 0) return;
+ if (openProgress <= 0 && openingProgress <= 0) return;
canvas.save();
+
+ if (actionBarLayout != null) {
+ actionBarLayout.getLocationOnScreen(pos);
+ getLocationOnScreen(pos2);
+ tabsViewBounds.set(pos[0] - pos2[0], pos[1] - pos2[1], pos[0] - pos2[0] + actionBarLayout.getWidth(), pos[1] - pos2[1] + actionBarLayout.getHeight());
+ } else {
+ pos[0] = pos[1] = 0;
+ tabsViewBounds.set(0, 0, 0, 0);
+ }
+
canvas.clipRect(tabsViewBounds);
canvas.translate(tabsViewBounds.left, tabsViewBounds.top);
@@ -817,11 +876,29 @@ public class BottomSheetTabsOverlay extends FrameLayout {
}
final float count = animatedCount.set(tabCount);
boolean reverse = true;
- for (int i = (reverse ? 0 : tabs.size() - 1); (reverse ? i < tabs.size() : i >= 0); i = (reverse ? i + 1 : i - 1)) {
- final TabPreview tab = tabs.get(i);
+ final float open = lerp(0, (1f - Utilities.clamp(getScrollWindow() <= 0 ? 0 : (getScrollMin() - getScrollOffset()) / (getScrollWindow() * .15f) * .2f, 1f, 0f)), openProgress);
+ int openingTabIndex = -1;
+ for (int i = 0; i < tabs.size() + 1; i++) {
+ final TabPreview tab;
+ if (i == tabs.size()) {
+ if (openingTabIndex >= 0 && openingProgress > .5f) {
+ tab = tabs.get(openingTabIndex);
+ } else {
+ continue;
+ }
+ } else {
+ tab = tabs.get(i);
+ }
+ if (i < tabs.size() && tab.tabDrawable == openingTab && openingProgress > .5f) {
+ openingTabIndex = i;
+ continue;
+ }
+
+ final float tabOpen = tab.tabDrawable == openingTab ? 1f : open;
+ final float opening = tab.tabDrawable == openingTab ? openingProgress : 0f;
final float position = count - 1 - tab.tabDrawable.getPosition();
- final float scroll = (position - getScrollOffset()) / getScrollWindow();
+ final float scroll = tab.tabDrawable == openingTab ? openingTabScroll : (position - Math.max(getScrollMin(), getScrollOffset())) / getScrollWindow();
final float scrollT = Math.max(scroll, 0f);
final float oscrollT = Math.max(Math.min(scroll, 1f), -4);
@@ -842,31 +919,29 @@ public class BottomSheetTabsOverlay extends FrameLayout {
if (alpha <= 0) continue;
rect2.set(cx - width / 2f, y, cx + width / 2f, y + height);
- tabsView.getTabBounds(rect, Utilities.clamp(tab.tabDrawable.getPosition(), 1, 0));
- rect.offset(tabsView.getX(), tabsView.getY());
- AndroidUtilities.lerpCentered(rect, rect2, openProgress, rect2);
+ boolean drawSimple = tab.tabDrawable != openingTab && (rect2.top > thisHeight || rect2.bottom < 0 || open < .1f) && position < count - 3;
+
+ if (openingSheet != null && tab.tabDrawable == openingTab) {
+ BotWebViewAttachedSheet.WindowView windowView = openingSheet.getWindowView();
+ rect.set(windowView.getRect());
+ AndroidUtilities.lerpCentered(rect2, rect, opening, rect2);
+ } else {
+ tabsView.getTabBounds(rect, Utilities.clamp(tab.tabDrawable.getPosition(), 1, 0));
+ rect.offset(tabsView.getX(), tabsView.getY());
+ AndroidUtilities.lerpCentered(rect, rect2, open, rect2);
+ }
if (tabsView != null) {
tabsView.setupTab(tab.tabDrawable);
}
+ if (tab.tabDrawable != openingTab && (rect2.top > thisHeight || rect2.bottom < 0))
+ continue;
+
canvas.save();
tab.clickBounds.set(rect2);
if (SharedConfig.botTabs3DEffect) {
-// final float scale = lerp(1f, .5f, openProgress);
-// canvas.scale(scale, scale, rect2.centerX(), rect2.centerY());
-// scale(tab.clickBounds, scale, rect.centerX(), rect2.centerY());
-
Canvas tabCanvas = canvas;
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && alpha < 1 && false) {
-// if (tab.node == null) {
-// tab.node = new RenderNode("a");
-// }
-// tab.node.setRenderEffect(RenderEffect.createBlurEffect((1f - alpha) * 300, (1f - alpha) * 300, Shader.TileMode.CLAMP));
-// tab.node.setPosition(0, 0, (int) thisWidth, (int) thisHeight);
-// tabCanvas = tab.node.beginRecording();
-// }
-
tab.matrix.reset();
final int p = 0;
@@ -880,41 +955,35 @@ public class BottomSheetTabsOverlay extends FrameLayout {
tab.src[6] = rect2.left;
tab.src[7] = rect2.top + rect2.height() * Sh;
-// final float ws = .75f;
-// final float wss = 1.2f;
-// final float hs = 1f;
-// final float wstop = 1f;
-// final float wsbottom = 1.2f;
-// tab.dst[0] = rect2.centerX() - rect2.width() / 2f * ws * wstop;
-// tab.dst[1] = rect2.centerY() - rect2.height() / 2f * hs;
-// tab.dst[2] = rect2.centerX() + rect2.width() / 2f * ws * wstop;
-// tab.dst[3] = rect2.centerY() - rect2.height() / 2f * hs;
-// tab.dst[4] = rect2.centerX() + rect2.width() / 2f * ws * (2f - wsbottom);
-// tab.dst[5] = rect2.centerY() + rect2.height() / 2f * hs;
-// tab.dst[6] = rect2.centerX() - rect2.width() / 2f * ws * (2f - wsbottom);
-// tab.dst[7] = rect2.centerY() + rect2.height() / 2f * hs;
-
tab.dst[0] = rect2.left;
tab.dst[1] = rect2.top - dp(p);
tab.dst[2] = rect2.right;
tab.dst[3] = rect2.top - dp(p);
final float s1 = .83f, s2 = .6f;
- tab.dst[4] = rect2.centerX() + rect2.width() / 2f * lerp(1f, s1, openProgress);
- tab.dst[5] = rect2.top - dp(p) + (rect2.height() * Sh + dp(p + p)) * lerp(1f, s2, openProgress);
- tab.dst[6] = rect2.centerX() - rect2.width() / 2f * lerp(1f, s1, openProgress);
- tab.dst[7] = rect2.top - dp(p) + (rect2.height() * Sh + dp(p + p)) * lerp(1f, s2, openProgress);
+ tab.dst[4] = rect2.centerX() + rect2.width() / 2f * lerp(1f, s1, tabOpen * (1f - opening));
+ tab.dst[5] = rect2.top - dp(p) + (rect2.height() * Sh + dp(p + p)) * lerp(1f, s2, tabOpen * (1f - opening));
+ tab.dst[6] = rect2.centerX() - rect2.width() / 2f * lerp(1f, s1, tabOpen * (1f - opening));
+ tab.dst[7] = rect2.top - dp(p) + (rect2.height() * Sh + dp(p + p)) * lerp(1f, s2, tabOpen * (1f - opening));
tab.matrix.setPolyToPoly(tab.src, 0, tab.dst, 0, 4);
tabCanvas.concat(tab.matrix);
- tab.draw(tabCanvas, rect2, lerp(tab.tabDrawable.getAlpha(), alpha, openProgress), openProgress);
+ tab.draw(
+ tabCanvas,
+ rect2,
+ drawSimple,
+ tab.tabDrawable == openingTab ? 1f : lerp(tab.tabDrawable.getAlpha(), alpha, openProgress),
+ tab.tabDrawable == openingTab ? 1f : tabOpen * (1f - opening),
+ opening,
+ lerp(clamp01(position - count + 2),1f, clamp01((tabOpen - .1f) / .8f))
+ );
+
+ if (openingSheet != null && tab.tabDrawable == openingTab) {
+ BotWebViewAttachedSheet.WindowView windowView = openingSheet.getWindowView();
+ windowView.drawInto(canvas, rect2, 1f, rect2, opening, true);
+ }
canvas.restore();
-//
-// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && alpha < 1 && false) {
-// tab.node.endRecording();
-// canvas.drawRenderNode(tab.node);
-// }
} else {
final float s = lerp(
1f,
@@ -928,7 +997,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
canvas.scale(s, s, rect2.centerX(), rect2.top);
scale(tab.clickBounds, s, rect.centerX(), rect2.top);
- tab.draw(canvas, rect2, lerp(tab.tabDrawable.getAlpha(), 1f, openProgress), openProgress);
+ tab.draw(canvas, rect2, drawSimple, lerp(tab.tabDrawable.getAlpha(), 1f, openProgress), open, 0f, lerp(clamp01(position - count + 2), 1f, clamp01((open - .1f) / .8f)));
canvas.restore();
}
}
@@ -1070,27 +1139,38 @@ public class BottomSheetTabsOverlay extends FrameLayout {
private final Matrix gradientMatrix = new Matrix();
private final Paint gradientPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
- public void draw(Canvas canvas, RectF bounds, float alpha, float expandProgress) {
+ public void draw(Canvas canvas, RectF bounds, boolean simple, float alpha, float expandProgress, float openingProgress, float contentAlpha) {
alpha *= Utilities.clamp(1f - ((Math.abs(dismissProgress) - .3f) / .7f), 1f, 0f);
if (alpha <= 0)
return;
float tabScaleY = 1f;
if (SharedConfig.botTabs3DEffect) {
- tabScaleY = lerp(1f, 1.3f, expandProgress);
+ tabScaleY = lerp(1f, 1.3f, expandProgress * (1f - openingProgress));
}
+ final float tabTranslateY = openingProgress * (AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() - dp(50));
canvas.save();
canvas.rotate(dismissProgress * 20, bounds.centerX() + dp(50) * dismissProgress, bounds.bottom + dp(350));
final float s = bounce.getScale(.01f);
canvas.scale(s, s, bounds.centerX(), bounds.centerY());
final float r = lerp(dp(10), dp(8), expandProgress);
+ if (simple) {
+ shadowPaint.setColor(0);
+ shadowPaint.setShadowLayer(dp(30), 0, dp(10), Theme.multAlpha(0x20000000, alpha * expandProgress * (1f - openingProgress)));
+ canvas.drawRoundRect(bounds, r, r, shadowPaint);
+ backgroundPaint.setAlpha((int) (0xFF * alpha));
+ canvas.drawRoundRect(bounds, r, r, backgroundPaint);
+ canvas.restore();
+ return;
+ }
+
clipPath.rewind();
clipPath.addRoundRect(bounds, r, r, Path.Direction.CW);
canvas.save();
shadowPaint.setColor(0);
- shadowPaint.setShadowLayer(dp(30), 0, dp(10), Theme.multAlpha(0x20000000, alpha * (expandProgress > .7f ? expandProgress : 0)));
+ shadowPaint.setShadowLayer(dp(30), 0, dp(10), Theme.multAlpha(0x20000000, alpha * expandProgress * (1f - openingProgress)));
canvas.drawPath(clipPath, shadowPaint);
canvas.clipPath(clipPath);
@@ -1098,8 +1178,8 @@ public class BottomSheetTabsOverlay extends FrameLayout {
canvas.drawRoundRect(bounds, r, r, backgroundPaint);
canvas.save();
- canvas.translate(bounds.left, bounds.top + dp(50) * tabScaleY);
- canvas.scale(1f, lerp(1f, 1.25f, expandProgress));
+ canvas.translate(bounds.left, bounds.top + dp(50) * tabScaleY + tabTranslateY);
+ canvas.scale(1f, lerp(1f, 1.25f, expandProgress * (1f - openingProgress)));
if (previewNode != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && ((RenderNode) previewNode).hasDisplayList()) {
RenderNode node = (RenderNode) previewNode;
final float s2 = bounds.width() / node.getWidth();
@@ -1121,7 +1201,7 @@ public class BottomSheetTabsOverlay extends FrameLayout {
canvas.restore();
canvas.save();
- gradientPaint.setAlpha((int) (0xFF * alpha * expandProgress));
+ gradientPaint.setAlpha((int) (0xFF * alpha * expandProgress * (1f - openingProgress)));
gradientMatrix.reset();
final float gradientScale = bounds.height() / 255f;
gradientMatrix.postScale(gradientScale, gradientScale);
@@ -1133,9 +1213,10 @@ public class BottomSheetTabsOverlay extends FrameLayout {
tabBounds.set(bounds);
tabBounds.bottom = tabBounds.top + Math.min(bounds.height(), dp(50));
+ tabBounds.offset(0, tabTranslateY);
tabDrawable.setExpandProgress(expandProgress);
canvas.scale(1f, tabScaleY, tabBounds.centerX(), tabBounds.top);
- tabDrawable.draw(canvas, tabBounds, r, alpha * alpha);
+ tabDrawable.draw(canvas, tabBounds, r, alpha * alpha, contentAlpha);
canvas.restore();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java
index caaec78e3..f0fa60c91 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java
@@ -28,6 +28,7 @@ import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_stories;
+import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
import org.telegram.ui.Components.RecyclerListView;
import java.util.ArrayList;
@@ -35,7 +36,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
-public abstract class BaseLocationAdapter extends RecyclerListView.SelectionAdapter {
+public abstract class BaseLocationAdapter extends AdapterWithDiffUtils {
public final boolean stories;
public final boolean biz;
@@ -82,7 +83,7 @@ public abstract class BaseLocationAdapter extends RecyclerListView.SelectionAdap
places.clear();
locations.clear();
searchInProgress = false;
- notifyDataSetChanged();
+ update(true);
} else {
if (searchRunnable != null) {
Utilities.searchQueue.cancelRunnable(searchRunnable);
@@ -483,7 +484,7 @@ public abstract class BaseLocationAdapter extends RecyclerListView.SelectionAdap
}
BaseLocationAdapter.this.locations.clear();
BaseLocationAdapter.this.locations.addAll(locations);
- notifyDataSetChanged();
+ update(true);
});
});
} else {
@@ -525,10 +526,13 @@ public abstract class BaseLocationAdapter extends RecyclerListView.SelectionAdap
if (delegate != null) {
delegate.didLoadSearchResult(places);
}
- notifyDataSetChanged();
+ update(true);
}));
+ update(true);
+ }
+
+ protected void update(boolean animated) {
notifyDataSetChanged();
-// notifyStartSearch(wasSearched, wasSearching, oldItemCount, animated);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java
index 6e139588f..9ef069a00 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java
@@ -334,7 +334,7 @@ public class FiltersView extends RecyclerListView {
long minDate = calendar.getTimeInMillis();
calendar.set(year, month, day + 1, 0, 0, 0);
long maxDate = calendar.getTimeInMillis() - 1;
- dates.add(new DateData(LocaleController.getInstance().formatterWeekLong.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterWeekLong().format(minDate), minDate, maxDate));
return;
}
if ((matcher = shortDate.matcher(q)).matches()) {
@@ -382,7 +382,7 @@ public class FiltersView extends RecyclerListView {
long minDate = calendar.getTimeInMillis();
calendar.set(year, month, day + 1, 0, 0, 0);
long maxDate = calendar.getTimeInMillis() - 1;
- dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterYearMax().format(minDate), minDate, maxDate));
return;
}
@@ -462,7 +462,7 @@ public class FiltersView extends RecyclerListView {
}
calendar.add(Calendar.MONTH, 1);
long maxDate = calendar.getTimeInMillis() - 1;
- dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterMonthYear().format(minDate), minDate, maxDate));
}
}
}
@@ -480,7 +480,7 @@ public class FiltersView extends RecyclerListView {
}
calendar.add(Calendar.MONTH, 1);
long maxDate = calendar.getTimeInMillis() - 1;
- dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterMonthYear().format(minDate), minDate, maxDate));
}
}
@@ -502,9 +502,9 @@ public class FiltersView extends RecyclerListView {
calendar.set(i, month, day + 2, 0, 0, 0);
long maxDate = calendar.getTimeInMillis() - 1;
if (i == currentYear) {
- dates.add(new DateData(LocaleController.getInstance().formatterDayMonth.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterDayMonth().format(minDate), minDate, maxDate));
} else {
- dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(minDate), minDate, maxDate));
+ dates.add(new DateData(LocaleController.getInstance().getFormatterYearMax().format(minDate), minDate, maxDate));
}
}
}
@@ -527,7 +527,7 @@ public class FiltersView extends RecyclerListView {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);
for (int i = 0; i < 7; i++) {
c.set(Calendar.DAY_OF_WEEK, i);
- if (LocaleController.getInstance().formatterWeekLong.format(c.getTime()).toLowerCase().startsWith(q)) {
+ if (LocaleController.getInstance().getFormatterWeekLong().format(c.getTime()).toLowerCase().startsWith(q)) {
return i;
}
if (dateFormat.format(c.getTime()).toLowerCase().startsWith(q)) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java
index d59e869a2..056579256 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java
@@ -750,4 +750,4 @@ public class LocationActivityAdapter extends BaseLocationAdapter implements Loca
private int getThemedColor(int key) {
return Theme.getColor(key, resourcesProvider);
}
-}
+}
\ No newline at end of file
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java
index 3e34c6c8b..723e9de94 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java
@@ -3636,7 +3636,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} else {
webPageUrl = adapter[0].currentPage.url;
}
- Browser.openUrl(parentActivity, webPageUrl, true, false);
+ if (parentActivity == null || parentActivity.isFinishing()) return;
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(webPageUrl));
+ intent.putExtra(android.provider.Browser.EXTRA_CREATE_NEW_TAB, true);
+ intent.putExtra(android.provider.Browser.EXTRA_APPLICATION_ID, parentActivity.getPackageName());
+ parentActivity.startActivity(intent);
} else if (id == settings_item) {
BottomSheet.Builder builder = new BottomSheet.Builder(parentActivity);
builder.setApplyTopPadding(false);
@@ -7131,7 +7135,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
}
if (currentBlock.date != 0) {
- dateLayout = createLayoutForText(this, LocaleController.getInstance().chatFullDate.format((long) currentBlock.date * 1000), null, width - AndroidUtilities.dp(36 + 14 + (avatarVisible ? 40 + 14 : 0)), AndroidUtilities.dp(29), currentBlock, parentAdapter);
+ dateLayout = createLayoutForText(this, LocaleController.getInstance().getChatFullDate().format((long) currentBlock.date * 1000), null, width - AndroidUtilities.dp(36 + 14 + (avatarVisible ? 40 + 14 : 0)), AndroidUtilities.dp(29), currentBlock, parentAdapter);
} else {
dateLayout = null;
}
@@ -9682,11 +9686,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
}
String description;
if (item.published_date != 0 && !TextUtils.isEmpty(item.author)) {
- description = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format((long) item.published_date * 1000), item.author);
+ description = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().getChatFullDate().format((long) item.published_date * 1000), item.author);
} else if (!TextUtils.isEmpty(item.author)) {
description = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, item.author);
} else if (item.published_date != 0) {
- description = LocaleController.getInstance().chatFullDate.format((long) item.published_date * 1000);
+ description = LocaleController.getInstance().getChatFullDate().format((long) item.published_date * 1000);
} else if (!TextUtils.isEmpty(item.description)) {
description = item.description;
} else {
@@ -10960,11 +10964,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
spans = null;
}
if (currentBlock.published_date != 0 && !TextUtils.isEmpty(author)) {
- text = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().chatFullDate.format((long) currentBlock.published_date * 1000), author);
+ text = LocaleController.formatString("ArticleDateByAuthor", R.string.ArticleDateByAuthor, LocaleController.getInstance().getChatFullDate().format((long) currentBlock.published_date * 1000), author);
} else if (!TextUtils.isEmpty(author)) {
text = LocaleController.formatString("ArticleByAuthor", R.string.ArticleByAuthor, author);
} else {
- text = LocaleController.getInstance().chatFullDate.format((long) currentBlock.published_date * 1000);
+ text = LocaleController.getInstance().getChatFullDate().format((long) currentBlock.published_date * 1000);
}
try {
if (spans != null && spans.length > 0) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Business/OpeningHoursActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/Business/OpeningHoursActivity.java
index f1c722f4e..1a2245e93 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Business/OpeningHoursActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Business/OpeningHoursActivity.java
@@ -468,7 +468,7 @@ public class OpeningHoursActivity extends BaseFragment implements NotificationCe
int hours = (time - min) / 60 % 24;
Calendar rightNow = Calendar.getInstance();
rightNow.set(0, 0, 0, hours, min);
- String str = LocaleController.getInstance().formatterConstDay.format(rightNow.getTime());
+ String str = LocaleController.getInstance().getFormatterConstDay().format(rightNow.getTime());
if (time > 24 * 60 && includeNextDay) {
return LocaleController.formatString(R.string.BusinessHoursNextDay, str);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
index 99fc13803..f01b19544 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
@@ -62,7 +62,6 @@ import android.text.style.CharacterStyle;
import android.text.style.ClickableSpan;
import android.text.style.LeadingMarginSpan;
import android.text.style.URLSpan;
-import android.util.Log;
import android.util.Pair;
import android.util.Property;
import android.util.SparseArray;
@@ -462,7 +461,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
- default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
+ default void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY, boolean asForward) {
}
default boolean didLongPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
@@ -481,7 +480,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
default void didPressBoostCounter(ChatMessageCell cell) {
}
- default void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
+ default void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY, boolean asForward) {
}
default boolean didLongPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
@@ -903,6 +902,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
private AvatarSpan forwardAvatar;
private ForwardBackground forwardBg;
+ private LoadingDrawable forwardLoading;
public boolean linkPreviewAbove;
public boolean captionAbove;
private boolean isSmallImage;
@@ -1831,7 +1831,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name);
}
} else if (currentUser != null) {
- delegate.didPressUserAvatar(this, currentUser, event.getX(), event.getY());
+ delegate.didPressUserAvatar(this, currentUser, event.getX(), event.getY(), false);
} else if (currentChat != null) {
int id;
TLRPC.Chat chat = currentChat;
@@ -1845,7 +1845,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
id = 0;
}
- delegate.didPressChannelAvatar(this, chat != null ? chat : currentChat, id, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(this, chat != null ? chat : currentChat, id, lastTouchX, lastTouchY, false);
}
}
}
@@ -4133,7 +4133,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (currentUser.id == 0) {
delegate.didPressHiddenForward(this);
} else {
- delegate.didPressUserAvatar(this, currentUser, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(this, currentUser, lastTouchX, lastTouchY, false);
}
} else if (currentChat != null) {
int id;
@@ -4148,7 +4148,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
id = 0;
}
- delegate.didPressChannelAvatar(this, chat != null ? chat : currentChat, id, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(this, chat != null ? chat : currentChat, id, lastTouchX, lastTouchY, false);
} else if (currentMessageObject != null) {
delegate.didPressInstantButton(this, drawInstantViewType);
}
@@ -4183,9 +4183,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (currentMessageObject.messageOwner.fwd_from != null) {
postId = currentMessageObject.messageOwner.fwd_from.channel_post;
}
- delegate.didPressChannelAvatar(this, currentForwardChannel, postId, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(this, currentForwardChannel, postId, lastTouchX, lastTouchY, true);
} else if (currentForwardUser != null) {
- delegate.didPressUserAvatar(this, currentForwardUser, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(this, currentForwardUser, lastTouchX, lastTouchY, true);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(this);
}
@@ -4251,9 +4251,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (replyPanelIsForward) {
if (delegate != null) {
if (currentForwardChannel != null) {
- delegate.didPressChannelAvatar(this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY, false);
} else if (currentForwardUser != null) {
- delegate.didPressUserAvatar(this, currentForwardUser, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(this, currentForwardUser, lastTouchX, lastTouchY, false);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(this);
}
@@ -4821,7 +4821,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (uid != 0) {
user = MessagesController.getInstance(currentAccount).getUser(uid);
}
- delegate.didPressUserAvatar(this, user, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(this, user, lastTouchX, lastTouchY, false);
} else if (currentMessageObject.type == MessageObject.TYPE_ROUND_VIDEO) {
if (buttonState != -1) {
didPressButton(true, false);
@@ -7327,7 +7327,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
String text;
- String time = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
+ String time = LocaleController.getInstance().getFormatterDay().format((long) (messageObject.messageOwner.date) * 1000);
TLRPC.TL_messageActionPhoneCall call = (TLRPC.TL_messageActionPhoneCall) messageObject.messageOwner.action;
boolean isMissed = call.reason instanceof TLRPC.TL_phoneCallDiscardReasonMissed;
if (messageObject.isOutOwner()) {
@@ -7887,21 +7887,19 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
groupMedia.setOverrideWidth(-1);
groupMedia.setMessageObject(messageObject, pinnedBottom, pinnedTop);
backgroundWidth = groupMedia.width + dp(8 + 9);
+ availableTimeWidth = backgroundWidth - AndroidUtilities.dp(31);
measureTime(messageObject);
- if (drawCommentButton && totalCommentWidth + AndroidUtilities.dp(20) > backgroundWidth) {
- backgroundWidth = totalCommentWidth + AndroidUtilities.dp(20);
+ if (drawCommentButton && totalCommentWidth + AndroidUtilities.dp(28) > backgroundWidth) {
+ backgroundWidth = totalCommentWidth + AndroidUtilities.dp(28);
groupMedia.setOverrideWidth(backgroundWidth - dp(8 + 9));
}
- if (timeWidth + dp(25) > backgroundWidth) {
- backgroundWidth = timeWidth + dp(25);
+ int timeWidthTotal = timeWidth + dp((SharedConfig.bubbleRadius >= 10 ? 22 : 18) + (messageObject.isOutOwner() ? 20 : 0) + 20);
+ if (timeWidthTotal > backgroundWidth) {
+ backgroundWidth = timeWidthTotal;
groupMedia.setOverrideWidth(backgroundWidth - dp(8 + 9));
}
mediaBackground = false;
- int timeWidthTotal = timeWidth + AndroidUtilities.dp((SharedConfig.bubbleRadius >= 10 ? 22 : 18) + (messageObject.isOutOwner() ? 20 : 0));
- if (backgroundWidth < timeWidthTotal) {
- backgroundWidth = timeWidthTotal;
- }
int widthForCaption = backgroundWidth - dp(20);
int additionHeight = 0;
@@ -7982,7 +7980,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
reactionsLayoutInBubble.positionOffsetY -= AndroidUtilities.dp(12);
}
if (!messageObject.isRestrictedMessage && messageObject.caption != null) {
- reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(14);
+ reactionsLayoutInBubble.positionOffsetY += AndroidUtilities.dp(!drawCommentButton ? 14 : 1);
}
totalHeight += reactionsLayoutInBubble.totalHeight;
}
@@ -9780,7 +9778,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
Activity activity = AndroidUtilities.findActivity(getContext());
Window window = activity == null ? null : activity.getWindow();
if (window != null) {
- flagSecure = new FlagSecureReason(window, () -> currentMessageObject != null && currentMessageObject.messageOwner != null && (currentMessageObject.messageOwner.noforwards || currentMessageObject.isVoiceOnce() || currentMessageObject.hasRevealedExtendedMedia()));
+ flagSecure = new FlagSecureReason(window, () -> currentMessageObject != null && currentMessageObject.messageOwner != null && (currentMessageObject.type == MessageObject.TYPE_PAID_MEDIA || currentMessageObject.messageOwner.noforwards || currentMessageObject.isVoiceOnce() || currentMessageObject.hasRevealedExtendedMedia()));
if (attachedToWindow) {
flagSecure.attach();
}
@@ -15687,11 +15685,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (currentMessageObject.scheduled && currentMessageObject.messageOwner.date == 0x7FFFFFFE) {
timeString = "";
} else if (currentMessageObject.realDate != 0) {
- timeString = LocaleController.formatSmallDateChat(currentMessageObject.realDate) + ", " + LocaleController.getInstance().formatterDay.format((long) (currentMessageObject.realDate) * 1000);
+ timeString = LocaleController.formatSmallDateChat(currentMessageObject.realDate) + ", " + LocaleController.getInstance().getFormatterDay().format((long) (currentMessageObject.realDate) * 1000);
} else if (currentMessageObject.isRepostPreview) {
- timeString = LocaleController.formatSmallDateChat(messageObject.messageOwner.date) + ", " + LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
+ timeString = LocaleController.formatSmallDateChat(messageObject.messageOwner.date) + ", " + LocaleController.getInstance().getFormatterDay().format((long) (messageObject.messageOwner.date) * 1000);
} else if (edited) {
- timeString = getString("EditedMessage", R.string.EditedMessage) + " " + LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
+ timeString = getString("EditedMessage", R.string.EditedMessage) + " " + LocaleController.getInstance().getFormatterDay().format((long) (messageObject.messageOwner.date) * 1000);
} else if (currentMessageObject.isSaved && currentMessageObject.messageOwner.fwd_from != null && (currentMessageObject.messageOwner.fwd_from.date != 0 || currentMessageObject.messageOwner.fwd_from.saved_date != 0)) {
int date = currentMessageObject.messageOwner.fwd_from.saved_date;
if (date == 0) {
@@ -15699,7 +15697,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
timeString = LocaleController.formatSeenDate(date);
} else {
- timeString = LocaleController.getInstance().formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
+ timeString = LocaleController.getInstance().getFormatterDay().format((long) (messageObject.messageOwner.date) * 1000);
}
if (signString != null) {
if (messageObject.messageOwner.via_business_bot_id != 0) {
@@ -18737,7 +18735,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
} else {
forwardNameY = AndroidUtilities.dp(7) + (drawNameLayout ? AndroidUtilities.dp(6) + (int) Theme.chat_namePaint.getTextSize() : 0) + (drawTopic && topicButton != null ? topicButton.height() + AndroidUtilities.dp(7 + (currentMessageObject.type != MessageObject.TYPE_TEXT ? 3 : 0)) : 0);
- if (!drawNameLayout && (currentMessageObject.type == MessageObject.TYPE_GIF || currentMessageObject.type == MessageObject.TYPE_PHOTO || currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == MessageObject.TYPE_STORY)) {
+ if (!drawNameLayout && (currentMessageObject.type == MessageObject.TYPE_GIF || currentMessageObject.type == MessageObject.TYPE_PHOTO || currentMessageObject.type == MessageObject.TYPE_VIDEO || currentMessageObject.type == MessageObject.TYPE_STORY || currentMessageObject.type == MessageObject.TYPE_PAID_MEDIA || currentMessageObject.type == MessageObject.TYPE_FILE)) {
forwardNameY += dp(2);
}
if (!drawNameLayout && currentMessageObject.type == MessageObject.TYPE_TEXT && !drawPinnedTop) {
@@ -18813,6 +18811,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
canvas.save();
canvas.translate(forwardNameXLocal, forwardNameY);
+ final boolean forwardLoading = delegate != null && delegate.isProgressLoading(this, ChatActivity.PROGRESS_FORWARD);
if (forwardBg != null) {
final float s = forwardBg.bounce.getScale(.02f);
canvas.scale(s, s, forwardBg.bounds.centerX(), forwardBg.bounds.centerY());
@@ -18821,7 +18820,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
forwardBg.setColor(Theme.multAlpha(Theme.chat_forwardNamePaint.getColor(), .15f));
}
- forwardBg.draw(canvas);
+ forwardBg.draw(canvas, forwardLoading);
}
for (int a = 0; a < 2; a++) {
canvas.save();
@@ -22124,9 +22123,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (action == R.id.acc_action_open_forwarded_origin) {
if (delegate != null) {
if (currentForwardChannel != null) {
- delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY, false);
} else if (currentForwardUser != null) {
- delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY, false);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(ChatMessageCell.this);
}
@@ -22475,7 +22474,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
@Override
public void onClick(@NonNull View view) {
if (delegate != null) {
- delegate.didPressUserAvatar(ChatMessageCell.this, user, 0, 0);
+ delegate.didPressUserAvatar(ChatMessageCell.this, user, 0, 0, false);
}
}
}
@@ -23162,7 +23161,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (action == AccessibilityNodeInfo.ACTION_CLICK) {
if (virtualViewId == PROFILE) {
if (delegate != null) {
- delegate.didPressUserAvatar(ChatMessageCell.this, currentUser, 0, 0);
+ delegate.didPressUserAvatar(ChatMessageCell.this, currentUser, 0, 0, false);
}
} else if (virtualViewId >= LINK_CAPTION_IDS_START) {
ClickableSpan link = getLinkById(virtualViewId, true);
@@ -23235,9 +23234,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else if (virtualViewId == FORWARD) {
if (delegate != null) {
if (currentForwardChannel != null) {
- delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY);
+ delegate.didPressChannelAvatar(ChatMessageCell.this, currentForwardChannel, currentMessageObject.messageOwner.fwd_from.channel_post, lastTouchX, lastTouchY, false);
} else if (currentForwardUser != null) {
- delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY);
+ delegate.didPressUserAvatar(ChatMessageCell.this, currentForwardUser, lastTouchX, lastTouchY, false);
} else if (currentForwardName != null) {
delegate.didPressHiddenForward(ChatMessageCell.this);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
index 7d5ab04e1..aebf3e876 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
@@ -27,6 +27,8 @@ import android.view.MotionEvent;
import androidx.annotation.NonNull;
import androidx.collection.LongSparseArray;
+import com.google.android.exoplayer2.offline.Download;
+
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DownloadController;
import org.telegram.messenger.FileLoader;
@@ -36,6 +38,7 @@ import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessageObject.GroupedMessagePosition;
+import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.Utilities;
@@ -597,15 +600,11 @@ public class GroupMedia {
if (messageObject.isSending()) {
SendMessagesHelper sendMessagesHelper = SendMessagesHelper.getInstance(messageObject.currentAccount);
long[] progress = ImageLoader.getInstance().getFileProgressSizes(h.attachPath);
- float loadingProgress = 0;
- boolean sending = sendMessagesHelper.isSendingMessage(messageObject.getId());
+ final boolean sending = sendMessagesHelper.isSendingPaidMessage(messageObject.getId(), i);
if (progress == null && sending) {
- loadingProgress = 1.0f;
- } else if (progress != null) {
- loadingProgress = DownloadController.getProgress(progress);
+ h.radialProgress.setProgress(1.0f, true);
+ h.setIcon(h.album ? MediaActionDrawable.ICON_CHECK : h.getDefaultIcon());
}
- h.radialProgress.setProgress(loadingProgress, false);
- h.setIcon(sending && loadingProgress < 1.0f ? MediaActionDrawable.ICON_CANCEL : (h.album ? MediaActionDrawable.ICON_CHECK : h.getDefaultIcon()));
} else if (FileLoader.getInstance(messageObject.currentAccount).isLoadingFile(h.filename)) {
h.setIcon(MediaActionDrawable.ICON_CANCEL);
} else {
@@ -620,7 +619,7 @@ public class GroupMedia {
canvas.clipPath(clipPath2);
canvas.translate(l, t);
canvas.saveLayerAlpha(0, 0, (int) (r - l), (int) (b - t), (int) (0xFF * hiddenAlpha), Canvas.ALL_SAVE_FLAG);
- spoilerEffect.draw(canvas, cell, (int) (r - l), (int) (b - t), 1f);
+ spoilerEffect.draw(canvas, cell, (int) (r - l), (int) (b - t), 1f, cell.drawingToBitmap);
canvas.restore();
canvas.restore();
cell.invalidate();
@@ -734,7 +733,7 @@ public class GroupMedia {
this.media = media;
autoplay = false;
- final String filter = w + "_" + h;
+ String filter = w + "_" + h;
if (media instanceof TLRPC.TL_messageExtendedMediaPreview) {
hidden = true;
filename = null;
@@ -747,7 +746,11 @@ public class GroupMedia {
AndroidUtilities.adjustBrightnessColorMatrix(colorMatrix, -.1f);
this.imageReceiver.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
} else if (media instanceof TLRPC.TL_messageExtendedMedia) {
- hidden = false;
+ hidden = msg.isRepostPreview;
+ if (hidden) {
+ filter += "_b3";
+ }
+ final int cacheType = 0;
this.imageReceiver.setColorFilter(null);
@@ -760,23 +763,15 @@ public class GroupMedia {
TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(mediaPhoto.photo.sizes, Math.min(w, h) / 100, false, photoSize, false);
ImageLocation photoLocation = ImageLocation.getForPhoto(photoSize, mediaPhoto.photo);
ImageLocation thumbLocation = ImageLocation.getForPhoto(thumbSize, mediaPhoto.photo);
-// if (msg.isSending()) {
-// sendingPhotoLocation = photoLocation;
-// sendingPhotoLocationDialogId = msg.getDialogId();
-// sendingPhotoLocationMessageId = msg.getId();
-// }
-// if (sendingPhotoLocation != null && sendingPhotoLocationDialogId == msg.getDialogId() && sendingPhotoLocationMessageId == msg.getId()) {
-// thumbLocation = sendingPhotoLocation;
-// }
imageReceiver.setImage(
photoLocation, filter,
thumbLocation, filter,
0, null,
- msg, 0
+ msg, cacheType
);
} else if (messageMedia instanceof TLRPC.TL_messageMediaDocument) {
TLRPC.TL_messageMediaDocument mediaDocument = (TLRPC.TL_messageMediaDocument) messageMedia;
- autoplay = !album && video && SharedConfig.isAutoplayVideo();
+ autoplay = !hidden && !album && video && SharedConfig.isAutoplayVideo();
// if (!TextUtils.isEmpty(extMedia.attachPath)) {
// imageReceiver.setImage(ImageLocation.getForPath(extMedia.attachPath), filter + (autoplay ? "_g" : ""), null, null, msg, 0);
// return;
@@ -788,20 +783,12 @@ public class GroupMedia {
ImageLocation mediaLocation = ImageLocation.getForDocument(mediaDocument.document);
ImageLocation photoLocation = ImageLocation.getForDocument(photoSize, mediaDocument.document);
ImageLocation thumbLocation = ImageLocation.getForDocument(thumbSize, mediaDocument.document);
-// if (msg.isSending()) {
-// sendingPhotoLocation = photoLocation;
-// sendingPhotoLocationDialogId = msg.getDialogId();
-// sendingPhotoLocationMessageId = msg.getId();
-// }
-// if (sendingPhotoLocation != null && sendingPhotoLocationDialogId == msg.getDialogId() && sendingPhotoLocationMessageId == msg.getId()) {
-// thumbLocation = sendingPhotoLocation;
-// }
imageReceiver.setImage(
- mediaLocation, filter + (autoplay ? "_g" : ""),
+ autoplay ? mediaLocation : null, filter + (autoplay ? "_g" : ""),
photoLocation, filter,
- thumbLocation, filter, null,
+ thumbLocation, filter, null,
0, null,
- msg, 0
+ msg, cacheType
);
return;
}
@@ -811,19 +798,11 @@ public class GroupMedia {
TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(mediaDocument.document.thumbs, Math.min(w, h), false, photoSize, false);
ImageLocation photoLocation = ImageLocation.getForDocument(photoSize, mediaDocument.document);
ImageLocation thumbLocation = ImageLocation.getForDocument(thumbSize, mediaDocument.document);
-// if (msg.isSending()) {
-// sendingPhotoLocation = photoLocation;
-// sendingPhotoLocationDialogId = msg.getDialogId();
-// sendingPhotoLocationMessageId = msg.getId();
-// }
-// if (sendingPhotoLocation != null && sendingPhotoLocationDialogId == msg.getDialogId() && sendingPhotoLocationMessageId == msg.getId()) {
-// thumbLocation = sendingPhotoLocation;
-// }
imageReceiver.setImage(
photoLocation, filter,
thumbLocation, filter,
0, null,
- msg, 0
+ msg, cacheType
);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPhotoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPhotoCell.java
index b85e84fa8..7bc80f65e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPhotoCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoAttachPhotoCell.java
@@ -669,7 +669,7 @@ public class PhotoAttachPhotoCell extends FrameLayout {
}
if (photoEntry != null) {
sb.append(". ");
- sb.append(LocaleController.getInstance().formatterStats.format(photoEntry.dateTaken * 1000L));
+ sb.append(LocaleController.getInstance().getFormatterStats().format(photoEntry.dateTaken * 1000L));
}
info.setText(sb);
if (checkBox.isChecked()) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
index c12c3e08b..4d86e920c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
@@ -357,7 +357,7 @@ public class SharedDocumentCell extends FrameLayout implements DownloadControlle
if (builder.length() > 0) {
builder.append(", ");
}
- builder.append(LocaleController.getInstance().formatterStats.format(entry.dateTaken));
+ builder.append(LocaleController.getInstance().getFormatterStats().format(entry.dateTaken));
dateTextView.setText(builder);
placeholderImageView.setVisibility(GONE);
}
@@ -518,7 +518,7 @@ public class SharedDocumentCell extends FrameLayout implements DownloadControlle
.append(fromName));
rightDateTextView.setText(LocaleController.stringForMessageListDate(message.messageOwner.date));
} else {
- dateTextView.setText(String.format("%s, %s", fileSize, LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)))));
+ dateTextView.setText(String.format("%s, %s", fileSize, LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().getFormatterYear().format(new Date(date)), LocaleController.getInstance().getFormatterDay().format(new Date(date)))));
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StatisticPostInfoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StatisticPostInfoCell.java
index d7b4a8a7d..b07209417 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StatisticPostInfoCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StatisticPostInfoCell.java
@@ -235,8 +235,8 @@ public class StatisticPostInfoCell extends FrameLayout {
views.setText(String.format(LocaleController.getPluralString("Views", postInfo.getViews()), AndroidUtilities.formatWholeNumber(postInfo.getViews(), 0)));
Date time = new Date(postInfo.getDate() * 1000L);
- String monthTxt = LocaleController.getInstance().formatterYear.format(time);
- String timeTxt = LocaleController.getInstance().formatterDay.format(time);
+ String monthTxt = LocaleController.getInstance().getFormatterYear().format(time);
+ String timeTxt = LocaleController.getInstance().getFormatterDay().format(time);
date.setText(LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, monthTxt, timeTxt));
shares.setText(AndroidUtilities.formatWholeNumber(postInfo.getForwards(), 0));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java
index b9701ad30..d6486e2ac 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelAdminLogActivity.java
@@ -2432,6 +2432,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
@Override
public void onRemoveFromParent() {
MediaController.getInstance().setTextureView(videoTextureView, null, null, false);
+ super.onRemoveFromParent();
}
private void hideFloatingDateView(boolean animated) {
@@ -2903,7 +2904,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
}
@Override
- public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
+ public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY, boolean asForward) {
if (chat != null && chat != currentChat) {
Bundle args = new Bundle();
args.putLong("chat_id", chat.id);
@@ -2922,7 +2923,7 @@ public class ChannelAdminLogActivity extends BaseFragment implements Notificatio
}
@Override
- public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
+ public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY, boolean asForward) {
if (user != null && user.id != UserConfig.getInstance(currentAccount).getClientUserId()) {
openProfile(user);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java
index 33367fd79..68d9e680f 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java
@@ -114,6 +114,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
private final CharSequence titleInfo;
private final CharSequence balanceInfo;
+ private final CharSequence proceedsInfo;
private final CharSequence starsBalanceInfo;
private final LinearLayout balanceLayout;
@@ -154,15 +155,24 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
}
}
+ public final boolean tonRevenueAvailable;
+ public final boolean starsRevenueAvailable;
+
public ChannelMonetizationLayout(
Context context,
BaseFragment fragment,
int currentAccount,
long dialogId,
- Theme.ResourcesProvider resourcesProvider
+ Theme.ResourcesProvider resourcesProvider,
+
+ boolean tonRevenueAvailable,
+ boolean starsRevenueAvailable
) {
super(context);
+ this.tonRevenueAvailable = tonRevenueAvailable;
+ this.starsRevenueAvailable = starsRevenueAvailable;
+
DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US);
symbols.setDecimalSeparator('.');
formatter = new DecimalFormat("#.##", symbols);
@@ -183,6 +193,9 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
balanceInfo = AndroidUtilities.replaceArrows(AndroidUtilities.replaceSingleTag(getString(MessagesController.getInstance(currentAccount).channelRevenueWithdrawalEnabled ? R.string.MonetizationBalanceInfo : R.string.MonetizationBalanceInfoNotAvailable), -1, REPLACING_TAG_TYPE_LINK_NBSP, () -> {
Browser.openUrl(getContext(), getString(R.string.MonetizationBalanceInfoLink));
}), true);
+ proceedsInfo = AndroidUtilities.replaceArrows(AndroidUtilities.replaceSingleTag(getString(R.string.MonetizationProceedsInfo), -1, REPLACING_TAG_TYPE_LINK_NBSP, () -> {
+ Browser.openUrl(getContext(), getString(R.string.MonetizationProceedsInfoLink));
+ }, resourcesProvider), true);
starsBalanceInfo = AndroidUtilities.replaceArrows(AndroidUtilities.replaceSingleTag(getString(R.string.MonetizationStarsInfo), () -> {
Browser.openUrl(getContext(), getString(R.string.MonetizationStarsInfoLink));
}), true);
@@ -680,6 +693,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
private double stars_rate;
private void loadStarsStats() {
+ if (!starsRevenueAvailable) return;
TLRPC.TL_payments_getStarsRevenueStats req2 = new TLRPC.TL_payments_getStarsRevenueStats();
req2.peer = MessagesController.getInstance(currentAccount).getInputPeer(dialogId);
req2.dark = Theme.isCurrentThemeDark();
@@ -695,6 +709,12 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
}
setupBalances(stats.status);
+ if (!tonRevenueAvailable) {
+ progress.animate().alpha(0).setDuration(380).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).withEndAction(() -> {
+ progress.setVisibility(View.GONE);
+ }).start();
+ }
+
if (listView != null) {
listView.adapter.update(true);
}
@@ -719,58 +739,63 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
loadStarsStats();
- TLObject req;
- if (ChatObject.isMegagroup(chat)) {
- return;
- } else {
- TL_stats.TL_getBroadcastRevenueStats getBroadcastStats = new TL_stats.TL_getBroadcastRevenueStats();
- getBroadcastStats.dark = Theme.isCurrentThemeDark();
- getBroadcastStats.channel = MessagesController.getInstance(currentAccount).getInputChannel(-dialogId);
- req = getBroadcastStats;
- }
- int stats_dc = -1;
- TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-dialogId);
- if (chatFull != null) {
- stats_dc = chatFull.stats_dc;
- initialSwitchOffValue = switchOffValue = chatFull.restricted_sponsored;
- }
- if (stats_dc == -1) return;
- ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
- if (res instanceof TL_stats.TL_broadcastRevenueStats) {
- TL_stats.TL_broadcastRevenueStats stats = (TL_stats.TL_broadcastRevenueStats) res;
-
- impressionsChart = StatisticActivity.createViewData(stats.top_hours_graph, getString(R.string.MonetizationGraphImpressions), 0);
- if (stats.revenue_graph != null) {
- stats.revenue_graph.rate = (float) (1_000_000_000.0 / 100.0 / stats.usd_rate);
- }
- revenueChart = StatisticActivity.createViewData(stats.revenue_graph, getString(R.string.MonetizationGraphRevenue), 2);
- if (impressionsChart != null) {
- impressionsChart.useHourFormat = true;
- }
-
- ton_rate = stats.usd_rate;
- setupBalances(stats.balances);
-
- progress.animate().alpha(0).setDuration(380).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).withEndAction(() -> {
- progress.setVisibility(View.GONE);
- }).start();
-
- checkLearnSheet();
+ if (tonRevenueAvailable) {
+ TLObject req;
+ if (ChatObject.isMegagroup(chat)) {
+ return;
+ } else {
+ TL_stats.TL_getBroadcastRevenueStats getBroadcastStats = new TL_stats.TL_getBroadcastRevenueStats();
+ getBroadcastStats.dark = Theme.isCurrentThemeDark();
+ getBroadcastStats.channel = MessagesController.getInstance(currentAccount).getInputChannel(-dialogId);
+ req = getBroadcastStats;
}
- }), null, null, 0, stats_dc, ConnectionsManager.ConnectionTypeGeneric, true);
+ int stats_dc = -1;
+ TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(-dialogId);
+ if (chatFull != null) {
+ stats_dc = chatFull.stats_dc;
+ initialSwitchOffValue = switchOffValue = chatFull.restricted_sponsored;
+ }
+ if (stats_dc == -1) return;
+ ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
+ if (res instanceof TL_stats.TL_broadcastRevenueStats) {
+ TL_stats.TL_broadcastRevenueStats stats = (TL_stats.TL_broadcastRevenueStats) res;
+
+ impressionsChart = StatisticActivity.createViewData(stats.top_hours_graph, getString(R.string.MonetizationGraphImpressions), 0);
+ if (stats.revenue_graph != null) {
+ stats.revenue_graph.rate = (float) (1_000_000_000.0 / 100.0 / stats.usd_rate);
+ }
+ revenueChart = StatisticActivity.createViewData(stats.revenue_graph, getString(R.string.MonetizationGraphRevenue), 2);
+ if (impressionsChart != null) {
+ impressionsChart.useHourFormat = true;
+ }
+
+ ton_rate = stats.usd_rate;
+ setupBalances(stats.balances);
+
+ progress.animate().alpha(0).setDuration(380).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).withEndAction(() -> {
+ progress.setVisibility(View.GONE);
+ }).start();
+
+ checkLearnSheet();
+ }
+ }), null, null, 0, stats_dc, ConnectionsManager.ConnectionTypeGeneric, true);
+ }
}
public void setupBalances(TLRPC.TL_broadcastRevenueBalances balances) {
if (ton_rate == 0) {
return;
}
+ availableValue.contains1 = true;
availableValue.crypto_amount = balances.available_balance;
availableValue.amount = (long) (availableValue.crypto_amount / 1_000_000_000.0 * ton_rate * 100.0);
setBalance(availableValue.crypto_amount, availableValue.amount);
availableValue.currency = "USD";
+ lastWithdrawalValue.contains1 = true;
lastWithdrawalValue.crypto_amount = balances.current_balance;
lastWithdrawalValue.amount = (long) (lastWithdrawalValue.crypto_amount / 1_000_000_000.0 * ton_rate * 100.0);
lastWithdrawalValue.currency = "USD";
+ lifetimeValue.contains1 = true;
lifetimeValue.crypto_amount = balances.overall_revenue;
lifetimeValue.amount = (long) (lifetimeValue.crypto_amount / 1_000_000_000.0 * ton_rate * 100.0);
lifetimeValue.currency = "USD";
@@ -860,16 +885,18 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
if (chatFull != null) {
stats_dc = chatFull.stats_dc;
}
- items.add(UItem.asCenterShadow(titleInfo));
- if (impressionsChart != null && !impressionsChart.isEmpty) {
- items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_BAR_LINEAR, stats_dc, impressionsChart));
- items.add(UItem.asShadow(-1, null));
+ if (tonRevenueAvailable) {
+ items.add(UItem.asCenterShadow(titleInfo));
+ if (impressionsChart != null && !impressionsChart.isEmpty) {
+ items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_BAR_LINEAR, stats_dc, impressionsChart));
+ items.add(UItem.asShadow(-1, null));
+ }
+ if (revenueChart != null && !revenueChart.isEmpty) {
+ items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_STACKBAR, stats_dc, revenueChart));
+ items.add(UItem.asShadow(-2, null));
+ }
}
- if (revenueChart != null && !revenueChart.isEmpty) {
- items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_STACKBAR, stats_dc, revenueChart));
- items.add(UItem.asShadow(-2, null));
- }
- if (starsRevenueChart != null && !starsRevenueChart.isEmpty) {
+ if (starsRevenueAvailable && starsRevenueChart != null && !starsRevenueChart.isEmpty) {
items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_STACKBAR, stats_dc, starsRevenueChart));
items.add(UItem.asShadow(-3, null));
}
@@ -878,22 +905,24 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
items.add(UItem.asProceedOverview(availableValue));
items.add(UItem.asProceedOverview(lastWithdrawalValue));
items.add(UItem.asProceedOverview(lifetimeValue));
- items.add(UItem.asShadow(-4, null));
+ items.add(UItem.asShadow(-4, proceedsInfo));
}
if (chat != null && chat.creator) {
- items.add(UItem.asBlackHeader(getString(R.string.MonetizationBalance)));
- items.add(UItem.asCustom(balanceLayout));
- items.add(UItem.asShadow(-5, balanceInfo));
- }
- if (chat != null && chat.creator) {
- final int switchOffLevel = MessagesController.getInstance(currentAccount).channelRestrictSponsoredLevelMin;
- items.add(UItem.asCheck(CHECK_SWITCHOFF, PeerColorActivity.withLevelLock(getString(R.string.MonetizationSwitchOff), currentBoostLevel < switchOffLevel ? switchOffLevel : 0)).setChecked(currentBoostLevel >= switchOffLevel && switchOffValue));
- items.add(UItem.asShadow(-8, getString(R.string.MonetizationSwitchOffInfo)));
- }
- if (chat != null && chat.creator) {
- items.add(UItem.asBlackHeader(getString(R.string.MonetizationStarsBalance)));
- items.add(UItem.asCustom(STARS_BALANCE, starsBalanceLayout));
- items.add(UItem.asShadow(-6, starsBalanceInfo));
+ if (tonRevenueAvailable) {
+ items.add(UItem.asBlackHeader(getString(R.string.MonetizationBalance)));
+ items.add(UItem.asCustom(balanceLayout));
+ items.add(UItem.asShadow(-5, balanceInfo));
+
+ final int switchOffLevel = MessagesController.getInstance(currentAccount).channelRestrictSponsoredLevelMin;
+ items.add(UItem.asCheck(CHECK_SWITCHOFF, PeerColorActivity.withLevelLock(getString(R.string.MonetizationSwitchOff), currentBoostLevel < switchOffLevel ? switchOffLevel : 0)).setChecked(currentBoostLevel >= switchOffLevel && switchOffValue));
+ items.add(UItem.asShadow(-8, getString(R.string.MonetizationSwitchOffInfo)));
+ }
+
+ if (starsRevenueAvailable) {
+ items.add(UItem.asBlackHeader(getString(R.string.MonetizationStarsBalance)));
+ items.add(UItem.asCustom(STARS_BALANCE, starsBalanceLayout));
+ items.add(UItem.asShadow(-6, starsBalanceInfo));
+ }
}
if (transactionsLayout.hasTransactions()) {
items.add(UItem.asFullscreenCustom(transactionsLayout, 0));
@@ -1047,7 +1076,14 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
final long crypto_amount = i == 0 ? value.crypto_amount : value.crypto_amount2;
final long amount = i == 0 ? value.amount : value.amount2;
- if (i == 1 && !value.contains2) continue;
+ if (i == 0 && !value.contains1) {
+ amountContainer[i].setVisibility(View.GONE);
+ continue;
+ }
+ if (i == 1 && !value.contains2) {
+ amountContainer[i].setVisibility(View.GONE);
+ continue;
+ }
CharSequence s = crypto_currency + " ";
if ("TON".equalsIgnoreCase(crypto_currency)) {
@@ -1066,6 +1102,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
cryptoAmount.setSpan(new RelativeSizeSpan(13f / 16f), index, cryptoAmount.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
+ amountContainer[i].setVisibility(View.VISIBLE);
cryptoAmountView[i].setText(cryptoAmount);
amountView[i].setText("≈" + BillingController.getInstance().formatCurrency(amount, value.currency));
}
@@ -1079,6 +1116,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
public static class ProceedOverview {
+ public boolean contains1 = true;
public String crypto_currency;
public CharSequence text;
public long crypto_amount;
@@ -1099,6 +1137,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
public static ProceedOverview as(String cryptoCurrency, String cryptoCurrency2, CharSequence text) {
ProceedOverview o = new ProceedOverview();
+ o.contains1 = false;
o.crypto_currency = cryptoCurrency;
o.crypto_currency2 = cryptoCurrency2;
o.text = text;
@@ -1552,7 +1591,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
}
}
- public static class ChannelTransactionsView extends LinearLayout {
+ public class ChannelTransactionsView extends LinearLayout {
private final int currentAccount;
private final ViewPagerFixed viewPager;
@@ -1711,7 +1750,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
final boolean hadTransactions = hasTransactions();
final boolean hadTheseTransactions = hasTransactions(type);
if (type == TON_TRANSACTIONS) {
- if (tonTransactions.size() >= tonTransactionsTotalCount && tonTransactionsTotalCount != 0)
+ if (tonTransactions.size() >= tonTransactionsTotalCount && tonTransactionsTotalCount != 0 || !tonRevenueAvailable)
return;
loadingTransactions[type] = true;
TL_stats.TL_getBroadcastRevenueTransactions req = new TL_stats.TL_getBroadcastRevenueTransactions();
@@ -1737,7 +1776,7 @@ public class ChannelMonetizationLayout extends SizeNotifierFrameLayout implement
}
}));
} else if (type == STARS_TRANSACTIONS) {
- if (starsLastOffset == null)
+ if (starsLastOffset == null || !starsRevenueAvailable)
return;
loadingTransactions[type] = true;
TLRPC.TL_payments_getStarsTransactions req = new TLRPC.TL_payments_getStarsTransactions();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHeaderView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHeaderView.java
index c1ce68b50..1c384355b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHeaderView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHeaderView.java
@@ -111,9 +111,9 @@ public class ChartHeaderView extends FrameLayout {
}
final String newText;
if (end - start >= 86400000L) {
- newText = LocaleController.getInstance().formatterYear.format(new Date(start)) + " — " + LocaleController.getInstance().formatterYear.format(new Date(end));
+ newText = LocaleController.getInstance().getFormatterYear().format(new Date(start)) + " — " + LocaleController.getInstance().getFormatterYear().format(new Date(end));
} else {
- newText = LocaleController.getInstance().formatterYear.format(new Date(start));
+ newText = LocaleController.getInstance().getFormatterYear().format(new Date(start));
}
dates.setText(newText);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
index c796d425e..5c58a8a47 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
@@ -242,7 +242,6 @@ import org.telegram.ui.Components.voip.VoIPHelper;
import org.telegram.ui.Delegates.ChatActivityMemberRequestsDelegate;
import org.telegram.ui.Stars.StarsController;
import org.telegram.ui.Stars.StarsIntroActivity;
-import org.telegram.ui.Stories.SelfStoryViewsPage;
import org.telegram.ui.Stories.StoriesListPlaceProvider;
import org.telegram.ui.Stories.StoriesUtilities;
import org.telegram.ui.Stories.recorder.HintView2;
@@ -12733,6 +12732,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
MediaController.getInstance().setTextureView(videoTextureView, null, null, false);
}
+ super.onRemoveFromParent();
}
protected void setIgnoreAttachOnPause(boolean value) {
@@ -15198,6 +15198,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public static final int PROGRESS_BOT_BUTTON = 3;
public static final int PROGRESS_GIFT = 4;
public static final int PROGRESS_PAID_MEDIA = 5;
+ public static final int PROGRESS_FORWARD = 6;
private int progressDialogAtMessageId;
private int progressDialogAtMessageType;
@@ -32766,6 +32767,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} : null;
}
+ private Browser.Progress makeProgressForForward(ChatMessageCell cell) {
+ if (progressDialogCurrent != null) {
+ progressDialogCurrent.cancel(true);
+ progressDialogCurrent = null;
+ }
+ return progressDialogCurrent = cell != null && cell.getMessageObject() != null ? new Browser.Progress() {
+ @Override
+ public void init() {
+ progressDialogAtMessageId = cell.getMessageObject().getId();
+ progressDialogAtMessageType = PROGRESS_FORWARD;
+
+ cell.invalidate();
+ }
+
+ @Override
+ public void end(boolean replaced) {
+ if (!replaced) {
+ AndroidUtilities.runOnUIThread(() -> {
+ if (progressDialogAtMessageId == cell.getMessageObject().getId()) {
+ resetProgressDialogLoading();
+ }
+ }, 240);
+ }
+ }
+ } : null;
+ }
+
private Browser.Progress makeProgressForBotButton(ChatMessageCell cell, String url) {
if (progressDialogCurrent != null) {
progressDialogCurrent.cancel(true);
@@ -35143,7 +35171,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
- public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY) {
+ public void didPressChannelAvatar(ChatMessageCell cell, TLRPC.Chat chat, int postId, float touchX, float touchY, boolean asForward) {
if (chat == null) {
return;
}
@@ -35151,7 +35179,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
processRowSelect(cell, true, touchX, touchY);
return;
}
- openChat(cell, chat, postId);
+ openChat(cell, chat, postId, asForward);
}
@Override
@@ -35247,7 +35275,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
- public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY) {
+ public void didPressUserAvatar(ChatMessageCell cell, TLRPC.User user, float touchX, float touchY, boolean asForward) {
if (actionBar.isActionModeShowed() || reportType >= 0) {
processRowSelect(cell, true, touchX, touchY);
return;
@@ -35359,7 +35387,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
break;
case OPEN_GROUP:
case OPEN_CHANNEL:
- openChat(cell, chat, 0);
+ openChat(cell, chat, 0, false);
break;
}
});
@@ -35411,7 +35439,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
- private void openChat(ChatMessageCell cell, TLRPC.Chat chat, int postId) {
+ private void openChat(ChatMessageCell cell, TLRPC.Chat chat, int postId, boolean asForward) {
if (currentChat != null && chat.id == currentChat.id) {
if (avatarContainer != null && postId == 0) {
avatarContainer.openProfile(false);
@@ -35424,8 +35452,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (postId != 0) {
args.putInt("message_id", postId);
}
- if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject())) {
- presentFragment(new ChatActivity(args));
+ Browser.Progress progress = asForward ? makeProgressForForward(cell) : null;
+ if (getMessagesController().checkCanOpenChat(args, ChatActivity.this, cell.getMessageObject(), progress)) {
+ ChatActivity chatActivity = new ChatActivity(args);
+ if (progress != null && postId != 0) {
+ progress.onCancel(getMessagesController().ensureMessagesLoaded(-chat.id, postId, new MessagesController.MessagesLoadedCallback() {
+ @Override
+ public void onMessagesLoaded(boolean fromCache) {
+ progress.end();
+ presentFragment(chatActivity);
+ }
+ @Override
+ public void onError() {
+ progress.end();
+ presentFragment(chatActivity);
+ }
+ }));
+ progress.init();
+ } else {
+ presentFragment(chatActivity);
+ }
}
}
}
@@ -36071,7 +36117,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!safe && !Browser.isInternalUri(uri, null)) {
AlertsCreator.showOpenUrlAlert(ChatActivity.this, url, true, true, true, !safe, progressDialogCurrent, themeDelegate);
} else {
- Browser.openUrl(getContext(), uri, true, true, false, progressDialogCurrent);
+ Browser.openUrl(getContext(), uri, true, true, false, progressDialogCurrent, null);
}
}
@@ -36682,7 +36728,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
}
- Browser.openUrl(getParentActivity(), Uri.parse(webPage.url), true, true, false, progressDialogCurrent);
+ Browser.openUrl(getParentActivity(), Uri.parse(webPage.url), true, true, false, progressDialogCurrent, null);
} else {
if (messageObject.isSponsored()) {
logSponsoredClicked(messageObject);
@@ -36707,7 +36753,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
};
- Browser.openUrl(getContext(), Uri.parse(messageObject.sponsoredUrl), true, false, false, progressDialogCurrent);
+ Browser.openUrl(getContext(), Uri.parse(messageObject.sponsoredUrl), true, false, false, progressDialogCurrent, null);
}
} else {
TLRPC.WebPage webPage = messageObject.getStoryMentionWebpage();
@@ -36751,7 +36797,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
};
- Browser.openUrl(getParentActivity(), Uri.parse(webPage.url), true, true, false, progressDialogCurrent);
+ Browser.openUrl(getParentActivity(), Uri.parse(webPage.url), true, true, false, progressDialogCurrent, null);
}
}
}
@@ -39015,17 +39061,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (getContext() == null || !ThanosEffect.supports() || chatListView == null || contentView == null) {
return null;
}
- chatListThanosEffect = new ThanosEffect(getContext(), () -> {
- if (removingFromParent) {
+ final ThanosEffect[] thisThanosEffect = new ThanosEffect[1];
+ final ThanosEffect thanosEffect = new ThanosEffect(getContext(), () -> {
+ if (removingFromParent || thisThanosEffect[0] == null) {
return;
}
- ThanosEffect thisThanosEffect = chatListThanosEffect;
- if (thisThanosEffect != null) {
+ ThanosEffect effect = thisThanosEffect[0];
+ AndroidUtilities.removeFromParent(effect);
+ thisThanosEffect[0] = null;
+ if (chatListThanosEffect == effect) {
chatListThanosEffect = null;
- contentView.removeView(thisThanosEffect);
}
});
- contentView.addView(chatListThanosEffect, 1 + contentView.indexOfChild(chatListView), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
+ thisThanosEffect[0] = chatListThanosEffect = thanosEffect;
+ contentView.addView(thanosEffect, 1 + contentView.indexOfChild(chatListView), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
return chatListThanosEffect;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
index f93b769df..e4cf205c0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java
@@ -1200,7 +1200,7 @@ public class AlertsCreator {
}
long inlineReturn = (fragment instanceof ChatActivity) ? ((ChatActivity) fragment).getInlineReturn() : 0;
if (Browser.isInternalUrl(url, null) || !ask) {
- Browser.openUrl(fragment.getParentActivity(), Uri.parse(url), inlineReturn == 0, tryTelegraph, forceNotInternalForApps && checkInternalBotApp(url), progress);
+ Browser.openUrl(fragment.getParentActivity(), Uri.parse(url), inlineReturn == 0, tryTelegraph, forceNotInternalForApps && checkInternalBotApp(url), progress, null);
} else {
String urlFinal;
if (punycode) {
@@ -3046,7 +3046,7 @@ public class AlertsCreator {
} else if (type == 3) {
num += 9;
}
- button.setText(LocaleController.getInstance().formatterScheduleSend[num].format(time));
+ button.setText(LocaleController.getInstance().getFormatterScheduleSend(num).format(time));
}
if (infoText != null) {
int diff = (int) ((time - systemTime) / 1000);
@@ -3294,12 +3294,12 @@ public class AlertsCreator {
int year = calendar.get(Calendar.YEAR);
if (year == currentYear) {
return (
- LocaleController.getInstance().formatterWeek.format(date) +
+ LocaleController.getInstance().getFormatterWeek().format(date) +
", " +
- LocaleController.getInstance().formatterScheduleDay.format(date)
+ LocaleController.getInstance().getFormatterScheduleDay().format(date)
);
} else {
- return LocaleController.getInstance().formatterScheduleYear.format(date);
+ return LocaleController.getInstance().getFormatterScheduleYear().format(date);
}
}
});
@@ -3478,9 +3478,9 @@ public class AlertsCreator {
calendar.setTimeInMillis(date);
int year = calendar.get(Calendar.YEAR);
if (year == currentYear) {
- return LocaleController.getInstance().formatterScheduleDay.format(date);
+ return LocaleController.getInstance().getFormatterScheduleDay().format(date);
} else {
- return LocaleController.getInstance().formatterScheduleYear.format(date);
+ return LocaleController.getInstance().getFormatterScheduleYear().format(date);
}
}
});
@@ -3908,11 +3908,11 @@ public class AlertsCreator {
int year = calendar.get(Calendar.YEAR);
int yearDay = calendar.get(Calendar.DAY_OF_YEAR);
if (year == currentYear && yearDay < currentDayYear + 7) {
- return LocaleController.getInstance().formatterWeek.format(date) + ", " + LocaleController.getInstance().formatterScheduleDay.format(date);
+ return LocaleController.getInstance().getFormatterWeek().format(date) + ", " + LocaleController.getInstance().getFormatterScheduleDay().format(date);
} else if (year == currentYear) {
- return LocaleController.getInstance().formatterScheduleDay.format(date);
+ return LocaleController.getInstance().getFormatterScheduleDay().format(date);
} else {
- return LocaleController.getInstance().formatterScheduleYear.format(date);
+ return LocaleController.getInstance().getFormatterScheduleYear().format(date);
}
}
});
@@ -6343,7 +6343,7 @@ public class AlertsCreator {
if (isActiveGiveawayAndOwner) {
TLRPC.TL_messageMediaGiveaway giveaway = (TLRPC.TL_messageMediaGiveaway) selectedMessage.messageOwner.media;
long untilDate = giveaway.until_date * 1000L;
- giveawayEndDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(untilDate));
+ giveawayEndDate = LocaleController.getInstance().getFormatterGiveawayMonthDayYear().format(new Date(untilDate));
isActiveGiveawayAndOwner = System.currentTimeMillis() < untilDate;
}
} else if (count == 1) {
@@ -6354,7 +6354,7 @@ public class AlertsCreator {
if (isActiveGiveawayAndOwner) {
TLRPC.TL_messageMediaGiveaway giveaway = (TLRPC.TL_messageMediaGiveaway) msg.messageOwner.media;
long untilDate = giveaway.until_date * 1000L;
- giveawayEndDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(untilDate));
+ giveawayEndDate = LocaleController.getInstance().getFormatterGiveawayMonthDayYear().format(new Date(untilDate));
isActiveGiveawayAndOwner = System.currentTimeMillis() < untilDate;
}
}
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 7c88af13c..7a7784c8b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AnimatedFileDrawable.java
@@ -122,10 +122,10 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable,
private RectF actualDrawRect = new RectF();
- private BitmapShader[] renderingShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private BitmapShader[] nextRenderingShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private BitmapShader[] nextRenderingShader2 = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private BitmapShader[] backgroundShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final BitmapShader[] renderingShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final BitmapShader[] nextRenderingShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final BitmapShader[] nextRenderingShader2 = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final BitmapShader[] backgroundShader = new BitmapShader[1 + DrawingInBackgroundThreadDrawable.THREAD_COUNT];
ArrayList unusedBitmaps = new ArrayList<>();
private BitmapShader renderingShaderBackgroundDraw;
@@ -155,15 +155,15 @@ public class AnimatedFileDrawable extends BitmapDrawable implements Animatable,
private float scaleFactor = 1f;
public boolean isWebmSticker;
private final TLRPC.Document document;
- private RectF[] dstRectBackground = new RectF[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private Paint[] backgroundPaint = new Paint[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private Matrix[] shaderMatrixBackground = new Matrix[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
- private Path[] roundPathBackground = new Path[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final RectF[] dstRectBackground = new RectF[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final Paint[] backgroundPaint = new Paint[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final Matrix[] shaderMatrixBackground = new Matrix[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
+ private final Path[] roundPathBackground = new Path[DrawingInBackgroundThreadDrawable.THREAD_COUNT];
private View parentView;
- private ArrayList secondParentViews = new ArrayList<>();
+ private final ArrayList secondParentViews = new ArrayList<>();
- private ArrayList parents = new ArrayList<>();
+ private final ArrayList parents = new ArrayList<>();
private AnimatedFileDrawableStream stream;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
index 8695d3a6a..51254b467 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AudioPlayerAlert.java
@@ -1608,16 +1608,18 @@ public class AudioPlayerAlert extends BottomSheet implements NotificationCenter.
blurredAnimationInProgress = true;
BaseFragment fragment = parentActivity.getActionBarLayout().getFragmentStack().get(parentActivity.getActionBarLayout().getFragmentStack().size() - 1);
View fragmentView = fragment.getFragmentView();
- int w = (int) (fragmentView.getMeasuredWidth() / 6.0f);
- int h = (int) (fragmentView.getMeasuredHeight() / 6.0f);
- Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
- canvas.scale(1.0f / 6.0f, 1.0f / 6.0f);
- fragmentView.draw(canvas);
- canvas.translate(containerView.getLeft() - getLeftInset(), 0);
- containerView.draw(canvas);
- Utilities.stackBlurBitmap(bitmap, Math.max(7, Math.max(w, h) / 180));
- blurredView.setBackground(new BitmapDrawable(bitmap));
+ if (fragmentView != null) {
+ int w = (int) (fragmentView.getMeasuredWidth() / 6.0f);
+ int h = (int) (fragmentView.getMeasuredHeight() / 6.0f);
+ Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+ canvas.scale(1.0f / 6.0f, 1.0f / 6.0f);
+ fragmentView.draw(canvas);
+ canvas.translate(containerView.getLeft() - getLeftInset(), 0);
+ containerView.draw(canvas);
+ Utilities.stackBlurBitmap(bitmap, Math.max(7, Math.max(w, h) / 180));
+ blurredView.setBackground(new BitmapDrawable(bitmap));
+ }
blurredView.setVisibility(View.VISIBLE);
blurredView.animate().alpha(1.0f).setDuration(180).setListener(new AnimatorListenerAdapter() {
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java
index c90f0fa6d..9df5e46c6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java
@@ -2866,6 +2866,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
boolean hasMessageToEffect = false;
MessageObject messageWithCaption = null;
+ boolean canHaveStars = false;
ArrayList messageObjects = new ArrayList<>();
int id = 0;
if (currentAttachLayout == photoLayout || currentAttachLayout == photoPreviewLayout) {
@@ -2973,6 +2974,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (messageWithCaption == null && !TextUtils.isEmpty(msg.message)) {
messageWithCaption = messageObject;
}
+ canHaveStars = true;
}
}
}
@@ -3144,7 +3146,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
}
});
}
- if (chatActivity != null && ChatObject.isChannelAndNotMegaGroup(chatActivity.getCurrentChat()) && chatActivity.getCurrentChatInfo() != null && chatActivity.getCurrentChatInfo().paid_media_allowed) {
+ if (canHaveStars && chatActivity != null && ChatObject.isChannelAndNotMegaGroup(chatActivity.getCurrentChat()) && chatActivity.getCurrentChatInfo() != null && chatActivity.getCurrentChatInfo().paid_media_allowed) {
ActionBarMenuSubItem item = options.add(R.drawable.menu_feature_paid, getString(R.string.PaidMediaButton), null).getLast();
item.setOnClickListener(v -> {
if (photoLayout == null) return;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForwardBackground.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForwardBackground.java
index 3374bdb0e..dff7d2b91 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForwardBackground.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForwardBackground.java
@@ -138,14 +138,45 @@ public class ForwardBackground {
view.invalidate();
}
- public void draw(Canvas canvas) {
+ private LoadingDrawable loadingDrawable;
+
+ public void draw(Canvas canvas, boolean loading) {
canvas.save();
canvas.clipPath(path);
if (rippleDrawable != null) {
rippleDrawable.setBounds(bounds);
rippleDrawable.draw(canvas);
}
+
+ if (loading) {
+ if (loadingDrawable == null) {
+ loadingDrawable = new LoadingDrawable();
+ loadingDrawable.setAppearByGradient(true);
+ } else if (loadingDrawable.isDisappeared() || loadingDrawable.isDisappearing()) {
+ loadingDrawable.reset();
+ loadingDrawable.resetDisappear();
+ }
+ } else if (loadingDrawable != null && !loadingDrawable.isDisappearing() && !loadingDrawable.isDisappeared()) {
+ loadingDrawable.disappear();
+ }
+
canvas.restore();
+
+ if (loadingDrawable != null && !loadingDrawable.isDisappeared()) {
+ loadingDrawable.usePath(path);
+ loadingDrawable.setColors(
+ Theme.multAlpha(rippleDrawableColor, .7f),
+ Theme.multAlpha(rippleDrawableColor, 1.3f),
+ Theme.multAlpha(rippleDrawableColor, 1.5f),
+ Theme.multAlpha(rippleDrawableColor, 2f)
+ );
+ loadingDrawable.setBounds(bounds);
+ canvas.save();
+ loadingDrawable.draw(canvas);
+ canvas.restore();
+ view.invalidate();
+ }
+
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/MessagePrivateSeenView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/MessagePrivateSeenView.java
index 7b8b9b1e4..970e845c4 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/MessagePrivateSeenView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/MessagePrivateSeenView.java
@@ -314,13 +314,13 @@ public class MessagePrivateSeenView extends FrameLayout {
minWidth = Math.max(minWidth, dp(40 + 96 + 8));
minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.getString(R.string.PmReadUnknown)));
minWidth = Math.max(minWidth, dp(40 + 16 + 8) + valueTextView.getPaint().measureText(LocaleController.getString(R.string.PmRead) + premiumTextView.getPaint().measureText(LocaleController.getString(R.string.PmReadShowWhen))));
- minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadTodayAt, LocaleController.getInstance().formatterDay.format(new Date(date)))));
+ minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadTodayAt, LocaleController.getInstance().getFormatterDay().format(new Date(date)))));
if (messageDiff > 60 * 60 * 24) {
- minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadYesterdayAt, LocaleController.getInstance().formatterDay.format(new Date(date)))));
+ minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadYesterdayAt, LocaleController.getInstance().getFormatterDay().format(new Date(date)))));
}
if (messageDiff > 60 * 60 * 24 * 2) {
- minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadDateTimeAt, LocaleController.getInstance().formatterDayMonth.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)))));
- minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadDateTimeAt, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)))));
+ minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadDateTimeAt, LocaleController.getInstance().getFormatterDayMonth().format(new Date(date)), LocaleController.getInstance().getFormatterDay().format(new Date(date)))));
+ minWidth = Math.max(minWidth, dp(40 + 8) + valueTextView.getPaint().measureText(LocaleController.formatString(R.string.PmReadDateTimeAt, LocaleController.getInstance().getFormatterYear().format(new Date(date)), LocaleController.getInstance().getFormatterDay().format(new Date(date)))));
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java
index ab3b546a0..989e02521 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/BoostDialogs.java
@@ -79,7 +79,7 @@ public class BoostDialogs {
if (error.text.contains("PREMIUM_SUB_ACTIVE_UNTIL_")) {
String strDate = error.text.replace("PREMIUM_SUB_ACTIVE_UNTIL_", "");
long date = Long.parseLong(strDate);
- String formattedDate = LocaleController.getInstance().formatterBoostExpired.format(new Date(date * 1000L));
+ String formattedDate = LocaleController.getInstance().getFormatterBoostExpired().format(new Date(date * 1000L));
String subTitleText = getString("GiftPremiumActivateErrorText", R.string.GiftPremiumActivateErrorText);
SpannableStringBuilder subTitleWithLink = AndroidUtilities.replaceSingleTag(
subTitleText,
@@ -302,9 +302,9 @@ public class BoostDialogs {
calendar.setTimeInMillis(date);
int year = calendar.get(Calendar.YEAR);
if (year == currentYear) {
- return LocaleController.getInstance().formatterScheduleDay.format(date);
+ return LocaleController.getInstance().getFormatterScheduleDay().format(date);
} else {
- return LocaleController.getInstance().formatterScheduleYear.format(date);
+ return LocaleController.getInstance().getFormatterScheduleYear().format(date);
}
}
});
@@ -502,10 +502,10 @@ public class BoostDialogs {
public static void showAbout(boolean isChannel, String from, long msgDate, TLRPC.TL_payments_giveawayInfo giveawayInfo, TLRPC.TL_messageMediaGiveaway giveaway, Context context, Theme.ResourcesProvider resourcesProvider) {
int quantity = giveaway.quantity;
String months = formatPluralString("BoldMonths", giveaway.months);
- String endDate = LocaleController.getInstance().formatterGiveawayMonthDay.format(new Date(giveaway.until_date * 1000L));
+ String endDate = LocaleController.getInstance().getFormatterGiveawayMonthDay().format(new Date(giveaway.until_date * 1000L));
- String fromTime = LocaleController.getInstance().formatterDay.format(new Date(giveawayInfo.start_date * 1000L));
- String fromDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(giveawayInfo.start_date * 1000L));
+ String fromTime = LocaleController.getInstance().getFormatterDay().format(new Date(giveawayInfo.start_date * 1000L));
+ String fromDate = LocaleController.getInstance().getFormatterGiveawayMonthDayYear().format(new Date(giveawayInfo.start_date * 1000L));
boolean isSeveralChats = giveaway.channels.size() > 1;
AlertDialog.Builder builder = new AlertDialog.Builder(context, resourcesProvider);
builder.setTitle(getString("BoostingGiveAwayAbout", R.string.BoostingGiveAwayAbout));
@@ -550,7 +550,7 @@ public class BoostDialogs {
String title = badChat != null ? badChat.title : "";
stringBuilder.append(replaceTags(formatString(isChannel ? R.string.BoostingGiveawayNotEligibleAdmin : R.string.BoostingGiveawayNotEligibleAdminGroup, title)));
} else if (giveawayInfo.joined_too_early_date != 0) {
- String date = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(giveawayInfo.joined_too_early_date * 1000L));
+ String date = LocaleController.getInstance().getFormatterGiveawayMonthDayYear().format(new Date(giveawayInfo.joined_too_early_date * 1000L));
stringBuilder.append(replaceTags(formatString("BoostingGiveawayNotEligible", R.string.BoostingGiveawayNotEligible, date)));
} else {
if (isSeveralChats) {
@@ -573,10 +573,10 @@ public class BoostDialogs {
}
int quantity = giveaway.quantity;
String months = formatPluralString("BoldMonths", giveaway.months);
- String endDate = LocaleController.getInstance().formatterGiveawayMonthDay.format(new Date(giveaway.until_date * 1000L));
+ String endDate = LocaleController.getInstance().getFormatterGiveawayMonthDay().format(new Date(giveaway.until_date * 1000L));
- String fromTime = LocaleController.getInstance().formatterDay.format(new Date(giveawayInfo.start_date * 1000L));
- String fromDate = LocaleController.getInstance().formatterGiveawayMonthDayYear.format(new Date(giveawayInfo.start_date * 1000L));
+ String fromTime = LocaleController.getInstance().getFormatterDay().format(new Date(giveawayInfo.start_date * 1000L));
+ String fromDate = LocaleController.getInstance().getFormatterGiveawayMonthDayYear().format(new Date(giveawayInfo.start_date * 1000L));
boolean isSeveralChats = giveaway.channels.size() > 1;
AlertDialog.Builder builder = new AlertDialog.Builder(context, resourcesProvider);
builder.setTitle(getString("BoostingGiveawayEnd", R.string.BoostingGiveawayEnd));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/adapters/GiftInfoAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/adapters/GiftInfoAdapter.java
index 081079743..e662ae645 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/adapters/GiftInfoAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/adapters/GiftInfoAdapter.java
@@ -190,8 +190,8 @@ public abstract class GiftInfoAdapter extends RecyclerListView.SelectionAdapter
cell.setText(text);
} else {
Date date = new Date(giftCode.used_date * 1000L);
- String monthTxt = LocaleController.getInstance().formatterYear.format(date);
- String timeTxt = LocaleController.getInstance().formatterDay.format(date);
+ String monthTxt = LocaleController.getInstance().getFormatterYear().format(date);
+ String timeTxt = LocaleController.getInstance().getFormatterDay().format(date);
String fullDateStr = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, monthTxt, timeTxt);
cell.setText(LocaleController.formatString("BoostingUsedLinkDate", R.string.BoostingUsedLinkDate, fullDateStr));
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/DateEndCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/DateEndCell.java
index 0b6c69695..86d106c21 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/DateEndCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/DateEndCell.java
@@ -49,8 +49,8 @@ public class DateEndCell extends FrameLayout {
public void setDate(long time) {
selectedTime = time;
Date date = new Date(time);
- String monthTxt = LocaleController.getInstance().formatterDayMonth.format(date);
- String timeTxt = LocaleController.getInstance().formatterDay.format(date);
+ String monthTxt = LocaleController.getInstance().getFormatterDayMonth().format(date);
+ String timeTxt = LocaleController.getInstance().getFormatterDay().format(date);
timeTextView.setText(LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, monthTxt, timeTxt));
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/TableCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/TableCell.java
index 45e44d62e..57726ee91 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/TableCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/TableCell.java
@@ -203,8 +203,8 @@ public class TableCell extends FrameLayout {
public void setData(TLRPC.TL_payments_checkedGiftCode giftCode, Utilities.Callback onObjectClicked) {
this.giftCode = giftCode;
Date date = new Date(giftCode.date * 1000L);
- String monthTxt = LocaleController.getInstance().formatterYear.format(date);
- String timeTxt = LocaleController.getInstance().formatterDay.format(date);
+ String monthTxt = LocaleController.getInstance().getFormatterYear().format(date);
+ String timeTxt = LocaleController.getInstance().getFormatterDay().format(date);
dateTextView.setText(LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, monthTxt, timeTxt));
reasonTextView.setTextColor(Theme.getColor(giftCode.via_giveaway ? Theme.key_dialogTextBlue : Theme.key_dialogTextBlack, resourcesProvider));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java
index 1e39f7ec6..a86d601cd 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/msg/GiveawayMessageCell.java
@@ -311,8 +311,8 @@ public class GiveawayMessageCell {
SpannableStringBuilder bottomStringBuilder = new SpannableStringBuilder(dateTitle);
bottomStringBuilder.setSpan(new RelativeSizeSpan(1.05f), 0, dateTitle.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Date date = new Date(giveaway.until_date * 1000L);
- String monthTxt = LocaleController.getInstance().formatterGiveawayCard.format(date);
- String timeTxt = LocaleController.getInstance().formatterDay.format(date);
+ String monthTxt = LocaleController.getInstance().getFormatterGiveawayCard().format(date);
+ String timeTxt = LocaleController.getInstance().getFormatterDay().format(date);
bottomStringBuilder.append("\n");
bottomStringBuilder.append(formatString("formatDateAtTime", R.string.formatDateAtTime, monthTxt, timeTxt));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/selector/SelectorUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/selector/SelectorUserCell.java
index 8fee73d24..c6dc58f11 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/selector/SelectorUserCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/selector/SelectorUserCell.java
@@ -168,7 +168,7 @@ public class SelectorUserCell extends BaseCell {
titleTextView.setText(chat.title);
subtitleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray3, resourcesProvider));
- setSubtitle(LocaleController.formatString("BoostExpireOn", R.string.BoostExpireOn, LocaleController.getInstance().formatterBoostExpired.format(new Date(boost.expires * 1000L))));
+ setSubtitle(LocaleController.formatString("BoostExpireOn", R.string.BoostExpireOn, LocaleController.getInstance().getFormatterBoostExpired().format(new Date(boost.expires * 1000L))));
if (boost.cooldown_until_date > 0) {
long diff = boost.cooldown_until_date * 1000L - System.currentTimeMillis();
@@ -191,7 +191,7 @@ public class SelectorUserCell extends BaseCell {
subtitleTextView.setAlpha(0.65f);
setCheckboxAlpha(0.3f, false);
} else {
- setSubtitle(LocaleController.formatString("BoostExpireOn", R.string.BoostExpireOn, LocaleController.getInstance().formatterBoostExpired.format(new Date(boost.expires * 1000L))));
+ setSubtitle(LocaleController.formatString("BoostExpireOn", R.string.BoostExpireOn, LocaleController.getInstance().getFormatterBoostExpired().format(new Date(boost.expires * 1000L))));
if (titleTextView.getAlpha() < 1f) {
titleTextView.animate().alpha(1f).start();
subtitleTextView.animate().alpha(1f).start();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/statistics/GiftedUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/statistics/GiftedUserCell.java
index 0acb34418..e86017c62 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/statistics/GiftedUserCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/boosts/cells/statistics/GiftedUserCell.java
@@ -105,8 +105,8 @@ public class GiftedUserCell extends UserCell {
avatarImageView.setForUserOrChat(null, avatarDrawable);
nameTextView.setRightDrawable(null);
}
- String date = LocaleController.getInstance().formatterScheduleDay.format(new Date(boost.expires * 1000L));
- String time = LocaleController.getInstance().formatterDay.format(new Date(boost.expires * 1000L));
+ String date = LocaleController.getInstance().getFormatterScheduleDay().format(new Date(boost.expires * 1000L));
+ String time = LocaleController.getInstance().getFormatterDay().format(new Date(boost.expires * 1000L));
statusTextView.setText(LocaleController.formatString("BoostingShortMonths", R.string.BoostingShortMonths, months) + " • " + LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, date, time));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
index 6307d4e1c..3f212a850 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
@@ -1957,7 +1957,7 @@ public class RecyclerListView extends RecyclerView {
}
} else {
emptyViewAnimateToVisibility = -1;
- checkIfEmpty(updateEmptyViewAnimated());
+ checkIfEmpty(false);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ScrimOptions.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ScrimOptions.java
index f9ea7ab05..fcc4bd426 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ScrimOptions.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ScrimOptions.java
@@ -441,7 +441,7 @@ public class ScrimOptions extends Dialog {
r = Math.max(r, layout.getLineRight(i));
}
- x += Math.min(xoffset, xwidth - Math.max(0, r - l));
+ x += Math.max(0, Math.min(xoffset, xwidth - Math.max(0, r - l)));
}
final Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ThanosEffect.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ThanosEffect.java
index 9bc849412..d4e202c33 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ThanosEffect.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ThanosEffect.java
@@ -194,6 +194,11 @@ public class ThanosEffect extends TextureView {
if (drawThread != null) {
drawThread.kill();
}
+ if (whenDone != null) {
+ Runnable runnable = whenDone;
+ whenDone = null;
+ runnable.run();
+ }
}
public void scroll(int dx, int dy) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java
index ecb414096..3d8400feb 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java
@@ -59,11 +59,19 @@ public class UItem extends AdapterWithDiffUtils.Item {
public boolean withUsername = true;
-
public UItem(int viewType, boolean selectable) {
super(viewType, selectable);
}
+ public UItem(int viewType) {
+ super(viewType, false);
+ }
+
+ public UItem(int viewType, Object object) {
+ super(viewType, false);
+ this.object = object;
+ }
+
public static UItem asCustom(int id, View view) {
UItem i = new UItem(UniversalAdapter.VIEW_TYPE_CUSTOM, false);
i.id = id;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DataUsage2Activity.java b/TMessagesProj/src/main/java/org/telegram/ui/DataUsage2Activity.java
index eaa7b4326..ce4c7f940 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/DataUsage2Activity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/DataUsage2Activity.java
@@ -346,8 +346,8 @@ public class DataUsage2Activity extends BaseFragment {
itemInners.add(new ItemInner(VIEW_TYPE_CHART));
final String sinceText = totalSize > 0 ?
- LocaleController.formatString("YourNetworkUsageSince", R.string.YourNetworkUsageSince, LocaleController.getInstance().formatterStats.format(getResetStatsDate())) :
- LocaleController.formatString("NoNetworkUsageSince", R.string.NoNetworkUsageSince, LocaleController.getInstance().formatterStats.format(getResetStatsDate()));
+ LocaleController.formatString("YourNetworkUsageSince", R.string.YourNetworkUsageSince, LocaleController.getInstance().getFormatterStats().format(getResetStatsDate())) :
+ LocaleController.formatString("NoNetworkUsageSince", R.string.NoNetworkUsageSince, LocaleController.getInstance().getFormatterStats().format(getResetStatsDate()));
itemInners.add(ItemInner.asSubtitle(sinceText));
ArrayList sections = new ArrayList<>();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java
index a9c2c9d53..c4c8aca78 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/DataUsageActivity.java
@@ -807,7 +807,7 @@ public class DataUsageActivity extends BaseFragment {
case 3: {
TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
cell.setBackground(Theme.getThemedDrawableByKey(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
- cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
+ cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().getFormatterStats().format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
break;
}
default:
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
index 082b3ff5d..e564262a9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
@@ -414,6 +414,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private FilterTabsView filterTabsView;
private boolean askingForPermissions;
private RLottieDrawable passcodeDrawable;
+ private int searchViewPagerIndex;
+ @Nullable
private SearchViewPager searchViewPager;
private SharedMediaLayout.SharedMediaPreloader sharedMediaPreloader;
public DialogStoriesCell dialogStoriesCell;
@@ -454,17 +456,28 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
private Paint actionBarDefaultPaint = new Paint();
private NumberTextView selectedDialogsCountTextView;
- private ArrayList actionModeViews = new ArrayList<>();
+ private final ArrayList actionModeViews = new ArrayList<>();
+ @Nullable
private ActionBarMenuItem deleteItem;
+ @Nullable
private ActionBarMenuItem pinItem;
+ @Nullable
private ActionBarMenuItem muteItem;
+ @Nullable
private ActionBarMenuItem archive2Item;
+ @Nullable
private ActionBarMenuSubItem pin2Item;
+ @Nullable
private ActionBarMenuSubItem addToFolderItem;
+ @Nullable
private ActionBarMenuSubItem removeFromFolderItem;
+ @Nullable
private ActionBarMenuSubItem archiveItem;
+ @Nullable
private ActionBarMenuSubItem clearItem;
+ @Nullable
private ActionBarMenuSubItem readItem;
+ @Nullable
private ActionBarMenuSubItem blockItem;
private float additionalFloatingTranslation;
@@ -1090,7 +1103,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
topBulletin.updatePosition();
}
}
- searchViewPager.setTranslationY(searchViewPagerTranslationY);
+ if (searchViewPager != null) {
+ searchViewPager.setTranslationY(searchViewPagerTranslationY);
+ }
}
}
@@ -1288,7 +1303,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
- searchViewPager.setKeyboardHeight(keyboardSize);
+ if (searchViewPager != null) {
+ searchViewPager.setKeyboardHeight(keyboardSize);
+ }
notifyHeightChanged();
updateContextViewPosition();
updateCommentView();
@@ -3055,7 +3072,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
searchContainer.addView(speedItem, speedParams);
searchItem.setSearchAdditionalButton(speedItem);
- updateSpeedItem(searchViewPager.getCurrentPosition() == 2);
+ updateSpeedItem(searchViewPager != null && searchViewPager.getCurrentPosition() == 2);
}
}
@@ -3159,13 +3176,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
@Override
public void onTextChanged(EditText editText) {
String text = editText.getText().toString();
- if (text.length() != 0 || (searchViewPager.dialogsSearchAdapter != null && searchViewPager.dialogsSearchAdapter.hasRecentSearch()) || searchFiltersWasShowed || hasStories) {
+ if (text.length() != 0 || (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null && searchViewPager.dialogsSearchAdapter.hasRecentSearch()) || searchFiltersWasShowed || hasStories) {
searchWas = true;
if (!searchIsShowed) {
showSearch(true, false, true);
}
}
- searchViewPager.onTextChanged(text);
+ if (searchViewPager != null) {
+ searchViewPager.onTextChanged(text);
+ }
}
@Override
@@ -3173,8 +3192,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (!searchIsShowed) {
return;
}
- searchViewPager.removeSearchFilter(filterData);
- searchViewPager.onTextChanged(searchItem.getSearchField().getText().toString());
+ if (searchViewPager != null) {
+ searchViewPager.removeSearchFilter(filterData);
+ searchViewPager.onTextChanged(searchItem.getSearchField().getText().toString());
+ }
updateFiltersView(true, null, null, false, true);
}
@@ -3598,7 +3619,176 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
sideMenu.getAdapter().notifyDataSetChanged();
}
- createActionMode(null);
+// createActionMode(null);
+
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if ((id == SearchViewPager.forwardItemId || id == SearchViewPager.gotoItemId || id == SearchViewPager.deleteItemId || id == SearchViewPager.speedItemId) && searchViewPager != null) {
+ searchViewPager.onActionBarItemClick(id);
+ return;
+ }
+ if (id == -1) {
+ if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.hasFragment()) {
+ if (actionBar.isActionModeShowed()) {
+ if (searchViewPager != null && searchViewPager.getVisibility() == View.VISIBLE && searchViewPager.actionModeShowing()) {
+ searchViewPager.hideActionMode();
+ } else {
+ hideActionMode(true);
+ }
+ } else {
+ rightSlidingDialogContainer.finishPreview();
+ if (searchViewPager != null) {
+ searchViewPager.updateTabs();
+ }
+ return;
+ }
+ } else if (filterTabsView != null && filterTabsView.isEditing()) {
+ filterTabsView.setIsEditing(false);
+ showDoneItem(false);
+ } else if (actionBar.isActionModeShowed()) {
+ if (searchViewPager != null && searchViewPager.getVisibility() == View.VISIBLE && searchViewPager.actionModeShowing()) {
+ searchViewPager.hideActionMode();
+ } else {
+ hideActionMode(true);
+ }
+ } else if (onlySelect || folderId != 0) {
+ finishFragment();
+ } else if (parentLayout != null && parentLayout.getDrawerLayoutContainer() != null) {
+ parentLayout.getDrawerLayoutContainer().openDrawer(false);
+ }
+ } else if (id == 1) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ SharedConfig.appLocked = true;
+ SharedConfig.saveConfig();
+ int[] position = new int[2];
+ passcodeItem.getLocationInWindow(position);
+ ((LaunchActivity) getParentActivity()).showPasscodeActivity(false, true, position[0] + passcodeItem.getMeasuredWidth() / 2, position[1] + passcodeItem.getMeasuredHeight() / 2, () -> passcodeItem.setAlpha(1.0f), () -> passcodeItem.setAlpha(0.0f));
+ getNotificationsController().showNotifications();
+ updatePasscodeButton();
+ } else if (id == 2) {
+ presentFragment(new ProxyListActivity());
+ } else if (id == 3) {
+ showSearch(true, true, true);
+ actionBar.openSearchField(true);
+ } else if (id == 5) {
+ presentFragment(new ArchiveSettingsActivity());
+ } else if (id == 6) {
+ showArchiveHelp();
+ } else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ DialogsActivityDelegate oldDelegate = delegate;
+ LaunchActivity launchActivity = (LaunchActivity) getParentActivity();
+ launchActivity.switchToAccount(id - 10, true);
+
+ DialogsActivity dialogsActivity = new DialogsActivity(arguments);
+ dialogsActivity.setDelegate(oldDelegate);
+ launchActivity.presentFragment(dialogsActivity, false, true);
+ } else if (id == add_to_folder) {
+ FiltersListBottomSheet sheet = new FiltersListBottomSheet(DialogsActivity.this, selectedDialogs);
+ sheet.setDelegate((filter, checked) -> {
+ ArrayList alwaysShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, true, false);
+ if (!checked) {
+ int currentCount;
+ if (filter != null) {
+ currentCount = filter.alwaysShow.size();
+ } else {
+ currentCount = 0;
+ }
+ int totalCount = currentCount + alwaysShow.size();
+ if ((totalCount > getMessagesController().dialogFiltersChatsLimitDefault && !getUserConfig().isPremium()) || totalCount > getMessagesController().dialogFiltersChatsLimitPremium) {
+ showDialog(new LimitReachedBottomSheet(DialogsActivity.this, fragmentView.getContext(), LimitReachedBottomSheet.TYPE_CHATS_IN_FOLDER, currentAccount, null));
+ return;
+ }
+ }
+ if (filter != null) {
+ if (checked) {
+ for (int a = 0; a < selectedDialogs.size(); a++) {
+ filter.neverShow.add(selectedDialogs.get(a));
+ filter.alwaysShow.remove(selectedDialogs.get(a));
+ }
+ FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.color, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null);
+ long did;
+ if (selectedDialogs.size() == 1) {
+ did = selectedDialogs.get(0);
+ } else {
+ did = 0;
+ }
+ final UndoView undoView = getUndoView();
+ if (undoView != null) {
+ undoView.showWithAction(did, UndoView.ACTION_REMOVED_FROM_FOLDER, selectedDialogs.size(), filter, null, null);
+ }
+ } else {
+ if (!alwaysShow.isEmpty()) {
+ for (int a = 0; a < alwaysShow.size(); a++) {
+ filter.neverShow.remove(alwaysShow.get(a));
+ }
+ filter.alwaysShow.addAll(alwaysShow);
+ FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.color, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null);
+ }
+ long did;
+ if (alwaysShow.size() == 1) {
+ did = alwaysShow.get(0);
+ } else {
+ did = 0;
+ }
+ final UndoView undoView = getUndoView();
+ if (undoView != null) {
+ undoView.showWithAction(did, UndoView.ACTION_ADDED_TO_FOLDER, alwaysShow.size(), filter, null, null);
+ }
+ }
+ } else {
+ presentFragment(new FilterCreateActivity(null, alwaysShow));
+ }
+ hideActionMode(true);
+ });
+ showDialog(sheet);
+ } else if (id == remove_from_folder) {
+ MessagesController.DialogFilter filter = getMessagesController().getDialogFilters().get(viewPages[0].selectedType);
+ ArrayList neverShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, false, false);
+
+ int currentCount;
+ if (filter != null) {
+ currentCount = filter.neverShow.size();
+ } else {
+ currentCount = 0;
+ }
+ if (currentCount + neverShow.size() > 100) {
+ showDialog(AlertsCreator.createSimpleAlert(getParentActivity(), LocaleController.getString("FilterAddToAlertFullTitle", R.string.FilterAddToAlertFullTitle), LocaleController.getString("FilterAddToAlertFullText", R.string.FilterAddToAlertFullText)).create());
+ return;
+ }
+ if (!neverShow.isEmpty()) {
+ filter.neverShow.addAll(neverShow);
+ for (int a = 0; a < neverShow.size(); a++) {
+ Long did = neverShow.get(a);
+ filter.alwaysShow.remove(did);
+ filter.pinnedDialogs.delete(did);
+ }
+ if (filter.isChatlist()) {
+ filter.neverShow.clear();
+ }
+ FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.color, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, false, false, DialogsActivity.this, null);
+ }
+ long did;
+ if (neverShow.size() == 1) {
+ did = neverShow.get(0);
+ } else {
+ did = 0;
+ }
+ final UndoView undoView = getUndoView();
+ if (undoView != null) {
+ undoView.showWithAction(did, UndoView.ACTION_REMOVED_FROM_FOLDER, neverShow.size(), filter, null, null);
+ }
+ hideActionMode(false);
+ } else if (id == pin || id == read || id == delete || id == clear || id == mute || id == archive || id == block || id == archive2 || id == pin2) {
+ performSelectedDialogsAction(selectedDialogs, id, true, false);
+ }
+ }
+ });
ContentView contentView = new ContentView(context);
fragmentView = contentView;
@@ -4241,263 +4431,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}
- int type = 0;
- if (searchString != null) {
- type = 2;
- } else if (!onlySelect) {
- type = 1;
- }
- searchViewPager = new SearchViewPager(context, this, type, initialDialogsType, folderId, new SearchViewPager.ChatPreviewDelegate() {
- @Override
- public void startChatPreview(RecyclerListView listView, DialogCell cell) {
- showChatPreview(cell);
- }
-
- @Override
- public void move(float dy) {
- if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
- movePreviewFragment(dy);
- }
- }
-
- @Override
- public void finish() {
- if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
- finishPreviewFragment();
- }
- }
- }) {
- @Override
- protected void onTabPageSelected(int position) {
- updateSpeedItem(position == 2);
- }
-
- @Override
- protected long getDialogId(String query) {
- if (query != null && query.length() > 0 && rightSlidingDialogContainer != null && rightSlidingDialogContainer.getFragment() instanceof TopicsFragment) {
- return ((TopicsFragment) rightSlidingDialogContainer.getFragment()).getDialogId();
- }
- return 0;
- }
-
- @Override
- protected boolean onBackProgress(float progress) {
- return false;
-// setSearchAnimationProgress(1f - progress, true);
-// return true;
- }
-
-// @Override
-// protected void onBack() {
-// actionBar.onSearchFieldVisibilityChanged(searchItem.toggleSearch(false));
-// }
-
- @Override
- protected boolean includeDownloads() {
- if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.hasFragment()) {
- return false;
- }
- return true;
- }
- };
- contentView.addView(searchViewPager);
-
- searchViewPager.dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() {
- @Override
- public void searchStateChanged(boolean search, boolean animated) {
- if (searchViewPager.emptyView.getVisibility() == View.VISIBLE) {
- animated = true;
- }
- if (searching && searchWas && searchViewPager.emptyView != null) {
- if (search || searchViewPager.dialogsSearchAdapter.getItemCount() != 0) {
- searchViewPager.emptyView.showProgress(true, animated);
- } else {
- searchViewPager.emptyView.showProgress(false, animated);
- }
- }
- if (search && searchViewPager.dialogsSearchAdapter.getItemCount() == 0) {
- searchViewPager.cancelEnterAnimation();
- }
- }
-
- @Override
- public void didPressedBlockedDialog(View view, long did) {
- showPremiumBlockedToast(view, did);
- }
-
- @Override
- public void didPressedOnSubDialog(long did) {
- if (onlySelect) {
- if (!validateSlowModeDialog(did)) {
- return;
- }
- if (!selectedDialogs.isEmpty()) {
- boolean checked = addOrRemoveSelectedDialog(did, null);
- findAndUpdateCheckBox(did, checked);
- updateSelectedCount();
- actionBar.closeSearchField();
- } else {
- didSelectResult(did, 0, true, false);
- }
- } else {
- Bundle args = new Bundle();
- if (DialogObject.isUserDialog(did)) {
- args.putLong("user_id", did);
- } else {
- args.putLong("chat_id", -did);
- }
- closeSearch();
- if (AndroidUtilities.isTablet() && viewPages != null) {
- for (int a = 0; a < viewPages.length; a++) {
- viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId.dialogId = did);
- }
- updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
- }
- if (searchString != null) {
- if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
- getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
- presentFragment(new ChatActivity(args));
- }
- } else {
- if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
- presentFragment(new ChatActivity(args));
- }
- }
- }
- }
-
- @Override
- public void needRemoveHint(long did) {
- if (getParentActivity() == null) {
- return;
- }
- TLRPC.User user = getMessagesController().getUser(did);
- if (user == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("ChatHintsDeleteAlertTitle", R.string.ChatHintsDeleteAlertTitle));
- builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("ChatHintsDeleteAlert", R.string.ChatHintsDeleteAlert, ContactsController.formatName(user.first_name, user.last_name))));
- builder.setPositiveButton(LocaleController.getString("StickersRemove", R.string.StickersRemove), (dialogInterface, i) -> getMediaDataController().removePeer(did));
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- AlertDialog dialog = builder.create();
- showDialog(dialog);
- TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
- if (button != null) {
- button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
- }
- }
-
- @Override
- public void needClearList() {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- if (searchViewPager.dialogsSearchAdapter.isSearchWas() && searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) {
- builder.setTitle(LocaleController.getString("ClearSearchAlertPartialTitle", R.string.ClearSearchAlertPartialTitle));
- builder.setMessage(LocaleController.formatPluralString("ClearSearchAlertPartial", searchViewPager.dialogsSearchAdapter.getRecentResultsCount()));
- builder.setPositiveButton(LocaleController.getString("Clear", R.string.Clear), (dialogInterface, i) -> {
- searchViewPager.dialogsSearchAdapter.clearRecentSearch();
- });
- } else {
- builder.setTitle(LocaleController.getString("ClearSearchAlertTitle", R.string.ClearSearchAlertTitle));
- builder.setMessage(LocaleController.getString("ClearSearchAlert", R.string.ClearSearchAlert));
- builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton), (dialogInterface, i) -> {
- if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) {
- searchViewPager.dialogsSearchAdapter.clearRecentSearch();
- } else {
- searchViewPager.dialogsSearchAdapter.clearRecentHashtags();
- }
- });
- }
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- AlertDialog dialog = builder.create();
- showDialog(dialog);
- TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
- if (button != null) {
- button.setTextColor(Theme.getColor(Theme.key_text_RedBold));
- }
- }
-
- @Override
- public void runResultsEnterAnimation() {
- if (searchViewPager != null) {
- searchViewPager.runResultsEnterAnimation();
- }
- }
-
- @Override
- public boolean isSelected(long dialogId) {
- return selectedDialogs.contains(dialogId);
- }
-
- @Override
- public long getSearchForumDialogId() {
- if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.getFragment() instanceof TopicsFragment) {
- return ((TopicsFragment) rightSlidingDialogContainer.getFragment()).getDialogId();
- }
- return 0;
- }
- });
-
- searchViewPager.channelsSearchListView.setOnItemClickListener((view, position, x, y) -> {
- Object obj = searchViewPager.channelsSearchAdapter.getObject(position);
- if (obj instanceof TLRPC.Chat) {
- Bundle args = new Bundle();
- args.putLong("chat_id", ((TLRPC.Chat) obj).id);
- ChatActivity chatActivity = new ChatActivity(args);
- chatActivity.setNextChannels(searchViewPager.channelsSearchAdapter.getNextChannels(position));
- presentFragment(chatActivity);
- } else if (obj instanceof MessageObject) {
- MessageObject msg = (MessageObject) obj;
- Bundle args = new Bundle();
- if (msg.getDialogId() >= 0) {
- args.putLong("user_id", msg.getDialogId());
- } else {
- args.putLong("chat_id", -msg.getDialogId());
- }
- args.putInt("message_id", msg.getId());
- ChatActivity chatActivity = new ChatActivity(args);
- presentFragment(highlightFoundQuote(chatActivity, msg));
- }
- });
-
- searchViewPager.searchListView.setOnItemClickListener((view, position, x, y) -> {
- if (view instanceof ProfileSearchCell && ((ProfileSearchCell) view).isBlocked()) {
- showPremiumBlockedToast(view, ((ProfileSearchCell) view).getDialogId());
- return;
- }
- if (initialDialogsType == DIALOGS_TYPE_WIDGET) {
- onItemLongClick(searchViewPager.searchListView, view, position, x, y, -1, searchViewPager.dialogsSearchAdapter);
- return;
- }
- onItemClick(view, position, searchViewPager.dialogsSearchAdapter, x, y);
- });
- searchViewPager.searchListView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {
- @Override
- public boolean onItemClick(View view, int position, float x, float y) {
- if (view instanceof ProfileSearchCell && ((ProfileSearchCell) view).isBlocked()) {
- showPremiumBlockedToast(view, ((ProfileSearchCell) view).getDialogId());
- return true;
- }
- return onItemLongClick(searchViewPager.searchListView, view, position, x, y, -1, searchViewPager.dialogsSearchAdapter);
- }
-
- @Override
- public void onMove(float dx, float dy) {
- if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
- movePreviewFragment(dy);
- }
- }
-
- @Override
- public void onLongClickRelease() {
- if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
- finishPreviewFragment();
- }
- }
- });
-
- searchViewPager.setFilteredSearchViewDelegate((showMediaFilters, users, dates, archive) -> DialogsActivity.this.updateFiltersView(showMediaFilters, users, dates, archive, true));
- searchViewPager.setVisibility(View.GONE);
+ searchViewPagerIndex = contentView.getChildCount();
filtersView = new FiltersView(getParentActivity(), null);
filtersView.setOnItemClickListener((view, position) -> {
@@ -5412,7 +5346,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
fixScrollYAfterArchiveOpened = true;
fragmentView.invalidate();
}
- searchViewPager.updateTabs();
+ if (searchViewPager != null) {
+ searchViewPager.updateTabs();
+ }
updateDrawerSwipeEnabled();
updateFilterTabs(false, true);
}
@@ -6416,7 +6352,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
private void updateFiltersView(boolean showMediaFilters, ArrayList