Update to 8.8.3

This commit is contained in:
xaxtix 2022-06-23 02:07:45 +04:00
parent 96dce2c9aa
commit 4a95c2fc1f
33 changed files with 255 additions and 97 deletions

View file

@ -27,4 +27,4 @@ RUN cp $ANDROID_HOME/build-tools/30.0.3/lib/dx.jar $ANDROID_HOME/build-tools/31.
ENV PATH ${ANDROID_NDK_HOME}:$PATH
ENV PATH ${ANDROID_NDK_HOME}/prebuilt/linux-x86_64/bin/:$PATH
CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/outputs/native-debug-symbols && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle assembleRelease && gradle assembleStandalone && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols
CMD mkdir -p /home/source/TMessagesProj/build/outputs/apk && mkdir -p /home/source/TMessagesProj/build/outputs/native-debug-symbols && cp -R /home/source/. /home/gradle && cd /home/gradle && gradle bundleBundleAfat_SDK23Release && gradle bundleBundleAfatRelease && gradle assembleStandalone && gradle assembleAfatRelease && cp -R /home/gradle/TMessagesProj/build/outputs/apk/. /home/source/TMessagesProj/build/outputs/apk && cp -R /home/gradle/TMessagesProj/build/outputs/bundle/. /home/source/TMessagesProj/build/outputs/bundle && cp -R /home/gradle/TMessagesProj/build/outputs/native-debug-symbols/. /home/source/TMessagesProj/build/outputs/native-debug-symbols

View file

@ -40,8 +40,6 @@ dependencies {
implementation 'com.android.billingclient:billing:5.0.0'
implementation files('libs/libgsaverification-client.aar')
implementation "com.android.billingclient:billing:5.0.0"
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
@ -237,7 +235,7 @@ android {
}
}
defaultConfig.versionCode = 2702
defaultConfig.versionCode = 2705
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -256,7 +254,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.8.2"
versionName "8.8.3"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

File diff suppressed because one or more lines are too long

View file

@ -21,6 +21,9 @@ import android.view.View;
import androidx.annotation.Nullable;
import androidx.core.os.TraceCompat;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -274,6 +277,7 @@ final class GapWorker implements Runnable {
return false;
}
@SuppressLint("NotifyDataSetChanged")
private RecyclerView.ViewHolder prefetchPositionWithDeadline(RecyclerView view,
int position, long deadlineNs) {
if (isPrefetchPositionAttached(view, position)) {
@ -301,6 +305,14 @@ final class GapWorker implements Runnable {
recycler.addViewHolderToRecycledViewPool(holder, false);
}
}
} catch (Exception e) {
FileLog.e(e);
AndroidUtilities.runOnUIThread(() -> {
if (view.getAdapter() != null) {
view.getAdapter().notifyDataSetChanged();
}
});
return null;
} finally {
view.onExitLayoutOrScroll(false);
}

View file

@ -10,7 +10,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.util.Consumer;
import com.android.billingclient.api.AcknowledgePurchaseParams;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.BillingClientStateListener;
import com.android.billingclient.api.BillingFlowParams;
@ -22,12 +21,16 @@ import com.android.billingclient.api.PurchasesResponseListener;
import com.android.billingclient.api.PurchasesUpdatedListener;
import com.android.billingclient.api.QueryProductDetailsParams;
import com.android.billingclient.api.QueryPurchasesParams;
import com.google.android.exoplayer2.util.Util;
import org.json.JSONObject;
import org.telegram.tgnet.TLRPC;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -46,6 +49,8 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
private Map<String, Consumer<BillingResult>> resultListeners = new HashMap<>();
private List<String> requestingTokens = new ArrayList<>();
private Map<String, Integer> currencyExpMap = new HashMap<>();
public static BillingController getInstance() {
if (instance == null) {
instance = new BillingController(ApplicationLoader.applicationContext);
@ -62,11 +67,40 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
.build();
}
public int getCurrencyExp(String currency) {
Integer exp = currencyExpMap.get(currency);
if (exp == null) {
return 0;
}
return exp;
}
public void startConnection() {
if (isReady()) {
return;
}
billingClient.startConnection(this);
if (BuildVars.useInvoiceBilling()) {
try {
Context ctx = ApplicationLoader.applicationContext;
InputStream in = ctx.getAssets().open("currencies.json");
JSONObject obj = new JSONObject(new String(Util.toByteArray(in), "UTF-8"));
parseCurrencies(obj);
in.close();
} catch (Exception e) {
FileLog.e(e);
}
} else {
billingClient.startConnection(this);
}
}
private void parseCurrencies(JSONObject obj) {
Iterator<String> it = obj.keys();
while (it.hasNext()) {
String key = it.next();
JSONObject currency = obj.optJSONObject(key);
currencyExpMap.put(key, currency.optInt("exp"));
}
}
public boolean isReady() {

View file

@ -20,11 +20,11 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2702;
public static String BUILD_VERSION_STRING = "8.8.2";
public static int BUILD_VERSION = 2705;
public static String BUILD_VERSION_STRING = "8.8.3";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";

View file

@ -893,6 +893,9 @@ public class FileLoader extends BaseController {
MessageObject messageObject = (MessageObject) parentObject;
int flag;
long dialogId = messageObject.getDialogId();
if (messageObject.isAnyKindOfSticker() || getMessagesController().isChatNoForwards(getMessagesController().getChat(-dialogId)) || messageObject.messageOwner.noforwards) {
return false;
}
if (dialogId >= 0) {
flag = SharedConfig.SAVE_TO_GALLERY_FLAG_PEER;
} else {

View file

@ -19,7 +19,6 @@ public class FilePathDatabase {
private SQLiteDatabase database;
private File cacheFile;
private File walCacheFile;
private File shmCacheFile;
private final static int LAST_DB_VERSION = 1;
@ -31,11 +30,11 @@ public class FilePathDatabase {
this.currentAccount = currentAccount;
dispatchQueue = new DispatchQueue("files_database_queue_" + currentAccount);
dispatchQueue.postRunnable(() -> {
createDatabase(false);
createDatabase(0, false);
});
}
public void createDatabase(boolean fromBackup) {
public void createDatabase(int tryCount, boolean fromBackup) {
File filesDir = ApplicationLoader.getFilesDirFixed();
if (currentAccount != 0) {
filesDir = new File(filesDir, "account" + currentAccount + "/");
@ -47,6 +46,7 @@ public class FilePathDatabase {
boolean createTable = false;
if (!cacheFile.exists()) {
createTable = true;
}
@ -59,6 +59,13 @@ public class FilePathDatabase {
database.executeFast("CREATE TABLE paths(document_id INTEGER, dc_id INTEGER, type INTEGER, path TEXT, PRIMARY KEY(document_id, dc_id, type));").stepThis().dispose();
database.executeFast("PRAGMA user_version = " + LAST_DB_VERSION).stepThis().dispose();
} else {
int version = database.executeInt("PRAGMA user_version");
if (BuildVars.LOGS_ENABLED) {
FileLog.d("current db version = " + version);
}
if (version == 0) {
throw new Exception("malformed");
}
//migration
}
if (!fromBackup) {
@ -66,12 +73,18 @@ public class FilePathDatabase {
}
FileLog.d("files db created from_backup= " + fromBackup);
} catch (Exception e) {
if (!fromBackup && restoreBackup()) {
createDatabase(true);
return;
if (tryCount < 4) {
if (!fromBackup && restoreBackup()) {
createDatabase(tryCount + 1, true);
return;
} else {
cacheFile.delete();
shmCacheFile.delete();
createDatabase(tryCount + 1, false);
}
}
if (BuildVars.DEBUG_VERSION) {
throw new RuntimeException(e);
FileLog.e(e);
}
}
}
@ -104,7 +117,7 @@ public class FilePathDatabase {
try {
return AndroidUtilities.copyFile(backupCacheFile, cacheFile);
} catch (IOException e) {
e.printStackTrace();
FileLog.e(e);
}
return false;
}
@ -130,7 +143,7 @@ public class FilePathDatabase {
}
cursor.dispose();
} catch (SQLiteException e) {
throw new RuntimeException(e);
FileLog.e(e);
}
syncLatch.countDown();
});
@ -149,9 +162,7 @@ public class FilePathDatabase {
}
cursor.dispose();
} catch (SQLiteException e) {
if (BuildVars.DEBUG_VERSION) {
throw new RuntimeException(e);
}
FileLog.e(e);
}
return res;
}
@ -173,9 +184,7 @@ public class FilePathDatabase {
database.executeFast("DELETE FROM paths WHERE document_id = " + id + " AND dc_id = " + dc + " AND type = " + type).stepThis().dispose();
}
} catch (SQLiteException e) {
if (BuildVars.DEBUG_VERSION) {
throw new RuntimeException(e);
}
FileLog.e(e);
}
});
}
@ -203,7 +212,7 @@ public class FilePathDatabase {
try {
syncLatch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
FileLog.e(e);
}
FileLog.d("checkMediaExistance size=" + messageObjects.size() + " time=" + (System.currentTimeMillis() - time));

View file

@ -997,7 +997,7 @@ public class ImageLoader {
boolean needInvert = false;
int orientation = 0;
File cacheFileFinal = cacheImage.finalFilePath;
boolean inEncryptedFile = cacheImage.secureDocument != null || cacheImage.encryptionKeyPath != null && cacheFileFinal != null && cacheFileFinal.getAbsolutePath().endsWith(".enc");
boolean inEncryptedFile = cacheImage.secureDocument != null || cacheImage.encryptionKeyPath != null && cacheFileFinal != null && (cacheFileFinal.getAbsolutePath().endsWith(".enc") || cacheFileFinal.getAbsolutePath().endsWith(".64enc"));
SecureDocumentKey secureDocumentKey;
byte[] secureDocumentHash;
if (cacheImage.secureDocument != null) {

View file

@ -226,6 +226,7 @@ public class MediaDataController extends BaseController {
private long loadFeaturedHash;
private int loadFeaturedDate;
public boolean loadFeaturedPremium;
private ArrayList<TLRPC.StickerSetCovered> featuredStickerSets = new ArrayList<>();
private LongSparseArray<TLRPC.StickerSetCovered> featuredStickerSetsById = new LongSparseArray<>();
private ArrayList<Long> unreadStickerSets = new ArrayList<>();
@ -1534,9 +1535,10 @@ public class MediaDataController extends BaseController {
ArrayList<Long> unread = new ArrayList<>();
int date = 0;
long hash = 0;
boolean premium = false;
SQLiteCursor cursor = null;
try {
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, unread, date, hash FROM stickers_featured WHERE 1");
cursor = getMessagesStorage().getDatabase().queryFinalized("SELECT data, unread, date, hash, premium FROM stickers_featured WHERE 1");
if (cursor.next()) {
NativeByteBuffer data = cursor.byteBufferValue(0);
if (data != null) {
@ -1558,6 +1560,7 @@ public class MediaDataController extends BaseController {
}
date = cursor.intValue(2);
hash = calcFeaturedStickersHash(newStickerArray);
premium = cursor.intValue(4) == 1;
}
} catch (Throwable e) {
FileLog.e(e);
@ -1566,7 +1569,7 @@ public class MediaDataController extends BaseController {
cursor.dispose();
}
}
processLoadedFeaturedStickers(newStickerArray, unread, true, date, hash);
processLoadedFeaturedStickers(newStickerArray, unread, premium, true, date, hash);
});
} else {
TLRPC.TL_messages_getFeaturedStickers req = new TLRPC.TL_messages_getFeaturedStickers();
@ -1574,15 +1577,15 @@ public class MediaDataController extends BaseController {
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (response instanceof TLRPC.TL_messages_featuredStickers) {
TLRPC.TL_messages_featuredStickers res = (TLRPC.TL_messages_featuredStickers) response;
processLoadedFeaturedStickers(res.sets, res.unread, false, (int) (System.currentTimeMillis() / 1000), res.hash);
processLoadedFeaturedStickers(res.sets, res.unread, res.premium,false, (int) (System.currentTimeMillis() / 1000), res.hash);
} else {
processLoadedFeaturedStickers(null, null, false, (int) (System.currentTimeMillis() / 1000), req.hash);
processLoadedFeaturedStickers(null, null, false, false, (int) (System.currentTimeMillis() / 1000), req.hash);
}
}));
}
}
private void processLoadedFeaturedStickers(ArrayList<TLRPC.StickerSetCovered> res, ArrayList<Long> unreadStickers, boolean cache, int date, long hash) {
private void processLoadedFeaturedStickers(ArrayList<TLRPC.StickerSetCovered> res, ArrayList<Long> unreadStickers, boolean premium, boolean cache, int date, long hash) {
AndroidUtilities.runOnUIThread(() -> {
loadingFeaturedStickers = false;
featuredStickersLoaded = true;
@ -1611,7 +1614,7 @@ public class MediaDataController extends BaseController {
}
if (!cache) {
putFeaturedStickersToCache(stickerSetsNew, unreadStickers, date, hash);
putFeaturedStickersToCache(stickerSetsNew, unreadStickers, date, hash, premium);
}
AndroidUtilities.runOnUIThread(() -> {
unreadStickerSets = unreadStickers;
@ -1619,6 +1622,7 @@ public class MediaDataController extends BaseController {
featuredStickerSets = stickerSetsNew;
loadFeaturedHash = hash;
loadFeaturedDate = date;
loadFeaturedPremium = premium;
loadStickers(TYPE_FEATURED, true, false);
getNotificationCenter().postNotificationName(NotificationCenter.featuredStickersDidLoad);
});
@ -1627,17 +1631,17 @@ public class MediaDataController extends BaseController {
}
} else {
AndroidUtilities.runOnUIThread(() -> loadFeaturedDate = date);
putFeaturedStickersToCache(null, null, date, 0);
putFeaturedStickersToCache(null, null, date, 0, premium);
}
});
}
private void putFeaturedStickersToCache(ArrayList<TLRPC.StickerSetCovered> stickers, ArrayList<Long> unreadStickers, int date, long hash) {
private void putFeaturedStickersToCache(ArrayList<TLRPC.StickerSetCovered> stickers, ArrayList<Long> unreadStickers, int date, long hash, boolean premium) {
ArrayList<TLRPC.StickerSetCovered> stickersFinal = stickers != null ? new ArrayList<>(stickers) : null;
getMessagesStorage().getStorageQueue().postRunnable(() -> {
try {
if (stickersFinal != null) {
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickers_featured VALUES(?, ?, ?, ?, ?)");
SQLitePreparedStatement state = getMessagesStorage().getDatabase().executeFast("REPLACE INTO stickers_featured VALUES(?, ?, ?, ?, ?, ?)");
state.requery();
int size = 4;
for (int a = 0; a < stickersFinal.size(); a++) {
@ -1658,6 +1662,7 @@ public class MediaDataController extends BaseController {
state.bindByteBuffer(3, data2);
state.bindInteger(4, date);
state.bindLong(5, hash);
state.bindInteger(6, premium ? 1 : 0);
state.step();
data.reuse();
data2.reuse();
@ -1707,7 +1712,7 @@ public class MediaDataController extends BaseController {
unreadStickerSets.clear();
loadFeaturedHash = calcFeaturedStickersHash(featuredStickerSets);
getNotificationCenter().postNotificationName(NotificationCenter.featuredStickersDidLoad);
putFeaturedStickersToCache(featuredStickerSets, unreadStickerSets, loadFeaturedDate, loadFeaturedHash);
putFeaturedStickersToCache(featuredStickerSets, unreadStickerSets, loadFeaturedDate, loadFeaturedHash, loadFeaturedPremium);
if (query) {
TLRPC.TL_messages_readFeaturedStickers req = new TLRPC.TL_messages_readFeaturedStickers();
getConnectionsManager().sendRequest(req, (response, error) -> {
@ -1743,7 +1748,7 @@ public class MediaDataController extends BaseController {
readingStickerSets.remove(id);
loadFeaturedHash = calcFeaturedStickersHash(featuredStickerSets);
getNotificationCenter().postNotificationName(NotificationCenter.featuredStickersDidLoad);
putFeaturedStickersToCache(featuredStickerSets, unreadStickerSets, loadFeaturedDate, loadFeaturedHash);
putFeaturedStickersToCache(featuredStickerSets, unreadStickerSets, loadFeaturedDate, loadFeaturedHash, loadFeaturedPremium);
}, 1000);
}

View file

@ -873,11 +873,17 @@ public class MessagesController extends BaseController implements NotificationCe
};
private static volatile MessagesController[] Instance = new MessagesController[UserConfig.MAX_ACCOUNT_COUNT];
private static volatile Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT];
static {
for (int i = 0; i < UserConfig.MAX_ACCOUNT_COUNT; i++) {
lockObjects[i] = new Object();
}
}
public static MessagesController getInstance(int num) {
MessagesController localInstance = Instance[num];
if (localInstance == null) {
synchronized (MessagesController.class) {
synchronized (lockObjects[num]) {
localInstance = Instance[num];
if (localInstance == null) {
Instance[num] = localInstance = new MessagesController(num);

View file

@ -83,7 +83,7 @@ public class MessagesStorage extends BaseController {
private CountDownLatch openSync = new CountDownLatch(1);
private static volatile MessagesStorage[] Instance = new MessagesStorage[UserConfig.MAX_ACCOUNT_COUNT];
private final static int LAST_DB_VERSION = 97;
private final static int LAST_DB_VERSION = 98;
private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert;
@ -361,7 +361,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE web_recent_v3(id TEXT, type INTEGER, image_url TEXT, thumb_url TEXT, local_url TEXT, width INTEGER, height INTEGER, size INTEGER, date INTEGER, document BLOB, PRIMARY KEY (id, type));").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_v2(id INTEGER PRIMARY KEY, data BLOB, date INTEGER, hash INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_featured(id INTEGER PRIMARY KEY, data BLOB, unread BLOB, date INTEGER, hash INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_featured(id INTEGER PRIMARY KEY, data BLOB, unread BLOB, date INTEGER, hash INTEGER, premium INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_dice(emoji TEXT PRIMARY KEY, data BLOB, date INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE hashtag_recent_v2(id TEXT PRIMARY KEY, date INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE webpage_pending_v2(id INTEGER, mid INTEGER, uid INTEGER, PRIMARY KEY (id, mid, uid));").stepThis().dispose();
@ -1586,6 +1586,13 @@ public class MessagesStorage extends BaseController {
version = 97;
}
if (version == 97) {
database.executeFast("DROP TABLE IF EXISTS stickers_featured;").stepThis().dispose();
database.executeFast("CREATE TABLE stickers_featured(id INTEGER PRIMARY KEY, data BLOB, unread BLOB, date INTEGER, hash INTEGER, premium INTEGER);").stepThis().dispose();
database.executeFast("PRAGMA user_version = 98").stepThis().dispose();
version = 98;
}
FileLog.d("MessagesStorage db migration finished");
AndroidUtilities.runOnUIThread(() -> {
databaseMigrationInProgress = false;

View file

@ -417,8 +417,8 @@ public class SharedConfig {
configLoaded = true;
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(debugWebView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && debugWebView) {
WebView.setWebContentsDebuggingEnabled(true);
}
} catch (Exception e) {
FileLog.e(e);

View file

@ -7389,6 +7389,7 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
flags = nopremium ? (flags | 8) : (flags &~ 8);
flags = document != null ? (flags | 1) : (flags &~ 1);
stream.writeInt32(flags);
if ((flags & 1) != 0) {
document.serializeToStream(stream);
@ -22949,7 +22950,6 @@ public class TLRPC {
public static int constructor = 0x40699cd0;
public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception);
currency = stream.readString(exception);
total_amount = stream.readInt64(exception);
}
@ -38596,7 +38596,7 @@ public class TLRPC {
public TL_chatInviteExported invite;
public void readParams(AbstractSerializedData stream, boolean exception) {
invite = (TL_chatInviteExported) ExportedChatInvite.TLdeserialize(stream, stream.readInt32(exception), exception);
invite = ExportedChatInvite.TLdeserialize(stream, stream.readInt32(exception), exception);
}
public void serializeToStream(AbstractSerializedData stream) {
@ -59978,6 +59978,10 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
}
public void readParams(AbstractSerializedData stream, boolean exception) {
}
}
public static class TL_phone_saveCallLog extends TLObject {

View file

@ -383,6 +383,7 @@ public class AvatarPreviewer {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
imageReceiver.onAttachedToWindow();
NotificationCenter.getInstance(UserConfig.selectedAccount).addObserver(this, NotificationCenter.fileLoaded);
NotificationCenter.getInstance(UserConfig.selectedAccount).addObserver(this, NotificationCenter.fileLoadProgressChanged);
}
@ -390,6 +391,7 @@ public class AvatarPreviewer {
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
imageReceiver.onDetachedFromWindow();
NotificationCenter.getInstance(UserConfig.selectedAccount).removeObserver(this, NotificationCenter.fileLoaded);
NotificationCenter.getInstance(UserConfig.selectedAccount).removeObserver(this, NotificationCenter.fileLoadProgressChanged);
}

View file

@ -15090,6 +15090,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
public static final int COMMENT = 496;
public static final int POLL_HINT = 495;
public static final int FORWARD = 494;
public static final int TRANSCRIBE = 493;
private Path linkPath = new Path();
private RectF rectF = new RectF();
private Rect rect = new Rect();
@ -15178,9 +15179,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
sb.append(title);
}
if (currentMessageObject.messageOwner.media != null && !TextUtils.isEmpty(currentMessageObject.caption)) {
if (currentMessageObject.isVoiceTranscriptionOpen()) {
sb.append("\n");
sb.append(currentMessageObject.caption);
sb.append(currentMessageObject.getVoiceTranscription());
} else {
if (currentMessageObject.messageOwner.media != null && !TextUtils.isEmpty(currentMessageObject.caption)) {
sb.append("\n");
sb.append(currentMessageObject.caption);
}
}
if (documentAttach != null) {
if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) {
@ -15343,6 +15349,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
seekBarAccessibilityDelegate.onInitializeAccessibilityNodeInfoInternal(info);
}
if (useTranscribeButton && transcribeButton != null) {
info.addChild(ChatMessageCell.this, TRANSCRIBE);
}
int i;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
if (isChat && currentUser != null && !currentMessageObject.isOut()) {
@ -15666,6 +15676,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
rect.offset(pos[0], pos[1]);
info.setBoundsInScreen(rect);
info.setClickable(true);
} else if (virtualViewId == TRANSCRIBE) {
info.setClassName("android.widget.Button");
info.setEnabled(true);
info.setText(currentMessageObject.isVoiceTranscriptionOpen() ? LocaleController.getString("AccActionCloseTranscription", R.string.AccActionCloseTranscription) : LocaleController.getString("AccActionOpenTranscription", R.string.AccActionOpenTranscription));
info.addAction(AccessibilityNodeInfo.ACTION_CLICK);
rect.set((int) transcribeX, (int) transcribeY, (int) (transcribeX + AndroidUtilities.dp(30)), (int) (transcribeY + AndroidUtilities.dp(30)));
info.setBoundsInParent(rect);
rect.offset(pos[0], pos[1]);
info.setBoundsInScreen(rect);
info.setClickable(true);
}
info.setFocusable(true);
info.setVisibleToUser(true);
@ -15755,6 +15775,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
delegate.didPressCommentButton(ChatMessageCell.this);
}
}
} else if (virtualViewId == TRANSCRIBE && transcribeButton != null) {
transcribeButton.onTap();
}
} else if (action == AccessibilityNodeInfo.ACTION_LONG_CLICK) {
ClickableSpan link = getLinkById(virtualViewId, virtualViewId >= LINK_CAPTION_IDS_START);

View file

@ -82,7 +82,7 @@ public class StickerEmojiCell extends FrameLayout implements NotificationCenter.
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Theme.getColor(Theme.key_featuredStickers_addButton));
premiumIconView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS);
premiumIconView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED);
premiumIconView.setImageReceiver(imageView.getImageReceiver());
premiumIconView.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4));
premiumIconView.setImageReceiver(imageView.getImageReceiver());
@ -213,18 +213,26 @@ public class StickerEmojiCell extends FrameLayout implements NotificationCenter.
}
private void updatePremiumStatus(boolean animated) {
float alpha;
if (isPremiumSticker && !UserConfig.getInstance(currentAccount).isPremium()) {
alpha = 0.5f;
if (isPremiumSticker) {
showPremiumLock = true;
} else {
alpha = 1f;
showPremiumLock = false;
}
FrameLayout.LayoutParams layoutParams = (LayoutParams) premiumIconView.getLayoutParams();
if (!UserConfig.getInstance(currentAccount).isPremium()) {
layoutParams.height = layoutParams.width = AndroidUtilities.dp(24);
layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
layoutParams.bottomMargin = layoutParams.rightMargin = 0;
premiumIconView.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4));
} else {
layoutParams.height = layoutParams.width = AndroidUtilities.dp(16);
layoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
layoutParams.bottomMargin = AndroidUtilities.dp(8);
layoutParams.rightMargin = AndroidUtilities.dp(8);
premiumIconView.setPadding(AndroidUtilities.dp(1), AndroidUtilities.dp(1), AndroidUtilities.dp(1), AndroidUtilities.dp(1));
}
premiumIconView.setLocked(!UserConfig.getInstance(currentAccount).isPremium());
AndroidUtilities.updateViewVisibilityAnimated(premiumIconView, showPremiumLock, 0.9f, animated);
// if (!animated) {
// premiumAlpha = alpha;
// }
invalidate();
}

View file

@ -250,6 +250,7 @@ import org.telegram.ui.Components.StickersAlert;
import org.telegram.ui.Components.TextSelectionHint;
import org.telegram.ui.Components.TextStyleSpan;
import org.telegram.ui.Components.ThemeEditorView;
import org.telegram.ui.Components.TranscribeButton;
import org.telegram.ui.Components.TranslateAlert;
import org.telegram.ui.Components.TrendingStickersAlert;
import org.telegram.ui.Components.TypefaceSpan;
@ -20939,6 +20940,9 @@ ChatActivity extends BaseFragment implements NotificationCenter.NotificationCent
if (!TextUtils.isEmpty(restrictionReason)) {
return restrictionReason;
}
if (messageObject.isVoiceTranscriptionOpen() && !TranscribeButton.isTranscribing(messageObject)) {
return messageObject.getVoiceTranscription();
}
if (messageObject.caption != null) {
return messageObject.caption;
}

View file

@ -847,7 +847,8 @@ public class EditTextBoldCursor extends EditTextEffects {
}
}
int bottom = (int) lineY;
int scrollHeight = (getLayout() == null ? 0 : getLayout().getHeight()) - getMeasuredHeight() + getPaddingBottom() + getPaddingTop();
int bottom = (int) lineY + getScrollY() + Math.min(Math.max(0, scrollHeight - getScrollY()), AndroidUtilities.dp(2));
int centerX = lastTouchX < 0 ? getMeasuredWidth() / 2 : lastTouchX,
maxWidth = Math.max(centerX, getMeasuredWidth() - centerX) * 2;
if (lineActiveness < 1f) {

View file

@ -4265,7 +4265,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
}
Object pack = rowStartPack.get(row);
if (pack instanceof String) {
if ("recent".equals(pack)) {
if ("premium".equals(pack)) {
return premiumTabNum;
} else if ("recent".equals(pack)) {
return recentTabNum;
} else {
return favTabNum;
@ -4476,7 +4478,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
}
case 5: {
StickerSetNameCell cell = (StickerSetNameCell) holder.itemView;
cell.setText(LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), R.drawable.msg_close);
cell.setText(MediaDataController.getInstance(currentAccount).loadFeaturedPremium ? LocaleController.getString("FeaturedStickersPremium", R.string.FeaturedStickersPremium) : LocaleController.getString("FeaturedStickers", R.string.FeaturedStickers), R.drawable.msg_close);
break;
}
}
@ -4566,7 +4568,13 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
if (pack != null) {
rowStartPack.put(startRow + b, pack);
} else {
rowStartPack.put(startRow + b, a == -1 ? "recent" : "fav");
if (a == -1) {
rowStartPack.put(startRow + b, "premium");
} else if (a == -2) {
rowStartPack.put(startRow + b, "recent");
} else {
rowStartPack.put(startRow + b, "fav");
}
}
}
totalItems += count * stickersPerRow + 1;

View file

@ -21,11 +21,13 @@ import org.telegram.ui.Components.voip.CellFlickerDrawable;
public class PremiumLockIconView extends ImageView {
public static int TYPE_REACTIONS = 0;
public static int TYPE_STICKERS = 1;
public static int TYPE_STICKERS_PREMIUM_LOCKED = 1;
private final int type;
public boolean isEnter;
private float[] colorFloat = new float[3];
StarParticlesView.Drawable starParticles;
private boolean locked;
public PremiumLockIconView(Context context, int type) {
super(context);
@ -174,7 +176,7 @@ public class PremiumLockIconView extends ImageView {
int c1 = currentColor;
int c2;
Color.colorToHSV(c1, colorFloat);
colorFloat[1] *= 2;
colorFloat[1] *= locked ? 2 : 1;
if (colorFloat[2] > 0.7f) {
colorFloat[2] = 0.7f;
}
@ -216,4 +218,10 @@ public class PremiumLockIconView extends ImageView {
setScaleX(0);
setScaleY(0);
}
public void setLocked(boolean locked) {
if (type != TYPE_REACTIONS) {
setImageResource(locked ? R.drawable.msg_mini_premiumlock : R.drawable.msg_mini_stickerstar);
}
}
}

View file

@ -26,6 +26,7 @@ import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.BaseFragment;
@ -101,7 +102,9 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
rowCount += premiumFeatures.size();
featuresEndRow = rowCount;
sectionRow = rowCount++;
buttonRow = rowCount++;
if (!UserConfig.getInstance(currentAccount).isPremium()) {
buttonRow = rowCount++;
}
recyclerListView.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0);
recyclerListView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
@Override
@ -154,10 +157,11 @@ public class PremiumPreviewBottomSheet extends BottomSheetWithRecyclerListView {
buttonDivider.getLayoutParams().height = 1;
AndroidUtilities.updateViewVisibilityAnimated(buttonDivider, true, 1f, false);
buttonContainer.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.CENTER_VERTICAL, 16, 0, 16, 0));
buttonContainer.setBackgroundColor(getThemedColor(Theme.key_dialogBackground));
containerView.addView(buttonContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 68, Gravity.BOTTOM));
if (!UserConfig.getInstance(currentAccount).isPremium()) {
buttonContainer.addView(premiumButtonView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.CENTER_VERTICAL, 16, 0, 16, 0));
buttonContainer.setBackgroundColor(getThemedColor(Theme.key_dialogBackground));
containerView.addView(buttonContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 68, Gravity.BOTTOM));
}
}
@Override

View file

@ -151,31 +151,7 @@ public class TranscribeButton {
public boolean onTouch(int action, float x, float y) {
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
if (pressed && action == MotionEvent.ACTION_UP) {
boolean processClick, toOpen = !shouldBeOpen;
if (!shouldBeOpen) {
processClick = !loading;
if (premium && parent.getMessageObject().isSent()) {
setLoading(true, true);
}
} else {
processClick = true;
setOpen(false, true);
setLoading(false, true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && selectorDrawable instanceof RippleDrawable) {
selectorDrawable.setState(StateSet.NOTHING);
parent.invalidate();
}
pressed = false;
if (processClick) {
if (!premium && toOpen) {
if (parent.getDelegate() != null) {
parent.getDelegate().needShowPremiumFeatures(PremiumPreviewFragment.featureTypeToServerString(PremiumPreviewFragment.PREMIUM_FEATURE_VOICE_TO_TEXT));
}
} else {
transcribePressed(parent.getMessageObject(), toOpen);
}
}
onTap();
return true;
}
pressed = false;
@ -195,6 +171,34 @@ public class TranscribeButton {
return true;
}
public void onTap() {
boolean processClick, toOpen = !shouldBeOpen;
if (!shouldBeOpen) {
processClick = !loading;
if (premium && parent.getMessageObject().isSent()) {
setLoading(true, true);
}
} else {
processClick = true;
setOpen(false, true);
setLoading(false, true);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && selectorDrawable instanceof RippleDrawable) {
selectorDrawable.setState(StateSet.NOTHING);
parent.invalidate();
}
pressed = false;
if (processClick) {
if (!premium && toOpen) {
if (parent.getDelegate() != null) {
parent.getDelegate().needShowPremiumFeatures(PremiumPreviewFragment.featureTypeToServerString(PremiumPreviewFragment.PREMIUM_FEATURE_VOICE_TO_TEXT));
}
} else {
transcribePressed(parent.getMessageObject(), toOpen);
}
}
}
public void setColor(boolean isOut, int color, int grayColor) {
boolean disabled = !premium;
// if (disabled) {

View file

@ -512,7 +512,7 @@ public class EmojiAnimationsOverlay implements NotificationCenter.NotificationCe
}
private void showStickerSetBulletin(TLRPC.TL_messages_stickerSet stickerSet, MessageObject messageObject) {
if (MessagesController.getInstance(currentAccount).premiumLocked) {
if (MessagesController.getInstance(currentAccount).premiumLocked || chatActivity.getParentActivity() == null) {
return;
}
StickerSetBulletinLayout layout = new StickerSetBulletinLayout(contentLayout.getContext(), null, StickerSetBulletinLayout.TYPE_EMPTY, messageObject.getDocument(), chatActivity.getResourceProvider());

View file

@ -381,7 +381,9 @@ public class GroupStickersActivity extends BaseFragment implements NotificationC
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.chatInfoDidLoad, info, 0, true, false);
finishFragment();
} else {
Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
if (getParentActivity() != null) {
Toast.makeText(getParentActivity(), LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred) + "\n" + error.text, Toast.LENGTH_SHORT).show();
}
}
}));
}

View file

@ -3234,7 +3234,7 @@ public class PaymentFormActivity extends BaseFragment implements NotificationCen
}
case STEP_CHECKOUT:
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.paymentFinished);
if (botUser.username != null && botUser.username.equalsIgnoreCase(getMessagesController().premiumBotUsername) || Objects.equals(invoiceSlug, getMessagesController().premiumInvoiceSlug)) {
if (botUser.username != null && botUser.username.equalsIgnoreCase(getMessagesController().premiumBotUsername) || invoiceSlug != null && getMessagesController().premiumInvoiceSlug != null && Objects.equals(invoiceSlug, getMessagesController().premiumInvoiceSlug)) {
for (BaseFragment fragment : new ArrayList<>(getParentLayout().fragmentsStack)) {
if (fragment instanceof ChatActivity || fragment instanceof PremiumPreviewFragment) {
fragment.removeSelfFromStack();

View file

@ -235,7 +235,7 @@ public class PremiumPreviewFragment extends BaseFragment implements Notification
shadowDrawable.getPadding(padding);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
statusBarHeight = AndroidUtilities.statusBarHeight;
statusBarHeight = AndroidUtilities.isTablet() ? 0 : AndroidUtilities.statusBarHeight;
}
contentView = new FrameLayout(context) {
@ -269,7 +269,7 @@ public class PremiumPreviewFragment extends BaseFragment implements Notification
isLandscapeMode = false;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
statusBarHeight = AndroidUtilities.statusBarHeight;
statusBarHeight = AndroidUtilities.isTablet() ? 0 : AndroidUtilities.statusBarHeight;
}
backgroundView.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
particlesView.getLayoutParams().height = backgroundView.getMeasuredHeight();
@ -633,7 +633,7 @@ public class PremiumPreviewFragment extends BaseFragment implements Notification
NumberFormat numberFormat = NumberFormat.getCurrencyInstance();
numberFormat.setCurrency(currency);
return LocaleController.formatString(R.string.SubscribeToPremium, numberFormat.format(premiumPromo.monthly_amount / 100f));
return LocaleController.formatString(R.string.SubscribeToPremium, numberFormat.format(premiumPromo.monthly_amount / Math.pow(10, BillingController.getInstance().getCurrencyExp(premiumPromo.currency))));
}
}

View file

@ -94,6 +94,19 @@ public class SecretMediaViewer implements NotificationCenter.NotificationCenterD
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
return child != aspectRatioFrameLayout && super.drawChild(canvas, child, drawingTime);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
centerImage.onAttachedToWindow();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
centerImage.onDetachedFromWindow();
}
}
private class SecretDeleteTimer extends FrameLayout {

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 716 B

View file

@ -4776,6 +4776,8 @@
<string name="AccActionOpenForwardedOrigin">Forwarded origin</string>
<string name="AccActionEnterSelectionMode">Enter selection mode</string>
<string name="AccActionChatPreview">Chat Preview</string>
<string name="AccActionOpenTranscription">Open Voice Transcription</string>
<string name="AccActionCloseTranscription">Close Transcription</string>
<string name="AccDescrEmojiButton">Emoji, stickers, and GIFs</string>
<string name="AccDescrAttachButton">Attach media</string>
<string name="AccDescrChanSilentOn">Send silently</string>
@ -5446,4 +5448,5 @@
<string name="PremiumPreviewAdvancedChatManagementDescription">Tools to set the default folder, auto-archive and hide new chats from non-contacts.</string>
<string name="TelegramPremiumUserDialogSubtitle">Owners of **Telegram Premium** accounts have exclusive acces to multiple additional features.</string>
<string name="PremiumPreviewNoAdsDescription2">Remove ads such as this one by subscribing to Telegram Premium.</string>
<string name="FeaturedStickersPremium">Trending Premium Stickers</string>
</resources>