update to 10.0.3 (3801)

This commit is contained in:
xaxtix 2023-08-24 22:30:23 +04:00
parent 702d37ce69
commit 702839a853
72 changed files with 1877 additions and 741 deletions

View file

@ -1309,11 +1309,11 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag
request->startTime = 0; request->startTime = 0;
request->startTimeMillis = 0; request->startTimeMillis = 0;
request->minStartTime = (int32_t) (getCurrentTimeMonotonicMillis() / 1000 + 2); request->minStartTime = (int32_t) (getCurrentTimeMonotonicMillis() / 1000 + 2);
} else if (error->error_code == 420) { } else if (error->error_code == 420 && (request->requestFlags & RequestFlagIgnoreFloodWait) == 0 && error->error_message.find("STORY_SEND_FLOOD") == std::string::npos) {
int32_t waitTime = 2; int32_t waitTime = 2;
static std::string floodWait = "FLOOD_WAIT_"; static std::string floodWait = "FLOOD_WAIT_";
static std::string slowmodeWait = "SLOWMODE_WAIT_"; static std::string slowmodeWait = "SLOWMODE_WAIT_";
discardResponse = (request->requestFlags & RequestFlagIgnoreFloodWait) == 0; discardResponse = true;
if (error->error_message.find(floodWait) != std::string::npos) { if (error->error_message.find(floodWait) != std::string::npos) {
std::string num = error->error_message.substr(floodWait.size(), error->error_message.size() - floodWait.size()); std::string num = error->error_message.substr(floodWait.size(), error->error_message.size() - floodWait.size());
waitTime = atoi(num.c_str()); waitTime = atoi(num.c_str());
@ -3060,7 +3060,9 @@ void ConnectionsManager::updateDcSettings(uint32_t dcNum, bool workaround, bool
if (!workaround && updatingDcSettingsAgain && updatingDcSettingsAgainDcNum == dcNum) { if (!workaround && updatingDcSettingsAgain && updatingDcSettingsAgainDcNum == dcNum) {
updatingDcSettingsAgain = false; updatingDcSettingsAgain = false;
for (auto & datacenter : datacenters) { for (auto & datacenter : datacenters) {
datacenter.second->resetInitVersion(); if (datacenter.first == dcNum) {
datacenter.second->resetInitVersion();
}
} }
updateDcSettings(updatingDcSettingsAgainDcNum, false, false); updateDcSettings(updatingDcSettingsAgainDcNum, false, false);
return; return;

View file

@ -701,6 +701,9 @@ public class AndroidUtilities {
public static void getViewPositionInParent(View view, ViewGroup parent, float[] pointPosition) { public static void getViewPositionInParent(View view, ViewGroup parent, float[] pointPosition) {
pointPosition[0] = 0; pointPosition[0] = 0;
pointPosition[1] = 0; pointPosition[1] = 0;
if (view == null || parent == null) {
return;
}
View currentView = view; View currentView = view;
while (currentView != parent) { while (currentView != parent) {
//fix strange offset inside view pager //fix strange offset inside view pager
@ -736,6 +739,22 @@ public class AndroidUtilities {
} }
} }
@RequiresApi(api = Build.VERSION_CODES.N)
public static void getBitmapFromSurface(Surface surface, Bitmap surfaceBitmap) {
if (surface == null || !surface.isValid()) {
return;
}
CountDownLatch countDownLatch = new CountDownLatch(1);
PixelCopy.request(surface, surfaceBitmap, copyResult -> {
countDownLatch.countDown();
}, Utilities.searchQueue.getHandler());
try {
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static float[] getCoordinateInParent(ViewGroup parentView, View view) { public static float[] getCoordinateInParent(ViewGroup parentView, View view) {
float x = 0, y = 0; float x = 0, y = 0;
View child = view; View child = view;

View file

@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 3793; public static int BUILD_VERSION = 3801;
public static String BUILD_VERSION_STRING = "10.0.1"; public static String BUILD_VERSION_STRING = "10.0.3";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -1333,6 +1333,13 @@ public class DatabaseMigrationHelper {
version = 128; version = 128;
} }
if (version == 128) {
database.executeFast("ALTER TABLE story_drafts ADD COLUMN type INTEGER default 0").stepThis().dispose();
database.executeFast("PRAGMA user_version = 129").stepThis().dispose();
version = 129;
}
return version; return version;
} }

View file

@ -92,7 +92,7 @@ public class DownloadController extends BaseController implements NotificationCe
public int maxVideoBitrate; public int maxVideoBitrate;
public Preset(int[] m, long p, long v, long f, boolean pv, boolean pm, boolean e, boolean l, int bitrate, boolean preloadStories) { public Preset(int[] m, long p, long v, long f, boolean pv, boolean pm, boolean e, boolean l, int bitrate, boolean preloadStories) {
System.arraycopy(m, 0, mask, 0, mask.length); System.arraycopy(m, 0, mask, 0, Math.max(m.length, mask.length));
sizes[PRESET_SIZE_NUM_PHOTO] = p; sizes[PRESET_SIZE_NUM_PHOTO] = p;
sizes[PRESET_SIZE_NUM_VIDEO] = v; sizes[PRESET_SIZE_NUM_VIDEO] = v;
sizes[PRESET_SIZE_NUM_DOCUMENT] = f; sizes[PRESET_SIZE_NUM_DOCUMENT] = f;

View file

@ -74,9 +74,18 @@ public class FileLoadOperation {
public boolean checkPrefixPreloadFinished() { public boolean checkPrefixPreloadFinished() {
if (preloadPrefixSize > 0 && downloadedBytes > preloadPrefixSize) { if (preloadPrefixSize > 0 && downloadedBytes > preloadPrefixSize) {
long minStart = Long.MAX_VALUE; long minStart = Long.MAX_VALUE;
for (int b = 0; b < notLoadedBytesRanges.size(); b++) { ArrayList<Range> array = notLoadedBytesRanges;
Range range = notLoadedBytesRanges.get(b); if (array == null) {
minStart = Math.min(minStart, range.start); return true;
}
try {
for (int b = 0; b < array.size(); b++) {
Range range = array.get(b);
minStart = Math.min(minStart, range.start);
}
} catch (Throwable e) {
FileLog.e(e);
return true;
} }
if (minStart > preloadPrefixSize) { if (minStart > preloadPrefixSize) {
return true; return true;

View file

@ -309,6 +309,9 @@ public class FileLoader extends BaseController {
} }
public void cancelFileUpload(final String location, final boolean enc) { public void cancelFileUpload(final String location, final boolean enc) {
if (location == null) {
return;
}
fileLoaderQueue.postRunnable(() -> { fileLoaderQueue.postRunnable(() -> {
FileUploadOperation operation; FileUploadOperation operation;
if (!enc) { if (!enc) {

View file

@ -24,6 +24,8 @@ import java.io.EOFException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -226,4 +228,29 @@ public class FileStreamLoadOperation extends BaseDataSource implements FileLoadO
priorityMap.put(document.id, priority); priorityMap.put(document.id, priority);
} }
} }
@Nullable
public static Uri prepareUri(int currentAccount, TLRPC.Document document, Object parent) {
String attachFileName = FileLoader.getAttachFileName(document);
File file = FileLoader.getInstance(currentAccount).getPathToAttach(document);
if (file != null && file.exists()) {
return Uri.fromFile(file);
}
try {
String params = "?account=" + currentAccount +
"&id=" + document.id +
"&hash=" + document.access_hash +
"&dc=" + document.dc_id +
"&size=" + document.size +
"&mime=" + URLEncoder.encode(document.mime_type, "UTF-8") +
"&rid=" + FileLoader.getInstance(currentAccount).getFileReference(parent) +
"&name=" + URLEncoder.encode(FileLoader.getDocumentFileName(document), "UTF-8") +
"&reference=" + Utilities.bytesToHex(document.file_reference != null ? document.file_reference : new byte[0]);
return Uri.parse("tg://" + attachFileName + params);
} catch (UnsupportedEncodingException e) {
FileLog.e(e);
}
return null;
}
} }

View file

@ -2249,7 +2249,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} }
public boolean hasNotThumb() { public boolean hasNotThumb() {
return currentImageDrawable != null || currentMediaDrawable != null || staticThumbDrawable instanceof VectorAvatarThumbDrawable; return currentImageDrawable != null || currentMediaDrawable != null || staticThumbDrawable instanceof VectorAvatarThumbDrawable || (staticThumbDrawable != null && currentImageKey == null && currentMediaKey == null);
} }
public boolean hasStaticThumb() { public boolean hasStaticThumb() {

View file

@ -143,7 +143,7 @@ public class MessagesController extends BaseController implements NotificationCe
public StoriesController storiesController; public StoriesController storiesController;
private boolean hasArchivedChats; private boolean hasArchivedChats;
private boolean hasStories; private boolean hasStories;
public long storiesChangelogUserId; public long storiesChangelogUserId = 777000;
public static TLRPC.Peer getPeerFromInputPeer(TLRPC.InputPeer peer) { public static TLRPC.Peer getPeerFromInputPeer(TLRPC.InputPeer peer) {
if (peer.chat_id != 0) { if (peer.chat_id != 0) {
@ -395,10 +395,9 @@ public class MessagesController extends BaseController implements NotificationCe
try { try {
SQLiteDatabase database = MessagesStorage.getInstance(currentAccount).getDatabase(); SQLiteDatabase database = MessagesStorage.getInstance(currentAccount).getDatabase();
if (database != null) { if (database != null) {
if (data == null) { database.executeFast("DELETE FROM app_config").stepThis().dispose();
database.executeFast("DELETE FROM app_config").stepThis().dispose(); if (data != null) {
} else { SQLitePreparedStatement state = database.executeFast("INSERT INTO app_config VALUES(?)");
SQLitePreparedStatement state = database.executeFast("REPLACE INTO app_config VALUES(?)");
state.requery(); state.requery();
NativeByteBuffer buffer = new NativeByteBuffer(data.getObjectSize()); NativeByteBuffer buffer = new NativeByteBuffer(data.getObjectSize());
data.serializeToStream(buffer); data.serializeToStream(buffer);
@ -16238,7 +16237,7 @@ public class MessagesController extends BaseController implements NotificationCe
} }
} }
} else if (baseUpdate instanceof TLRPC.TL_updateSentStoryReaction) { } else if (baseUpdate instanceof TLRPC.TL_updateSentStoryReaction) {
storiesController.updateStoryReaction(((TLRPC.TL_updateSentStoryReaction) baseUpdate).user_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).story_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).reaction); getStoriesController().updateStoryReaction(((TLRPC.TL_updateSentStoryReaction) baseUpdate).user_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).story_id, ((TLRPC.TL_updateSentStoryReaction) baseUpdate).reaction);
} }
} }
if (editor != null) { if (editor != null) {

View file

@ -95,7 +95,7 @@ public class MessagesStorage extends BaseController {
} }
} }
public final static int LAST_DB_VERSION = 128; public final static int LAST_DB_VERSION = 129;
private boolean databaseMigrationInProgress; private boolean databaseMigrationInProgress;
public boolean showClearDatabaseAlert; public boolean showClearDatabaseAlert;
private LongSparseIntArray dialogIsForum = new LongSparseIntArray(); private LongSparseIntArray dialogIsForum = new LongSparseIntArray();
@ -678,7 +678,7 @@ public class MessagesStorage extends BaseController {
database.executeFast("CREATE TABLE profile_stories (dialog_id INTEGER, story_id INTEGER, data BLOB, PRIMARY KEY(dialog_id, story_id));").stepThis().dispose(); database.executeFast("CREATE TABLE profile_stories (dialog_id INTEGER, story_id INTEGER, data BLOB, PRIMARY KEY(dialog_id, story_id));").stepThis().dispose();
database.executeFast("CREATE TABLE archived_stories (story_id INTEGER PRIMARY KEY, data BLOB);").stepThis().dispose(); database.executeFast("CREATE TABLE archived_stories (story_id INTEGER PRIMARY KEY, data BLOB);").stepThis().dispose();
database.executeFast("CREATE TABLE story_drafts (id INTEGER PRIMARY KEY, date INTEGER, data BLOB);").stepThis().dispose(); database.executeFast("CREATE TABLE story_drafts (id INTEGER PRIMARY KEY, date INTEGER, data BLOB, type INTEGER);").stepThis().dispose();
database.executeFast("CREATE TABLE story_pushes (uid INTEGER, sid INTEGER, date INTEGER, localName TEXT, flags INTEGER, expire_date INTEGER, PRIMARY KEY(uid, sid));").stepThis().dispose(); database.executeFast("CREATE TABLE story_pushes (uid INTEGER, sid INTEGER, date INTEGER, localName TEXT, flags INTEGER, expire_date INTEGER, PRIMARY KEY(uid, sid));").stepThis().dispose();

View file

@ -77,12 +77,9 @@ public class PushListenerController {
req.events.add(event); req.events.add(event);
sendStat = false; sendStat = false;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { SharedConfig.pushStatSent = true;
if (error != null) { SharedConfig.saveConfig();
SharedConfig.pushStatSent = true; ConnectionsManager.getInstance(currentAccount).sendRequest(req, null);
SharedConfig.saveConfig();
}
}));
} }
AndroidUtilities.runOnUIThread(() -> MessagesController.getInstance(currentAccount).registerForPush(pushType, token)); AndroidUtilities.runOnUIThread(() -> MessagesController.getInstance(currentAccount).registerForPush(pushType, token));
} }

View file

@ -4736,11 +4736,15 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
reqSend.reply_to = SendMessagesHelper.creteReplyInput(replyToTopMsg.getId()); reqSend.reply_to = SendMessagesHelper.creteReplyInput(replyToTopMsg.getId());
reqSend.flags |= 512; reqSend.flags |= 512;
} }
if (newMsg.from_id != null) { if (newMsg.from_id != null) {
reqSend.send_as = getMessagesController().getInputPeer(newMsg.from_id); reqSend.send_as = getMessagesController().getInputPeer(newMsg.from_id);
} }
reqSend.hide_via = !params.containsKey("bot"); reqSend.hide_via = !params.containsKey("bot");
if (newMsg.reply_to != null && newMsg.reply_to.reply_to_msg_id != 0) { if (replyToStoryItem != null) {
reqSend.reply_to = creteReplyInput(replyToStoryItem);
reqSend.flags |= 1;
} else if (newMsg.reply_to != null && newMsg.reply_to.reply_to_msg_id != 0) {
reqSend.flags |= 1; reqSend.flags |= 1;
reqSend.reply_to = SendMessagesHelper.creteReplyInput(newMsg.reply_to.reply_to_msg_id); reqSend.reply_to = SendMessagesHelper.creteReplyInput(newMsg.reply_to.reply_to_msg_id);
} }

View file

@ -735,7 +735,7 @@ public class SharedConfig {
if (updateVersionString == null) { if (updateVersionString == null) {
updateVersionString = BuildVars.BUILD_VERSION_STRING; updateVersionString = BuildVars.BUILD_VERSION_STRING;
} }
if (update.version == null || updateVersionString.compareTo(update.version) >= 0) { if (update.version == null || versionBiggerOrEqual(updateVersionString, update.version)) {
return false; return false;
} }
pendingAppUpdate = update; pendingAppUpdate = update;
@ -744,6 +744,22 @@ public class SharedConfig {
return true; return true;
} }
// returns a >= b
private static boolean versionBiggerOrEqual(String a, String b) {
String[] partsA = a.split("\\.");
String[] partsB = b.split("\\.");
for (int i = 0; i < Math.min(partsA.length, partsB.length); ++i) {
int numA = Integer.parseInt(partsA[i]);
int numB = Integer.parseInt(partsB[i]);
if (numA < numB) {
return false;
} else if (numA > numB) {
return true;
}
}
return true;
}
public static boolean checkPasscode(String passcode) { public static boolean checkPasscode(String passcode) {
if (passcodeSalt.length == 0) { if (passcodeSalt.length == 0) {
boolean result = Utilities.MD5(passcode).equals(passcodeHash); boolean result = Utilities.MD5(passcode).equals(passcodeHash);

View file

@ -272,6 +272,7 @@ public class UserConfig extends BaseController {
getMediaDataController().loadPremiumPromo(false); getMediaDataController().loadPremiumPromo(false);
getMediaDataController().loadReactions(false, true); getMediaDataController().loadReactions(false, true);
getMessagesController().getStoriesController().invalidateStoryLimit();
}); });
} }
} }

View file

@ -349,7 +349,6 @@ public class MediaCodecVideoConvertor {
long lastFramePts = -1; long lastFramePts = -1;
if (videoIndex >= 0) { if (videoIndex >= 0) {
try { try {
long videoTime = -1; long videoTime = -1;
boolean outputDone = false; boolean outputDone = false;
@ -444,27 +443,22 @@ public class MediaCodecVideoConvertor {
outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate); outputFormat.setInteger(MediaFormat.KEY_FRAME_RATE, framerate);
outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1); outputFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
// boolean hasHDR = false; boolean hasHDR = false;
// int hdrType = 0; int colorTransfer = 0, colorStandard = 0, colorRange = 0;
// int colorTransfer = 0, colorStandard = 0, colorRange = 0; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (videoFormat.containsKey(MediaFormat.KEY_COLOR_TRANSFER)) {
// if (videoFormat.containsKey(MediaFormat.KEY_COLOR_TRANSFER)) { colorTransfer = videoFormat.getInteger(MediaFormat.KEY_COLOR_TRANSFER);
// colorTransfer = videoFormat.getInteger(MediaFormat.KEY_COLOR_TRANSFER); }
// } if (videoFormat.containsKey(MediaFormat.KEY_COLOR_STANDARD)) {
// if (videoFormat.containsKey(MediaFormat.KEY_COLOR_STANDARD)) { colorStandard = videoFormat.getInteger(MediaFormat.KEY_COLOR_STANDARD);
// colorStandard = videoFormat.getInteger(MediaFormat.KEY_COLOR_STANDARD); }
// } if (videoFormat.containsKey(MediaFormat.KEY_COLOR_RANGE)) {
// if (videoFormat.containsKey(MediaFormat.KEY_COLOR_RANGE)) { colorRange = videoFormat.getInteger(MediaFormat.KEY_COLOR_RANGE);
// colorRange = videoFormat.getInteger(MediaFormat.KEY_COLOR_RANGE); }
// } if ((colorTransfer == MediaFormat.COLOR_TRANSFER_ST2084 || colorTransfer == MediaFormat.COLOR_TRANSFER_HLG) && colorStandard == MediaFormat.COLOR_STANDARD_BT2020) {
// if (videoFormat.containsKey(MediaFormat.KEY_HDR_STATIC_INFO)) { hasHDR = true;
// ByteBuffer bytes = videoFormat.getByteBuffer(MediaFormat.KEY_HDR_STATIC_INFO); }
// } }
// if ((colorTransfer == MediaFormat.COLOR_TRANSFER_ST2084 || colorTransfer == MediaFormat.COLOR_TRANSFER_HLG) && colorStandard == MediaFormat.COLOR_STANDARD_BT2020) {
// hasHDR = true;
// hdrType = colorTransfer == MediaFormat.COLOR_TRANSFER_HLG ? 1 : 2;
// }
// }
if (Build.VERSION.SDK_INT < 23 && Math.min(h, w) <= 480 && !isAvatar) { if (Build.VERSION.SDK_INT < 23 && Math.min(h, w) <= 480 && !isAvatar) {
if (bitrate > 921600) { if (bitrate > 921600) {
@ -482,6 +476,15 @@ public class MediaCodecVideoConvertor {
encoder.start(); encoder.start();
outputSurface = new OutputSurface(savedFilterState, null, paintPath, mediaEntities, cropState, resultWidth, resultHeight, originalWidth, originalHeight, rotationValue, framerate, false, gradientTopColor, gradientBottomColor, hdrInfo, parts); outputSurface = new OutputSurface(savedFilterState, null, paintPath, mediaEntities, cropState, resultWidth, resultHeight, originalWidth, originalHeight, rotationValue, framerate, false, gradientTopColor, gradientBottomColor, hdrInfo, parts);
if (hdrInfo == null && outputSurface.supportsEXTYUV() && hasHDR) {
hdrInfo = new StoryEntry.HDRInfo();
hdrInfo.colorTransfer = colorTransfer;
hdrInfo.colorStandard = colorStandard;
hdrInfo.colorRange = colorRange;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
outputFormat.setInteger(MediaFormat.KEY_COLOR_TRANSFER, MediaFormat.COLOR_TRANSFER_SDR_VIDEO);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && hdrInfo != null && hdrInfo.getHDRType() != 0 && outputSurface.supportsEXTYUV()) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && hdrInfo != null && hdrInfo.getHDRType() != 0 && outputSurface.supportsEXTYUV()) {
outputSurface.changeFragmentShader( outputSurface.changeFragmentShader(
hdrFragmentShader(originalWidth, originalHeight, resultWidth, resultHeight, true, hdrInfo), hdrFragmentShader(originalWidth, originalHeight, resultWidth, resultHeight, true, hdrInfo),
@ -1164,6 +1167,7 @@ public class MediaCodecVideoConvertor {
} }
shaderCode = shaderCode.replace("$dstWidth", dstWidth + ".0"); shaderCode = shaderCode.replace("$dstWidth", dstWidth + ".0");
shaderCode = shaderCode.replace("$dstHeight", dstHeight + ".0"); shaderCode = shaderCode.replace("$dstHeight", dstHeight + ".0");
// TODO(@dkaraush): use minlum/maxlum
return shaderCode + "\n" + return shaderCode + "\n" +
"in vec2 vTextureCoord;\n" + "in vec2 vTextureCoord;\n" +
"out vec4 fragColor;\n" + "out vec4 fragColor;\n" +

View file

@ -0,0 +1,426 @@
package org.telegram.messenger.video;
import android.graphics.Bitmap;
import android.graphics.Paint;
import android.graphics.SurfaceTexture;
import android.net.Uri;
import android.os.Build;
import android.view.SurfaceView;
import android.view.TextureView;
import com.google.android.exoplayer2.ExoPlayer;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.FileStreamLoadOperation;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.VideoPlayer;
//used for player in background thread
public class VideoPlayerHolderBase {
public boolean paused;
public TLRPC.Document document;
VideoPlayer videoPlayer;
Runnable initRunnable;
volatile boolean released;
public boolean firstFrameRendered;
public float progress;
int lastState;
public long currentPosition;
private int currentAccount;
long playerDuration;
boolean audioDisabled;
public boolean stubAvailable;
private TextureView textureView;
private SurfaceView surfaceView;
public Bitmap playerStubBitmap;
public Paint playerStubPaint;
public long pendingSeekTo;
Uri contentUri;
public VideoPlayerHolderBase() {
}
public VideoPlayerHolderBase with(SurfaceView surfaceView) {
this.surfaceView = surfaceView;
this.textureView = null;
return this;
}
public VideoPlayerHolderBase with(TextureView textureView) {
this.surfaceView = null;
this.textureView = textureView;
return this;
}
final DispatchQueue dispatchQueue = Utilities.getOrCreatePlayerQueue();
public Uri uri;
Runnable progressRunnable = new Runnable() {
@Override
public void run() {
if (videoPlayer != null) {
if (lastState == ExoPlayer.STATE_ENDED) {
progress = 1f;
} else {
currentPosition = videoPlayer.getCurrentPosition();
playerDuration = videoPlayer.getDuration();
}
if (lastState == ExoPlayer.STATE_READY) {
dispatchQueue.cancelRunnable(progressRunnable);
dispatchQueue.postRunnable(progressRunnable, 16);
}
}
}
};
long startTime;
public void preparePlayer(Uri uri, boolean audioDisabled) {
this.audioDisabled = audioDisabled;
this.currentAccount = currentAccount;
this.contentUri = uri;
paused = true;
if (initRunnable != null) {
dispatchQueue.cancelRunnable(initRunnable);
}
dispatchQueue.postRunnable(initRunnable = () -> {
if (released) {
return;
}
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other", FileLoader.PRIORITY_LOW);
videoPlayer.setPlayWhenReady(false);
videoPlayer.setWorkerQueue(dispatchQueue);
});
}
public void start(boolean paused, Uri uri, long t, boolean audioDisabled) {
startTime = System.currentTimeMillis();
this.audioDisabled = audioDisabled;
this.paused = paused;
dispatchQueue.postRunnable(initRunnable = () -> {
if (released) {
return;
}
if (videoPlayer == null) {
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other");
videoPlayer.setWorkerQueue(dispatchQueue);
if (!paused) {
if (surfaceView != null) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
videoPlayer.setPlayWhenReady(true);
}
} else {
if (!paused) {
if (surfaceView != null) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
videoPlayer.play();
}
}
if (t > 0) {
videoPlayer.seekTo(t);
}
// videoPlayer.setVolume(isInSilentMode ? 0 : 1f);
AndroidUtilities.runOnUIThread(() -> initRunnable = null);
});
}
private void ensurePlayerCreated(boolean audioDisabled) {
if (videoPlayer != null) {
videoPlayer.releasePlayer(true);
}
videoPlayer = new VideoPlayer(false, audioDisabled);
videoPlayer.setDelegate(new VideoPlayer.VideoPlayerDelegate() {
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
lastState = playbackState;
if (playbackState == ExoPlayer.STATE_READY || playbackState == ExoPlayer.STATE_BUFFERING) {
dispatchQueue.cancelRunnable(progressRunnable);
dispatchQueue.postRunnable(progressRunnable);
} else if (playbackState == ExoPlayer.STATE_ENDED) {
if (needRepeat()) {
progress = 0;
videoPlayer.seekTo(0);
videoPlayer.play();
} else {
progress = 1f;
}
}
VideoPlayerHolderBase.this.onStateChanged(playWhenReady, playbackState);
}
@Override
public void onError(VideoPlayer player, Exception e) {
FileLog.e(e);
}
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
}
@Override
public void onRenderedFirstFrame() {
AndroidUtilities.runOnUIThread(() -> {
if (released ) {
return;
}
VideoPlayerHolderBase.this.onRenderedFirstFrame();
if (onReadyListener != null) {
onReadyListener.run();
onReadyListener = null;
}
}, 16);
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
return false;
}
});
videoPlayer.setIsStory();
}
private Runnable onReadyListener;
public void setOnReadyListener(Runnable listener) {
onReadyListener = listener;
}
public boolean release(Runnable whenReleased) {
TLRPC.Document document = this.document;
if (document != null) {
int priority = FileStreamLoadOperation.getStreamPrioriy(document);
if (priority != FileLoader.PRIORITY_LOW) {
FileStreamLoadOperation.setPriorityForDocument(document, FileLoader.PRIORITY_LOW);
FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_LOW, document, null, null, null, null, null);
}
}
released = true;
dispatchQueue.cancelRunnable(initRunnable);
initRunnable = null;
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
videoPlayer.setTextureView(null);
videoPlayer.setSurfaceView(null);
videoPlayer.releasePlayer(false);
}
if (document != null) {
FileLoader.getInstance(currentAccount).cancelLoadFile(document);
}
if (whenReleased != null) {
AndroidUtilities.runOnUIThread(whenReleased);
}
videoPlayer = null;
});
if (playerStubBitmap != null) {
AndroidUtilities.recycleBitmap(playerStubBitmap);
playerStubBitmap = null;
}
return true;
}
public void pause() {
if (released) {
return;
}
if (paused) {
return;
}
paused = true;
if (surfaceView != null && firstFrameRendered && surfaceView.getHolder().getSurface().isValid()) {
stubAvailable = true;
if (playerStubBitmap == null) {
playerStubBitmap = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
playerStubPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
AndroidUtilities.getBitmapFromSurface(surfaceView, playerStubBitmap);
}
}
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
videoPlayer.pause();
}
});
}
public void play() {
if (released) {
return;
}
if (!paused) {
return;
}
paused = false;
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
if (surfaceView != null) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
if (pendingSeekTo > 0) {
videoPlayer.seekTo(pendingSeekTo);
pendingSeekTo = 0;
}
videoPlayer.setPlayWhenReady(true);
}
});
}
public void setAudioEnabled(boolean enabled, boolean prepared) {
boolean disabled = !enabled;
if (audioDisabled == disabled) {
return;
}
audioDisabled = disabled;
dispatchQueue.postRunnable(() -> {
if (videoPlayer == null) {
return;
}
boolean playing = videoPlayer.isPlaying();
if (enabled && !videoPlayer.createdWithAudioTrack()) {
//release and create new with audio track
videoPlayer.pause();
long position = videoPlayer.getCurrentPosition();
videoPlayer.releasePlayer(false);
videoPlayer = null;
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other");
videoPlayer.setWorkerQueue(dispatchQueue);
if (!prepared) {
if (surfaceView != null) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
}
// videoPlayer.setTextureView(textureView);
videoPlayer.seekTo(position + 50);
if (playing && !prepared) {
videoPlayer.setPlayWhenReady(true);
videoPlayer.play();
} else {
videoPlayer.setPlayWhenReady(false);
videoPlayer.pause();
}
} else {
videoPlayer.setVolume(enabled ? 1f : 0);
}
});
}
public float getPlaybackProgress(long totalDuration) {
if (lastState == ExoPlayer.STATE_ENDED) {
progress = 1f;
} else {
float localProgress;
if (totalDuration != 0) {
localProgress = currentPosition / (float) totalDuration;
} else {
localProgress = currentPosition / (float) playerDuration;
}
if (localProgress < progress) {
return progress;
}
progress = localProgress;
}
return progress;
}
public void loopBack() {
progress = 0;
lastState = ExoPlayer.STATE_IDLE;
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
videoPlayer.seekTo(0);
}
progress = 0;
currentPosition = 0;
});
}
public void setVolume(float v) {
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
videoPlayer.setVolume(v);
}
});
}
public boolean isBuffering() {
return !released && lastState == ExoPlayer.STATE_BUFFERING;
}
public long getCurrentPosition() {
return currentPosition;
}
public long getDuration() {
return playerDuration;
}
public boolean isPlaying() {
return !paused;
}
public void onRenderedFirstFrame() {
}
public void onStateChanged(boolean playWhenReady, int playbackState) {
}
public boolean needRepeat() {
return false;
}
public void seekTo(long position) {
dispatchQueue.postRunnable(() -> {
if (videoPlayer == null) {
pendingSeekTo = position;
return;
}
videoPlayer.seekTo(position);
});
}
public Uri getCurrentUri() {
return contentUri;
}
public void setPlaybackSpeed(float currentVideoSpeed) {
dispatchQueue.postRunnable(() -> {
if (videoPlayer == null) {
return;
}
videoPlayer.setPlaybackSpeed(currentVideoSpeed);
});
}
}

View file

@ -56,6 +56,7 @@ import androidx.core.graphics.ColorUtils;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.LiteMode;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
@ -271,10 +272,10 @@ public class AlertDialog extends Dialog implements Drawable.Callback, Notificati
super(context, R.style.TransparentDialog); super(context, R.style.TransparentDialog);
this.resourcesProvider = resourcesProvider; this.resourcesProvider = resourcesProvider;
blurredNativeBackground = supportsNativeBlur() && progressViewStyle == ALERT_TYPE_MESSAGE;
backgroundColor = getThemedColor(Theme.key_dialogBackground); backgroundColor = getThemedColor(Theme.key_dialogBackground);
final boolean isDark = AndroidUtilities.computePerceivedBrightness(backgroundColor) < 0.721f; final boolean isDark = AndroidUtilities.computePerceivedBrightness(backgroundColor) < 0.721f;
blurredBackground = blurredNativeBackground || !supportsNativeBlur() && SharedConfig.getDevicePerformanceClass() >= SharedConfig.PERFORMANCE_CLASS_HIGH && isDark; blurredNativeBackground = supportsNativeBlur() && progressViewStyle == ALERT_TYPE_MESSAGE;
blurredBackground = (blurredNativeBackground || !supportsNativeBlur() && SharedConfig.getDevicePerformanceClass() >= SharedConfig.PERFORMANCE_CLASS_HIGH && LiteMode.isEnabled(LiteMode.FLAG_CHAT_BLUR)) && isDark;
backgroundPaddings = new Rect(); backgroundPaddings = new Rect();
if (progressStyle != ALERT_TYPE_SPINNER || blurredBackground) { if (progressStyle != ALERT_TYPE_SPINNER || blurredBackground) {

View file

@ -65,6 +65,7 @@ import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BotWebViewVibrationEffect; import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
@ -989,8 +990,12 @@ public final class FloatingToolbar {
}); });
} }
final int size = menuItems.size(); final int size = menuItems.size();
final boolean premiumLocked = MessagesController.getInstance(UserConfig.selectedAccount).premiumLocked;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
overflowPanelAdapter.add(menuItems.get(i)); final MenuItem menuItem = menuItems.get(i);
if (!premiumOptions.contains(menuItem.getItemId()) || !premiumLocked) {
overflowPanelAdapter.add(menuItem);
}
} }
mOverflowPanel.setAdapter(overflowPanelAdapter); mOverflowPanel.setAdapter(overflowPanelAdapter);
if (mOpenOverflowUpwards) { if (mOpenOverflowUpwards) {

View file

@ -1067,7 +1067,7 @@ public class Theme {
for (int a = 0, N = accents.size(); a < N; a++) { for (int a = 0, N = accents.size(); a < N; a++) {
ThemeAccent accent = accents.get(a); ThemeAccent accent = accents.get(a);
File wallpaper = accent.getPathToWallpaper(); File wallpaper = accent.getPathToWallpaper();
if (wallpaper != null && wallpaper.exists()) { if (wallpaper != null && wallpaper.length() > 0) {
accents.remove(a); accents.remove(a);
a--; a--;
N--; N--;
@ -9580,7 +9580,9 @@ public class Theme {
int gradientToColor2 = currentColors.get(key_chat_wallpaper_gradient_to2); int gradientToColor2 = currentColors.get(key_chat_wallpaper_gradient_to2);
int gradientToColor1 = currentColors.get(key_chat_wallpaper_gradient_to1); int gradientToColor1 = currentColors.get(key_chat_wallpaper_gradient_to1);
boolean bitmapCreated = false;
if (wallpaperFile != null && wallpaperFile.exists()) { if (wallpaperFile != null && wallpaperFile.exists()) {
bitmapCreated = true;
try { try {
if (backgroundColor != 0 && gradientToColor1 != 0 && gradientToColor2 != 0) { if (backgroundColor != 0 && gradientToColor1 != 0 && gradientToColor2 != 0) {
MotionBackgroundDrawable motionBackgroundDrawable = new MotionBackgroundDrawable(backgroundColor, gradientToColor1, gradientToColor2, gradientToColor3, false); MotionBackgroundDrawable motionBackgroundDrawable = new MotionBackgroundDrawable(backgroundColor, gradientToColor1, gradientToColor2, gradientToColor3, false);
@ -9592,6 +9594,9 @@ public class Theme {
patternBitmap = patternBitmap.copy(Bitmap.Config.ALPHA_8, false); patternBitmap = patternBitmap.copy(Bitmap.Config.ALPHA_8, false);
toRecycle.recycle(); toRecycle.recycle();
} }
if (patternBitmap == null) {
bitmapCreated = false;
}
motionBackgroundDrawable.setPatternBitmap(intensity, patternBitmap); motionBackgroundDrawable.setPatternBitmap(intensity, patternBitmap);
motionBackgroundDrawable.setPatternColorFilter(motionBackgroundDrawable.getPatternColor()); motionBackgroundDrawable.setPatternColorFilter(motionBackgroundDrawable.getPatternColor());
settings.wallpaper = motionBackgroundDrawable; settings.wallpaper = motionBackgroundDrawable;
@ -9604,6 +9609,9 @@ public class Theme {
} catch (Throwable e) { } catch (Throwable e) {
FileLog.e(e); FileLog.e(e);
} }
}
if (bitmapCreated) {
} else if (backgroundColor != 0) { } else if (backgroundColor != 0) {
int rotation = currentColors.get(key_chat_wallpaper_gradient_rotation, -1); int rotation = currentColors.get(key_chat_wallpaper_gradient_rotation, -1);
if (rotation == -1) { if (rotation == -1) {
@ -9620,7 +9628,9 @@ public class Theme {
FileOutputStream stream = null; FileOutputStream stream = null;
try { try {
stream = new FileOutputStream(wallpaperFile); stream = new FileOutputStream(wallpaperFile);
patternBitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); Bitmap bitmap = patternBitmap.copy(Bitmap.Config.ARGB_8888, true);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream);
bitmap.recycle();
stream.close(); stream.close();
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);

View file

@ -492,15 +492,13 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
} else { } else {
tabsTranslation = 0; tabsTranslation = 0;
} }
if (hasHiddenArchive && position == 0 && recyclerListView.getPaddingTop() - view.getTop() - view.getMeasuredHeight() + tabsTranslation < 0) { if (recyclerListView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING) {
position = 1; if (hasHiddenArchive && position == 0 && recyclerListView.getPaddingTop() - view.getTop() - view.getMeasuredHeight() + tabsTranslation < 0) {
offset = tabsTranslation; position = 1;
offset = tabsTranslation;
}
layoutManager.scrollToPositionWithOffset(position, (int) offset);
} }
// if (firstUpdate && hasStories) {
// offset -= AndroidUtilities.dp(DialogStoriesCell.HEIGHT_IN_DP);
// }
// firstUpdate = false;
layoutManager.scrollToPositionWithOffset(position, (int) offset);
} }
} }
DiffUtil.calculateDiff(new DiffUtil.Callback() { DiffUtil.calculateDiff(new DiffUtil.Callback() {
@ -1110,7 +1108,7 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter implements
} }
} }
parentFragment.getOrCreateStoryViewer().open(mContext, null, peerIds, 0, null, null, StoriesListPlaceProvider.of(recyclerListView), false); parentFragment.getOrCreateStoryViewer().open(mContext, null, peerIds, 0, null, null, StoriesListPlaceProvider.of(recyclerListView, true), false);
} }
public void setIsTransitionSupport() { public void setIsTransitionSupport() {

View file

@ -27,6 +27,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
@ -65,6 +66,7 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SoundEffectConstants; import android.view.SoundEffectConstants;
import android.view.Surface;
import android.view.TextureView; import android.view.TextureView;
import android.view.VelocityTracker; import android.view.VelocityTracker;
import android.view.View; import android.view.View;
@ -112,6 +114,7 @@ import org.telegram.messenger.DownloadController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FileStreamLoadOperation;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.ImageReceiver;
@ -127,6 +130,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.WebFile; import org.telegram.messenger.WebFile;
import org.telegram.messenger.browser.Browser; import org.telegram.messenger.browser.Browser;
import org.telegram.messenger.video.VideoPlayerHolderBase;
import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
@ -171,6 +175,7 @@ import org.telegram.ui.Components.TextPaintUrlSpan;
import org.telegram.ui.Components.TextPaintWebpageUrlSpan; import org.telegram.ui.Components.TextPaintWebpageUrlSpan;
import org.telegram.ui.Components.TranslateAlert2; import org.telegram.ui.Components.TranslateAlert2;
import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.Components.VideoPlayer;
import org.telegram.ui.Components.WebPlayerView; import org.telegram.ui.Components.WebPlayerView;
import java.io.File; import java.io.File;
@ -830,6 +835,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
attachedToWindow = false; attachedToWindow = false;
if (videoPlayer != null) {
videoPlayer.release(null);
videoPlayer = null;
}
currentPlayer = null;
} }
@Override @Override
@ -3042,6 +3052,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
windowView.setClipChildren(true); windowView.setClipChildren(true);
windowView.setFocusable(false); windowView.setFocusable(false);
containerView = new FrameLayout(activity) { containerView = new FrameLayout(activity) {
@Override @Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) { protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if (windowView.movingPage) { if (windowView.movingPage) {
@ -3107,7 +3118,8 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
windowView.addView(fullscreenVideoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); windowView.addView(fullscreenVideoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
fullscreenAspectRatioView = new AspectRatioFrameLayout(activity); fullscreenAspectRatioView = new AspectRatioFrameLayout(activity);
fullscreenAspectRatioView.setVisibility(View.GONE); fullscreenAspectRatioView.setVisibility(View.VISIBLE);
fullscreenAspectRatioView.setBackgroundColor(Color.BLACK);
fullscreenVideoContainer.addView(fullscreenAspectRatioView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER)); fullscreenVideoContainer.addView(fullscreenAspectRatioView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER));
fullscreenTextureView = new TextureView(activity); fullscreenTextureView = new TextureView(activity);
@ -3169,6 +3181,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
setCurrentHeaderHeight((int) (windowView.startMovingHeaderHeight + (AndroidUtilities.dp(56) - windowView.startMovingHeaderHeight) * progress)); setCurrentHeaderHeight((int) (windowView.startMovingHeaderHeight + (AndroidUtilities.dp(56) - windowView.startMovingHeaderHeight) * progress));
} }
} }
@Override
protected void dispatchDraw(Canvas canvas) {
checkVideoPlayer();
super.dispatchDraw(canvas);
}
}; };
((DefaultItemAnimator) listView[i].getItemAnimator()).setDelayAnimations(false); ((DefaultItemAnimator) listView[i].getItemAnimator()).setDelayAnimations(false);
listView[i].setLayoutManager(layoutManager[i] = new LinearLayoutManager(parentActivity, LinearLayoutManager.VERTICAL, false)); listView[i].setLayoutManager(layoutManager[i] = new LinearLayoutManager(parentActivity, LinearLayoutManager.VERTICAL, false));
@ -3286,6 +3304,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
if (recyclerView.getChildCount() == 0) { if (recyclerView.getChildCount() == 0) {
return; return;
} }
recyclerView.invalidate();
textSelectionHelper.onParentScrolled(); textSelectionHelper.onParentScrolled();
headerView.invalidate(); headerView.invalidate();
checkScroll(dy); checkScroll(dy);
@ -3738,13 +3757,10 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
}); });
containerView.addView(textSelectionHelper.getOverlayView(activity)); containerView.addView(textSelectionHelper.getOverlayView(activity));
pinchToZoomHelper = new PinchToZoomHelper(containerView, windowView); pinchToZoomHelper = new PinchToZoomHelper(containerView, containerView);
pinchToZoomHelper.setClipBoundsListener(new PinchToZoomHelper.ClipBoundsListener() { pinchToZoomHelper.setClipBoundsListener(topBottom -> {
@Override topBottom[0] = currentHeaderHeight;
public void getClipTopBottom(float[] topBottom) { topBottom[1] = listView[0].getMeasuredHeight();
topBottom[0] = currentHeaderHeight;
topBottom[1] = listView[0].getMeasuredHeight();
}
}); });
pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() { pinchToZoomHelper.setCallback(new PinchToZoomHelper.Callback() {
@Override @Override
@ -3757,6 +3773,43 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
updatePaintColors(); updatePaintColors();
} }
VideoPlayerHolderBase videoPlayer;
BlockVideoCell currentPlayer;
private void checkVideoPlayer() {
RecyclerView recyclerView = listView[0];
if (recyclerView == null && attachedToWindow) {
return;
}
BlockVideoCell bestView = null;
float bestViewCenterX = 0;
float parentCenterX = recyclerView.getMeasuredHeight() / 2f;
for (int i = 0; i < recyclerView.getChildCount(); i++) {
View child = recyclerView.getChildAt(i);
if (child instanceof BlockVideoCell) {
float centerX = child.getTop() + child.getMeasuredHeight() / 2f;
if (bestView == null || (Math.abs(parentCenterX - centerX) < (Math.abs(parentCenterX - bestViewCenterX)))) {
bestView = (BlockVideoCell) child;
bestViewCenterX = centerX;
}
}
}
boolean allowPlayer = !PhotoViewer.getInstance().isVisibleOrAnimating();
if (!allowPlayer || (currentPlayer != null && currentPlayer != bestView && videoPlayer != null)) {
if (videoPlayer != null) {
currentPlayer.playFrom = videoPlayer.getCurrentPosition();
videoPlayer.release(null);
}
videoPlayer = null;
currentPlayer = null;
}
if (allowPlayer && bestView != null) {
bestView.startVideoPlayer();
currentPlayer = bestView;
}
}
private void showSearch(boolean show) { private void showSearch(boolean show) {
if (searchContainer == null || (searchContainer.getTag() != null) == show) { if (searchContainer == null || (searchContainer.getTag() != null) == show) {
return; return;
@ -4054,7 +4107,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
return; return;
} }
int maxHeight = AndroidUtilities.dp(56); int maxHeight = AndroidUtilities.dp(56);
int minHeight = Math.max(AndroidUtilities.statusBarHeight, AndroidUtilities.dp(24)); int minHeight = AndroidUtilities.dp(24);
if (newHeight < minHeight) { if (newHeight < minHeight) {
newHeight = minHeight; newHeight = minHeight;
@ -5976,9 +6029,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
private class BlockVideoCell extends FrameLayout implements DownloadController.FileDownloadProgressListener, TextSelectionHelper.ArticleSelectableView { private class BlockVideoCell extends FrameLayout implements DownloadController.FileDownloadProgressListener, TextSelectionHelper.ArticleSelectableView {
public long playFrom;
private DrawingText captionLayout; private DrawingText captionLayout;
private DrawingText creditLayout; private DrawingText creditLayout;
private ImageReceiver imageView; private ImageReceiver imageView;
private AspectRatioFrameLayout aspectRatioFrameLayout;
private TextureView textureView;
private RadialProgress2 radialProgress; private RadialProgress2 radialProgress;
private BlockChannelCell channelCell; private BlockChannelCell channelCell;
private int currentType; private int currentType;
@ -6007,6 +6063,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
private MessageObject.GroupedMessagePosition groupPosition; private MessageObject.GroupedMessagePosition groupPosition;
private WebpageAdapter parentAdapter; private WebpageAdapter parentAdapter;
private boolean firstFrameRendered;
public BlockVideoCell(Context context, WebpageAdapter adapter, int type) { public BlockVideoCell(Context context, WebpageAdapter adapter, int type) {
super(context); super(context);
@ -6022,9 +6079,25 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
radialProgress.setColors(0x66000000, 0x7f000000, 0xffffffff, 0xffd9d9d9); radialProgress.setColors(0x66000000, 0x7f000000, 0xffffffff, 0xffd9d9d9);
TAG = DownloadController.getInstance(currentAccount).generateObserverTag(); TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
channelCell = new BlockChannelCell(context, parentAdapter, 1); channelCell = new BlockChannelCell(context, parentAdapter, 1);
aspectRatioFrameLayout = new AspectRatioFrameLayout(context);
aspectRatioFrameLayout.setResizeMode(AspectRatioFrameLayout.RESIZE_MODE_FIT);
textureView = new TextureView(context);
textureView.setOpaque(false);
aspectRatioFrameLayout.addView(textureView);
addView(aspectRatioFrameLayout);
addView(channelCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); addView(channelCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
} }
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
if (child == aspectRatioFrameLayout && pinchToZoomHelper.isInOverlayModeFor(this)) {
return true;
}
return super.drawChild(canvas, child, drawingTime);
}
public void setBlock(TLRPC.TL_pageBlockVideo block, boolean first, boolean last) { public void setBlock(TLRPC.TL_pageBlockVideo block, boolean first, boolean last) {
currentBlock = block; currentBlock = block;
parentBlock = null; parentBlock = null;
@ -6050,7 +6123,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, null)) { if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, textureView, null)) {
return true; return true;
} }
float x = event.getX(); float x = event.getX();
@ -6158,23 +6231,29 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} }
} }
imageView.setQualityThumbDocument(currentDocument); imageView.setQualityThumbDocument(currentDocument);
imageView.setImageCoords(photoX, (isFirst || currentType == 1 || currentType == 2 || currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8), photoWidth, photoHeight); int photoY = (isFirst || currentType == 1 || currentType == 2 || currentBlock.level > 0) ? 0 : AndroidUtilities.dp(8);
imageView.setImageCoords(photoX, photoY, photoWidth, photoHeight);
if (isGif) { if (isGif) {
autoDownload = DownloadController.getInstance(currentAccount).canDownloadMedia(DownloadController.AUTODOWNLOAD_TYPE_VIDEO, currentDocument.size); autoDownload = DownloadController.getInstance(currentAccount).canDownloadMedia(DownloadController.AUTODOWNLOAD_TYPE_VIDEO, currentDocument.size);
File path = FileLoader.getInstance(currentAccount).getPathToAttach(currentDocument, true); File path = FileLoader.getInstance(currentAccount).getPathToAttach(currentDocument, true);
if (autoDownload || path.exists()) { if (autoDownload || path.exists()) {
imageView.setStrippedLocation(null); imageView.setStrippedLocation(null);
imageView.setImage(ImageLocation.getForDocument(currentDocument), ImageLoader.AUTOPLAY_FILTER, null, null, ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", null, currentDocument.size, null, parentAdapter.currentPage, 1); TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(currentDocument.thumbs, 1000);
imageView.setImage(null, null, ImageLocation.getForObject(photoSize, currentDocument), "200_200", ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", null, currentDocument.size, null, parentAdapter.currentPage, 1);
} else { } else {
imageView.setStrippedLocation(ImageLocation.getForDocument(currentDocument)); imageView.setStrippedLocation(ImageLocation.getForDocument(currentDocument));
imageView.setImage(null, null, null, null, ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", null, currentDocument.size, null, parentAdapter.currentPage, 1); imageView.setImage(null, null, null, null, ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", null, currentDocument.size, null, parentAdapter.currentPage, 1);
} }
FrameLayout.LayoutParams params = (LayoutParams) aspectRatioFrameLayout.getLayoutParams();
params.leftMargin = photoX;
params.topMargin = photoY;
params.width = photoWidth;
params.height = photoHeight;
} else { } else {
imageView.setStrippedLocation(null); imageView.setStrippedLocation(null);
imageView.setImage(null, null, ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", 0, null, parentAdapter.currentPage, 1); imageView.setImage(null, null, ImageLocation.getForDocument(thumb, currentDocument), "80_80_b", 0, null, parentAdapter.currentPage, 1);
} }
imageView.setAspectFit(true); // imageView.setAspectFit(true);
buttonX = (int) (imageView.getImageX() + (imageView.getImageWidth() - size) / 2.0f); buttonX = (int) (imageView.getImageX() + (imageView.getImageWidth() - size) / 2.0f);
buttonY = (int) (imageView.getImageY() + (imageView.getImageHeight() - size) / 2.0f); buttonY = (int) (imageView.getImageY() + (imageView.getImageHeight() - size) / 2.0f);
radialProgress.setProgressRect(buttonX, buttonY, buttonX + size, buttonY + size); radialProgress.setProgressRect(buttonX, buttonY, buttonX + size, buttonY + size);
@ -6208,7 +6287,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
channelCell.measure(widthMeasureSpec, heightMeasureSpec); channelCell.measure(widthMeasureSpec, heightMeasureSpec);
channelCell.setTranslationY(imageView.getImageHeight() - AndroidUtilities.dp(39)); channelCell.setTranslationY(imageView.getImageHeight() - AndroidUtilities.dp(39));
setMeasuredDimension(width, height); super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
} }
@Override @Override
@ -6221,9 +6300,6 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} }
if (!pinchToZoomHelper.isInOverlayModeFor(this)) { if (!pinchToZoomHelper.isInOverlayModeFor(this)) {
imageView.draw(canvas); imageView.draw(canvas);
if (imageView.getVisible()) {
radialProgress.draw(canvas);
}
} }
int count = 0; int count = 0;
if (captionLayout != null) { if (captionLayout != null) {
@ -6243,6 +6319,13 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
if (currentBlock.level > 0) { if (currentBlock.level > 0) {
canvas.drawRect(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(20), getMeasuredHeight() - (currentBlock.bottom ? AndroidUtilities.dp(6) : 0), quoteLinePaint); canvas.drawRect(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(20), getMeasuredHeight() - (currentBlock.bottom ? AndroidUtilities.dp(6) : 0), quoteLinePaint);
} }
super.onDraw(canvas);
if (!pinchToZoomHelper.isInOverlayModeFor(this)) {
if (imageView.getVisible()) {
radialProgress.draw(canvas);
}
}
} }
private int getIconForCurrentState() { private int getIconForCurrentState() {
@ -6330,11 +6413,14 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} }
} }
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
imageView.onDetachedFromWindow(); imageView.onDetachedFromWindow();
DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this); DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
playFrom = 0;
firstFrameRendered = false;
} }
@Override @Override
@ -6344,6 +6430,41 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
updateButtonState(false); updateButtonState(false);
} }
private void startVideoPlayer() {
if (currentDocument == null || videoPlayer != null) {
return;
}
// if (!firstFrameRendered) {
// textureView.setAlpha(0f);
// }
videoPlayer = new VideoPlayerHolderBase() {
@Override
public boolean needRepeat() {
return true;
}
@Override
public void onRenderedFirstFrame() {
super.onRenderedFirstFrame();
if (!firstFrameRendered) {
firstFrameRendered = true;
textureView.setAlpha(1f);
}
}
}.with(textureView);
TLRPC.Document document = currentDocument;
Uri uri = FileStreamLoadOperation.prepareUri(currentAccount, document, parentAdapter.currentPage);
if (uri == null) {
return;
}
videoPlayer.seekTo(playFrom);
videoPlayer.preparePlayer(uri, true);
videoPlayer.play();
}
@Override @Override
public void onFailedDownload(String fileName, boolean canceled) { public void onFailedDownload(String fileName, boolean canceled) {
updateButtonState(false); updateButtonState(false);
@ -9934,7 +10055,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, null)) { if (pinchToZoomHelper.checkPinchToZoom(event, this, imageView, null, null)) {
return true; return true;
} }
float x = event.getX(); float x = event.getX();
@ -11261,7 +11382,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} }
final PhotoViewer photoViewer = PhotoViewer.getInstance(); final PhotoViewer photoViewer = PhotoViewer.getInstance();
photoViewer.setParentActivity(parentFragment); photoViewer.setParentActivity(parentFragment);
return photoViewer.openPhoto(index, new RealPageBlocksAdapter(adapter.currentPage, pageBlocks), new PageBlocksPhotoViewerProvider(pageBlocks)); if (photoViewer.openPhoto(index, new RealPageBlocksAdapter(adapter.currentPage, pageBlocks), new PageBlocksPhotoViewerProvider(pageBlocks))) {
checkVideoPlayer();
return true;
}
return false;
} }
@ -11295,6 +11420,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
return !(index >= pageBlocks.size() || index < 0) && WebPageUtils.isVideo(page, get(index)); return !(index >= pageBlocks.size() || index < 0) && WebPageUtils.isVideo(page, get(index));
} }
@Override
public boolean isHardwarePlayer(int index) {
return !(index >= pageBlocks.size() || index < 0) && !WebPageUtils.isVideo(page, get(index)) && adapter[0].getTypeForBlock(get(index)) == 5;
}
@Override @Override
public TLObject getMedia(int index) { public TLObject getMedia(int index) {
if (index >= pageBlocks.size() || index < 0) { if (index >= pageBlocks.size() || index < 0) {
@ -11461,6 +11591,19 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
BlockVideoCell cell = (BlockVideoCell) view; BlockVideoCell cell = (BlockVideoCell) view;
if (cell.currentBlock == pageBlock) { if (cell.currentBlock == pageBlock) {
view.getLocationInWindow(coords); view.getLocationInWindow(coords);
if (cell == currentPlayer && videoPlayer != null && videoPlayer.firstFrameRendered) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Surface surface = new Surface(cell.textureView.getSurfaceTexture());
Bitmap bitmap = Bitmap.createBitmap(cell.textureView.getMeasuredWidth(), cell.textureView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
AndroidUtilities.getBitmapFromSurface(surface, bitmap);
surface.release();
cell.imageView.setImageBitmap(bitmap);
} else {
cell.imageView.setImageBitmap(cell.textureView.getBitmap());
}
cell.firstFrameRendered = false;
cell.textureView.setAlpha(0);
}
return cell.imageView; return cell.imageView;
} }
} else if (view instanceof BlockCollageCell) { } else if (view instanceof BlockCollageCell) {
@ -11492,5 +11635,47 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
} }
return null; return null;
} }
@Override
public void onClose() {
super.onClose();
checkVideoPlayer();
}
@Override
public void onReleasePlayerBeforeClose(int photoIndex) {
VideoPlayer player = PhotoViewer.getInstance().getVideoPlayer();
TextureView textureView = PhotoViewer.getInstance().getVideoTextureView();
BlockVideoCell videoCell = getViewFromListView(listView[0], pageBlocks.get(photoIndex));
if (videoCell != null && player != null && textureView != null) {
videoCell.playFrom = player.getCurrentPosition();
videoCell.firstFrameRendered = false;
videoCell.textureView.setAlpha(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Surface surface = new Surface(textureView.getSurfaceTexture());
Bitmap bitmap = Bitmap.createBitmap(textureView.getMeasuredWidth(), textureView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
AndroidUtilities.getBitmapFromSurface(surface, bitmap);
surface.release();
videoCell.imageView.setImageBitmap(bitmap);
} else {
videoCell.imageView.setImageBitmap(textureView.getBitmap());
}
}
checkVideoPlayer();
}
private BlockVideoCell getViewFromListView(ViewGroup listView, TLRPC.PageBlock pageBlock) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View view = listView.getChildAt(a);
if (view instanceof BlockVideoCell) {
BlockVideoCell cell = (BlockVideoCell) view;
if (cell.currentBlock == pageBlock) {
return cell;
}
}
}
return null;
}
} }
} }

View file

@ -194,7 +194,7 @@ public class CalendarActivity extends BaseFragment implements NotificationCenter
holder.storyImage = imageReceiver; holder.storyImage = imageReceiver;
if (storiesPlaceDrawAbove == null) { if (storiesPlaceDrawAbove == null) {
storiesPlaceDrawAbove = (canvas, bounds, alpha) -> { storiesPlaceDrawAbove = (canvas, bounds, alpha, opening) -> {
blackoutPaint.setAlpha((int) (80 * alpha)); blackoutPaint.setAlpha((int) (80 * alpha));
float r = AndroidUtilities.lerp(0, Math.min(bounds.width(), bounds.height()) / 2f, alpha); float r = AndroidUtilities.lerp(0, Math.min(bounds.width(), bounds.height()) / 2f, alpha);
canvas.drawRoundRect(bounds, r, r, blackoutPaint); canvas.drawRoundRect(bounds, r, r, blackoutPaint);

View file

@ -1391,7 +1391,7 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD
} else { } else {
giftPremiumSubtitleLayout.draw(canvas); giftPremiumSubtitleLayout.draw(canvas);
} }
} else { } else if (giftPremiumSubtitleLayout != null) {
giftPremiumSubtitleLayout.draw(canvas); giftPremiumSubtitleLayout.draw(canvas);
} }
canvas.restore(); canvas.restore();

View file

@ -3253,7 +3253,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
isRoundVideo || currentMessageObject.isAnimatedSticker() || (currentMessageObject.isDocument() && !currentMessageObject.isGif()) || currentMessageObject.needDrawBluredPreview()) { isRoundVideo || currentMessageObject.isAnimatedSticker() || (currentMessageObject.isDocument() && !currentMessageObject.isGif()) || currentMessageObject.needDrawBluredPreview()) {
return false; return false;
} }
return pinchToZoomHelper.checkPinchToZoom(ev, this, photoImage, currentMessageObject); return pinchToZoomHelper.checkPinchToZoom(ev, this, photoImage, null, currentMessageObject);
} }
private boolean checkTextSelection(MotionEvent event) { private boolean checkTextSelection(MotionEvent event) {
@ -6786,7 +6786,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
photoImage.setImage(null, null, thumb, null, messageObject, 0); photoImage.setImage(null, null, thumb, null, messageObject, 0);
} }
if (!reactionsLayoutInBubble.isSmall) { if (!reactionsLayoutInBubble.isSmall) {
reactionsLayoutInBubble.measure(maxWidth, currentMessageObject.isOutOwner() && (currentMessageObject.isAnimatedEmoji() || currentMessageObject.isAnyKindOfSticker()) ? Gravity.RIGHT : Gravity.LEFT); reactionsLayoutInBubble.measure(maxWidth + AndroidUtilities.dp(36), currentMessageObject.isOutOwner() && (currentMessageObject.isAnimatedEmoji() || currentMessageObject.isAnyKindOfSticker()) ? Gravity.RIGHT : Gravity.LEFT);
reactionsLayoutInBubble.drawServiceShaderBackground = 1f; reactionsLayoutInBubble.drawServiceShaderBackground = 1f;
reactionsLayoutInBubble.totalHeight = reactionsLayoutInBubble.height + AndroidUtilities.dp(8); reactionsLayoutInBubble.totalHeight = reactionsLayoutInBubble.height + AndroidUtilities.dp(8);
additionHeight += reactionsLayoutInBubble.totalHeight; additionHeight += reactionsLayoutInBubble.totalHeight;

View file

@ -325,6 +325,7 @@ public class ProfileSearchCell extends BaseCell implements NotificationCenter.No
drawPremium = !savedMessages && MessagesController.getInstance(currentAccount).isPremiumUser(user); drawPremium = !savedMessages && MessagesController.getInstance(currentAccount).isPremiumUser(user);
updateStatus(drawCheck, user, false); updateStatus(drawCheck, user, false);
} else if (contact != null) { } else if (contact != null) {
dialog_id = 0;
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
} else { } else {
@ -749,7 +750,12 @@ public class ProfileSearchCell extends BaseCell implements NotificationCenter.No
actionLayout.draw(canvas); actionLayout.draw(canvas);
canvas.restore(); canvas.restore();
} }
StoriesUtilities.drawAvatarWithStory(dialog_id, canvas, avatarImage, avatarStoryParams); if (user != null) {
StoriesUtilities.drawAvatarWithStory(user.id, canvas, avatarImage, avatarStoryParams);
} else {
avatarImage.setImageCoords(avatarStoryParams.originalAvatarRect);
avatarImage.draw(canvas);
}
} }
@Override @Override
@ -794,7 +800,7 @@ public class ProfileSearchCell extends BaseCell implements NotificationCenter.No
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (avatarStoryParams.checkOnTouchEvent(event, this)) { if (user != null && avatarStoryParams.checkOnTouchEvent(event, this)) {
return true; return true;
} }
if (actionButton != null && actionButton.checkTouchEvent(event)) { if (actionButton != null && actionButton.checkTouchEvent(event)) {

View file

@ -194,6 +194,7 @@ public class ReactedUserHolderView extends FrameLayout {
String contentDescription; String contentDescription;
boolean hasReactImage = false; boolean hasReactImage = false;
if (like) { if (like) {
reactView.setAnimatedEmojiDrawable(null);
hasReactImage = true; hasReactImage = true;
Drawable likeDrawableFilled = ContextCompat.getDrawable(getContext(), R.drawable.media_like_active).mutate(); Drawable likeDrawableFilled = ContextCompat.getDrawable(getContext(), R.drawable.media_like_active).mutate();
reactView.setColorFilter(new PorterDuffColorFilter(0xFFFF2E38, PorterDuff.Mode.MULTIPLY)); reactView.setColorFilter(new PorterDuffColorFilter(0xFFFF2E38, PorterDuff.Mode.MULTIPLY));
@ -202,6 +203,7 @@ public class ReactedUserHolderView extends FrameLayout {
} else if (reaction != null) { } else if (reaction != null) {
ReactionsLayoutInBubble.VisibleReaction visibleReaction = ReactionsLayoutInBubble.VisibleReaction.fromTLReaction(reaction); ReactionsLayoutInBubble.VisibleReaction visibleReaction = ReactionsLayoutInBubble.VisibleReaction.fromTLReaction(reaction);
if (visibleReaction.emojicon != null) { if (visibleReaction.emojicon != null) {
reactView.setAnimatedEmojiDrawable(null);
TLRPC.TL_availableReaction r = MediaDataController.getInstance(currentAccount).getReactionsMap().get(visibleReaction.emojicon); TLRPC.TL_availableReaction r = MediaDataController.getInstance(currentAccount).getReactionsMap().get(visibleReaction.emojicon);
if (r != null) { if (r != null) {
SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(r.static_icon.thumbs, Theme.key_windowBackgroundGray, 1.0f); SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(r.static_icon.thumbs, Theme.key_windowBackgroundGray, 1.0f);

View file

@ -280,7 +280,7 @@ public class StickerEmojiCell extends FrameLayout implements NotificationCenter.
} }
public boolean showingBitmap() { public boolean showingBitmap() {
return imageView.getBitmap() != null; return imageView.hasNotThumb();
} }
public ImageReceiver getImageView() { public ImageReceiver getImageView() {

View file

@ -8681,7 +8681,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
blurredView.animate().setListener(new HideViewAfterAnimation(blurredView)).alpha(0).start(); blurredView.animate().setListener(new HideViewAfterAnimation(blurredView)).alpha(0).start();
blurredView.setTag(null); blurredView.setTag(null);
chatListView.invalidate(); chatListView.invalidate();
fragmentView.invalidate(); if (fragmentView != null) {
fragmentView.invalidate();
}
} }
} }

View file

@ -1708,10 +1708,15 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
} }
} }
canvas.save(); boolean result;
canvas.clipRect(backgroundPaddingLeft, actionBar.getY() + actionBar.getMeasuredHeight() - currentPanTranslationY, getMeasuredWidth() - backgroundPaddingLeft, getMeasuredHeight()); if (child != contactsLayout && child != audioLayout) {
boolean result = super.drawChild(canvas, child, drawingTime); canvas.save();
canvas.restore(); canvas.clipRect(backgroundPaddingLeft, actionBar.getY() + actionBar.getMeasuredHeight() - currentPanTranslationY, getMeasuredWidth() - backgroundPaddingLeft, getMeasuredHeight());
result = super.drawChild(canvas, child, drawingTime);
canvas.restore();
} else {
result = super.drawChild(canvas, child, drawingTime);
}
if (drawBackground) { if (drawBackground) {
if (rad != 1.0f && actionBarType != 2) { if (rad != 1.0f && actionBarType != 2) {
@ -2113,11 +2118,15 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
buttonsRecyclerView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); buttonsRecyclerView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
containerView.addView(buttonsRecyclerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 84, Gravity.BOTTOM | Gravity.LEFT)); containerView.addView(buttonsRecyclerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 84, Gravity.BOTTOM | Gravity.LEFT));
buttonsRecyclerView.setOnItemClickListener((view, position) -> { buttonsRecyclerView.setOnItemClickListener((view, position) -> {
if (baseFragment != null && baseFragment.getParentActivity() == null) { BaseFragment lastFragment = baseFragment;
if (lastFragment == null) {
lastFragment = LaunchActivity.getLastFragment();
}
if (lastFragment == null || lastFragment.getParentActivity() == null) {
return; return;
} }
if (view instanceof AttachButton) { if (view instanceof AttachButton) {
final Activity activity = baseFragment.getParentActivity(); final Activity activity = lastFragment.getParentActivity();
int num = (Integer) view.getTag(); int num = (Integer) view.getTag();
if (num == 1) { if (num == 1) {
if (!photosEnabled && !videosEnabled) { if (!photosEnabled && !videosEnabled) {

View file

@ -54,7 +54,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Keep; import androidx.annotation.Keep;
import androidx.exifinterface.media.ExifInterface;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller; import androidx.recyclerview.widget.LinearSmoothScroller;
@ -105,7 +104,6 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View file

@ -565,7 +565,7 @@ public class EditTextBoldCursor extends EditTextEffects {
public void setHintText(CharSequence text, boolean animated) { public void setHintText(CharSequence text, boolean animated) {
if (hintAnimatedDrawable != null) { if (hintAnimatedDrawable != null) {
hintAnimatedDrawable.setText(text, true); hintAnimatedDrawable.setText(text, !LocaleController.isRTL);
} else { } else {
if (text == null) { if (text == null) {
text = ""; text = "";

View file

@ -3,6 +3,7 @@ package org.telegram.ui.Components;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.PointF; import android.graphics.PointF;
import android.media.MediaFormat;
import android.opengl.GLES11Ext; import android.opengl.GLES11Ext;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.GLUtils; import android.opengl.GLUtils;

View file

@ -666,7 +666,7 @@ public class LimitReachedBottomSheet extends BottomSheetWithRecyclerListView {
description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); description.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
description.setGravity(Gravity.CENTER_HORIZONTAL); description.setGravity(Gravity.CENTER_HORIZONTAL);
description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider)); description.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
addView(description, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 24, 0, 24, 24)); addView(description, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 24, 0, 24, 24));
updatePremiumButtonText(); updatePremiumButtonText();
} }

View file

@ -110,43 +110,45 @@ public class PremiumLockIconView extends ImageView {
invalidate(); invalidate();
} }
} }
if (type == TYPE_REACTIONS) { if (paint != null) {
if (currentColor != 0) { if (type == TYPE_REACTIONS) {
canvas.drawPath(path, paint); if (currentColor != 0) {
} else { canvas.drawPath(path, paint);
PremiumGradient.getInstance().updateMainGradientMatrix(0, 0, getMeasuredWidth(), getMeasuredHeight(), -AndroidUtilities.dp(24), 0); } else {
canvas.drawPath(path, PremiumGradient.getInstance().getMainGradientPaint()); PremiumGradient.getInstance().updateMainGradientMatrix(0, 0, getMeasuredWidth(), getMeasuredHeight(), -AndroidUtilities.dp(24), 0);
} canvas.drawPath(path, PremiumGradient.getInstance().getMainGradientPaint());
if (cellFlickerDrawable == null) {
cellFlickerDrawable = new CellFlickerDrawable();
}
cellFlickerDrawable.setParentWidth(getMeasuredWidth() / 2);
cellFlickerDrawable.drawFrame = false;
cellFlickerDrawable.draw(canvas, path, this);
canvas.save();
canvas.clipPath(path);
starParticles.onDraw(canvas);
canvas.restore();
invalidate();
} else {
float cx = getMeasuredWidth() / 2f;
float cy = getMeasuredHeight() / 2f;
if (oldShaderPaint == null) {
shaderCrossfadeProgress = 1f;
}
if (shaderCrossfadeProgress != 1f) {
paint.setAlpha((int) (255 * shaderCrossfadeProgress));
canvas.drawCircle(cx, cy, cx, oldShaderPaint);
canvas.drawCircle(cx, cy, cx, paint);
shaderCrossfadeProgress += 16 / 150f;
if (shaderCrossfadeProgress > 1f) {
shaderCrossfadeProgress = 1f;
oldShaderPaint = null;
} }
if (cellFlickerDrawable == null) {
cellFlickerDrawable = new CellFlickerDrawable();
}
cellFlickerDrawable.setParentWidth(getMeasuredWidth() / 2);
cellFlickerDrawable.drawFrame = false;
cellFlickerDrawable.draw(canvas, path, this);
canvas.save();
canvas.clipPath(path);
starParticles.onDraw(canvas);
canvas.restore();
invalidate(); invalidate();
paint.setAlpha(255);
} else { } else {
canvas.drawCircle(cx, cy, cx, paint); float cx = getMeasuredWidth() / 2f;
float cy = getMeasuredHeight() / 2f;
if (oldShaderPaint == null) {
shaderCrossfadeProgress = 1f;
}
if (shaderCrossfadeProgress != 1f) {
paint.setAlpha((int) (255 * shaderCrossfadeProgress));
canvas.drawCircle(cx, cy, cx, oldShaderPaint);
canvas.drawCircle(cx, cy, cx, paint);
shaderCrossfadeProgress += 16 / 150f;
if (shaderCrossfadeProgress > 1f) {
shaderCrossfadeProgress = 1f;
oldShaderPaint = null;
}
invalidate();
paint.setAlpha(255);
} else {
canvas.drawCircle(cx, cy, cx, paint);
}
} }
} }
super.onDraw(canvas); super.onDraw(canvas);

View file

@ -402,8 +402,8 @@ public class ProfileGalleryView extends CircularViewPager implements Notificatio
if (pinchToZoomHelper != null && getCurrentItemView() != null) { if (pinchToZoomHelper != null && getCurrentItemView() != null) {
if (action != MotionEvent.ACTION_DOWN && isDownReleased && !pinchToZoomHelper.isInOverlayMode()) { if (action != MotionEvent.ACTION_DOWN && isDownReleased && !pinchToZoomHelper.isInOverlayMode()) {
pinchToZoomHelper.checkPinchToZoom(MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0), this, getCurrentItemView().getImageReceiver(), null); pinchToZoomHelper.checkPinchToZoom(MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0), this, getCurrentItemView().getImageReceiver(), null,null);
} else if (pinchToZoomHelper.checkPinchToZoom(ev, this, getCurrentItemView().getImageReceiver(), null)) { } else if (pinchToZoomHelper.checkPinchToZoom(ev, this, getCurrentItemView().getImageReceiver(), null,null)) {
if (!isDownReleased) { if (!isDownReleased) {
isDownReleased = true; isDownReleased = true;
callback.onRelease(); callback.onRelease();

View file

@ -53,6 +53,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat; import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.GridLayoutManager;
@ -79,6 +80,7 @@ import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper; import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject; import org.telegram.messenger.UserObject;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.browser.Browser; import org.telegram.messenger.browser.Browser;
@ -1009,7 +1011,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
mediaPages[0].listView.getLocationInWindow(coords); mediaPages[0].listView.getLocationInWindow(coords);
object.animatingImageViewYOffset = -coords[1]; object.animatingImageViewYOffset = -coords[1];
object.imageReceiver = imageReceiver; object.imageReceiver = imageReceiver;
object.allowTakeAnimation = false; object.allowTakeAnimation = true;
object.radius = object.imageReceiver.getRoundRadius(); object.radius = object.imageReceiver.getRoundRadius();
object.thumb = object.imageReceiver.getBitmapSafe(); object.thumb = object.imageReceiver.getBitmapSafe();
object.parentView.getLocationInWindow(coords); object.parentView.getLocationInWindow(coords);
@ -1503,8 +1505,10 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
if (isStories) { if (isStories) {
StoriesAdapter adapter = tab == TAB_STORIES ? storiesAdapter : archivedStoriesAdapter; StoriesAdapter adapter = tab == TAB_STORIES ? storiesAdapter : archivedStoriesAdapter;
showPhotosItem.setChecked(adapter.storiesList.showPhotos()); if (adapter.storiesList != null) {
showVideosItem.setChecked(adapter.storiesList.showVideos()); showPhotosItem.setChecked(adapter.storiesList.showPhotos());
showVideosItem.setChecked(adapter.storiesList.showVideos());
}
showPhotosItem.setOnClickListener(v -> { showPhotosItem.setOnClickListener(v -> {
if (changeTypeAnimation) { if (changeTypeAnimation) {
return; return;
@ -1514,6 +1518,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
return; return;
} }
showPhotosItem.getCheckView().setChecked(!showPhotosItem.getCheckView().isChecked(), true); showPhotosItem.getCheckView().setChecked(!showPhotosItem.getCheckView().isChecked(), true);
if (adapter.storiesList == null) {
return;
}
adapter.storiesList.updateFilters(showPhotosItem.getCheckView().isChecked(), showVideosItem.getCheckView().isChecked()); adapter.storiesList.updateFilters(showPhotosItem.getCheckView().isChecked(), showVideosItem.getCheckView().isChecked());
}); });
showVideosItem.setOnClickListener(v -> { showVideosItem.setOnClickListener(v -> {
@ -1525,6 +1532,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
return; return;
} }
showVideosItem.getCheckView().setChecked(!showVideosItem.getCheckView().isChecked(), true); showVideosItem.getCheckView().setChecked(!showVideosItem.getCheckView().isChecked(), true);
if (adapter.storiesList == null) {
return;
}
adapter.storiesList.updateFilters(showPhotosItem.getCheckView().isChecked(), showVideosItem.getCheckView().isChecked()); adapter.storiesList.updateFilters(showPhotosItem.getCheckView().isChecked(), showVideosItem.getCheckView().isChecked());
}); });
} else { } else {
@ -2554,10 +2564,10 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} }
public void setStoriesFilter(boolean photos, boolean videos) { public void setStoriesFilter(boolean photos, boolean videos) {
if (storiesAdapter != null) { if (storiesAdapter != null && storiesAdapter.storiesList != null) {
storiesAdapter.storiesList.updateFilters(photos, videos); storiesAdapter.storiesList.updateFilters(photos, videos);
} }
if (archivedStoriesAdapter != null) { if (archivedStoriesAdapter != null && archivedStoriesAdapter.storiesList != null) {
archivedStoriesAdapter.storiesList.updateFilters(photos, videos); archivedStoriesAdapter.storiesList.updateFilters(photos, videos);
} }
} }
@ -5387,6 +5397,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} }
} else if (selectedMode == TAB_STORIES || selectedMode == TAB_ARCHIVED_STORIES) { } else if (selectedMode == TAB_STORIES || selectedMode == TAB_ARCHIVED_STORIES) {
StoriesController.StoriesList storiesList = (selectedMode == TAB_STORIES ? storiesAdapter : archivedStoriesAdapter).storiesList; StoriesController.StoriesList storiesList = (selectedMode == TAB_STORIES ? storiesAdapter : archivedStoriesAdapter).storiesList;
if (storiesList == null) {
return;
}
profileActivity.getOrCreateStoryViewer().open(getContext(), message.getId(), storiesList, StoriesListPlaceProvider.of(mediaPages[a].listView).with(forward -> { profileActivity.getOrCreateStoryViewer().open(getContext(), message.getId(), storiesList, StoriesListPlaceProvider.of(mediaPages[a].listView).with(forward -> {
if (forward) { if (forward) {
storiesList.load(false, 30); storiesList.load(false, 30);
@ -6759,10 +6772,16 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} }
public int getStoriesCount(int tab) { public int getStoriesCount(int tab) {
StoriesController.StoriesList list;
if (tab == TAB_STORIES) { if (tab == TAB_STORIES) {
return storiesAdapter.storiesList.getCount(); list = storiesAdapter.storiesList;
} else if (tab == TAB_ARCHIVED_STORIES) { } else if (tab == TAB_ARCHIVED_STORIES) {
return archivedStoriesAdapter.storiesList.getCount(); list = archivedStoriesAdapter.storiesList;
} else {
return 0;
}
if (list != null) {
return list.getCount();
} }
return 0; return 0;
} }
@ -6770,7 +6789,8 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
private class StoriesAdapter extends SharedPhotoVideoAdapter { private class StoriesAdapter extends SharedPhotoVideoAdapter {
private final boolean isArchive; private final boolean isArchive;
public StoriesController.StoriesList storiesList; @Nullable
public final StoriesController.StoriesList storiesList;
private StoriesAdapter supportingAdapter; private StoriesAdapter supportingAdapter;
private int id; private int id;
@ -6778,7 +6798,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
super(context); super(context);
this.isArchive = isArchive; this.isArchive = isArchive;
storiesList = profileActivity.getMessagesController().getStoriesController().getStoriesList(dialog_id, isArchive ? StoriesController.StoriesList.TYPE_ARCHIVE : StoriesController.StoriesList.TYPE_PINNED); storiesList = profileActivity.getMessagesController().getStoriesController().getStoriesList(dialog_id, isArchive ? StoriesController.StoriesList.TYPE_ARCHIVE : StoriesController.StoriesList.TYPE_PINNED);
id = storiesList.link(); if (storiesList != null) {
id = storiesList.link();
}
checkColumns(); checkColumns();
} }
@ -6801,6 +6823,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} }
private void checkColumns() { private void checkColumns() {
if (storiesList == null) {
return;
}
if (!isArchive && (!storiesColumnsCountSet || allowStoriesSingleColumn && storiesList.getCount() > 1) && storiesList.getCount() > 0 && !isStoriesView()) { if (!isArchive && (!storiesColumnsCountSet || allowStoriesSingleColumn && storiesList.getCount() > 1) && storiesList.getCount() > 0 && !isStoriesView()) {
if (storiesList.getCount() < 5) { if (storiesList.getCount() < 5) {
mediaColumnsCount[1] = storiesList.getCount(); mediaColumnsCount[1] = storiesList.getCount();
@ -6845,6 +6870,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
@Override @Override
public int getItemCount() { public int getItemCount() {
if (storiesList == null) {
return 0;
}
return storiesList.isOnlyCache() && hasInternet() ? 0 : storiesList.getCount(); return storiesList.isOnlyCache() && hasInternet() ? 0 : storiesList.getCount();
} }
@ -6877,6 +6905,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (storiesList == null) {
return;
}
int viewType = holder.getItemViewType(); int viewType = holder.getItemViewType();
if (viewType == 0) { if (viewType == 0) {
SharedPhotoVideoCell2 cell = (SharedPhotoVideoCell2) holder.itemView; SharedPhotoVideoCell2 cell = (SharedPhotoVideoCell2) holder.itemView;
@ -6884,6 +6915,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
position -= getTopOffset(); position -= getTopOffset();
if (position < 0 || position >= storiesList.messageObjects.size()) { if (position < 0 || position >= storiesList.messageObjects.size()) {
cell.setMessageObject(null, columnsCount()); cell.setMessageObject(null, columnsCount());
cell.isStory = true;
return; return;
} }
MessageObject messageObject = storiesList.messageObjects.get(position); MessageObject messageObject = storiesList.messageObjects.get(position);
@ -6897,6 +6929,10 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} }
public void load(boolean force) { public void load(boolean force) {
if (storiesList == null) {
return;
}
final int columnCount = columnsCount(); final int columnCount = columnsCount();
final int count = Math.min(100, Math.max(1, columnCount / 2) * columnCount * columnCount); final int count = Math.min(100, Math.max(1, columnCount / 2) * columnCount * columnCount);
storiesList.load(force, count); storiesList.load(force, count);
@ -6909,6 +6945,9 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
@Override @Override
public String getLetter(int position) { public String getLetter(int position) {
if (storiesList == null) {
return null;
}
position -= getTopOffset(); position -= getTopOffset();
if (position < 0 || position >= storiesList.messageObjects.size()) { if (position < 0 || position >= storiesList.messageObjects.size()) {
return null; return null;

View file

@ -634,19 +634,16 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
int y = scrollOffsetY - backgroundPaddingTop + AndroidUtilities.dp(6); int y = scrollOffsetY - backgroundPaddingTop + AndroidUtilities.dp(6);
int top = scrollOffsetY - backgroundPaddingTop - AndroidUtilities.dp(13); int top = scrollOffsetY - backgroundPaddingTop - AndroidUtilities.dp(13);
int height = getMeasuredHeight() + AndroidUtilities.dp(15) + backgroundPaddingTop;
int statusBarHeight = 0; int statusBarHeight = 0;
float radProgress = 1.0f; float radProgress = 1.0f;
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
top += AndroidUtilities.statusBarHeight; top += AndroidUtilities.statusBarHeight;
y += AndroidUtilities.statusBarHeight; y += AndroidUtilities.statusBarHeight;
height -= AndroidUtilities.statusBarHeight;
if (fullHeight) { if (fullHeight) {
if (top + backgroundPaddingTop < AndroidUtilities.statusBarHeight * 2) { if (top + backgroundPaddingTop < AndroidUtilities.statusBarHeight * 2) {
int diff = Math.min(AndroidUtilities.statusBarHeight, AndroidUtilities.statusBarHeight * 2 - top - backgroundPaddingTop); int diff = Math.min(AndroidUtilities.statusBarHeight, AndroidUtilities.statusBarHeight * 2 - top - backgroundPaddingTop);
top -= diff; top -= diff;
height += diff;
radProgress = 1.0f - Math.min(1.0f, (diff * 2) / (float) AndroidUtilities.statusBarHeight); radProgress = 1.0f - Math.min(1.0f, (diff * 2) / (float) AndroidUtilities.statusBarHeight);
} }
if (top + backgroundPaddingTop < AndroidUtilities.statusBarHeight) { if (top + backgroundPaddingTop < AndroidUtilities.statusBarHeight) {
@ -655,7 +652,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
} }
} }
shadowDrawable.setBounds(0, top, getMeasuredWidth(), height); shadowDrawable.setBounds(0, top, getMeasuredWidth(), getMeasuredHeight());
shadowDrawable.draw(canvas); shadowDrawable.draw(canvas);
if (radProgress != 1.0f) { if (radProgress != 1.0f) {
@ -925,6 +922,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileUploaded); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileUploaded);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileUploadFailed); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.fileUploadFailed);
} }
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stickersDidLoad);
updateFields(); updateFields();
updateSendButton(); updateSendButton();
@ -1142,9 +1140,10 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
premiumButtonView.setVisibility(View.INVISIBLE); premiumButtonView.setVisibility(View.INVISIBLE);
} }
final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount);
boolean notInstalled; boolean notInstalled;
if (stickerSet != null && stickerSet.set != null && stickerSet.set.emojis) { if (stickerSet != null && stickerSet.set != null && stickerSet.set.emojis) {
ArrayList<TLRPC.TL_messages_stickerSet> sets = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_EMOJIPACKS); ArrayList<TLRPC.TL_messages_stickerSet> sets = mediaDataController.getStickerSets(MediaDataController.TYPE_EMOJIPACKS);
boolean has = false; boolean has = false;
for (int i = 0; sets != null && i < sets.size(); ++i) { for (int i = 0; sets != null && i < sets.size(); ++i) {
if (sets.get(i) != null && sets.get(i).set != null && sets.get(i).set.id == stickerSet.set.id) { if (sets.get(i) != null && sets.get(i).set != null && sets.get(i).set.id == stickerSet.set.id) {
@ -1154,7 +1153,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
} }
notInstalled = !has; notInstalled = !has;
} else { } else {
notInstalled = stickerSet == null || stickerSet.set == null || !MediaDataController.getInstance(currentAccount).isStickerPackInstalled(stickerSet.set.id); notInstalled = stickerSet == null || stickerSet.set == null || !mediaDataController.isStickerPackInstalled(stickerSet.set.id);
} }
if (customButtonDelegate != null) { if (customButtonDelegate != null) {
@ -1163,7 +1162,22 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
dismiss(); dismiss();
} }
}, customButtonDelegate.getCustomButtonText(), customButtonDelegate.getCustomButtonTextColorKey(), customButtonDelegate.getCustomButtonColorKey(), customButtonDelegate.getCustomButtonRippleColorKey()); }, customButtonDelegate.getCustomButtonText(), customButtonDelegate.getCustomButtonTextColorKey(), customButtonDelegate.getCustomButtonColorKey(), customButtonDelegate.getCustomButtonRippleColorKey());
} else if (notInstalled) { return;
}
if (notInstalled) {
int type = MediaDataController.TYPE_IMAGE;
if (stickerSet != null && stickerSet.set != null && stickerSet.set.emojis) {
type = MediaDataController.TYPE_EMOJIPACKS;
} else if (stickerSet != null && stickerSet.set != null && stickerSet.set.masks) {
type = MediaDataController.TYPE_MASK;
}
if (!mediaDataController.areStickersLoaded(type)) {
mediaDataController.checkStickers(type);
setButton(null, "", -1, -1, -1);
return;
}
}
if (notInstalled) {
String text; String text;
if (stickerSet != null && stickerSet.set != null && stickerSet.set.masks) { if (stickerSet != null && stickerSet.set != null && stickerSet.set.masks) {
text = LocaleController.formatPluralString("AddManyMasksCount", stickerSet.documents == null ? 0 : stickerSet.documents.size()); text = LocaleController.formatPluralString("AddManyMasksCount", stickerSet.documents == null ? 0 : stickerSet.documents.size());
@ -1602,6 +1616,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploaded); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploaded);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploadFailed); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploadFailed);
} }
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.stickersDidLoad);
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 4); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 4);
} }
@ -1674,6 +1689,8 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
if (uploadImportStickers.isEmpty()) { if (uploadImportStickers.isEmpty()) {
updateFields(); updateFields();
} }
} else if (id == NotificationCenter.stickersDidLoad) {
updateFields();
} }
} }
@ -1692,16 +1709,24 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not
ViewGroup.MarginLayoutParams shadowParams = (ViewGroup.MarginLayoutParams) shadow[1].getLayoutParams(); ViewGroup.MarginLayoutParams shadowParams = (ViewGroup.MarginLayoutParams) shadow[1].getLayoutParams();
ViewGroup.MarginLayoutParams gridParams = (ViewGroup.MarginLayoutParams) gridView.getLayoutParams(); ViewGroup.MarginLayoutParams gridParams = (ViewGroup.MarginLayoutParams) gridView.getLayoutParams();
ViewGroup.MarginLayoutParams emptyParams = (ViewGroup.MarginLayoutParams) emptyView.getLayoutParams(); ViewGroup.MarginLayoutParams emptyParams = (ViewGroup.MarginLayoutParams) emptyView.getLayoutParams();
if (backgroundColorKey >= 0 && backgroundSelectorColorKey >= 0) { if (onClickListener == null) {
pickerBottomLayout.setAlpha(0f);
} else if (backgroundColorKey >= 0 && backgroundSelectorColorKey >= 0) {
pickerBottomLayout.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(6), getThemedColor(backgroundColorKey), getThemedColor(backgroundSelectorColorKey))); pickerBottomLayout.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(6), getThemedColor(backgroundColorKey), getThemedColor(backgroundSelectorColorKey)));
pickerBottomFrameLayout.setBackgroundColor(getThemedColor(Theme.key_dialogBackground)); pickerBottomFrameLayout.setBackgroundColor(getThemedColor(Theme.key_dialogBackground));
params.leftMargin = params.topMargin = params.rightMargin = params.bottomMargin = dp(8); params.leftMargin = params.topMargin = params.rightMargin = params.bottomMargin = dp(8);
emptyParams.bottomMargin = gridParams.bottomMargin = shadowParams.bottomMargin = dp(64); emptyParams.bottomMargin = gridParams.bottomMargin = shadowParams.bottomMargin = dp(64);
if (pickerBottomLayout.getAlpha() < 1f) {
pickerBottomLayout.animate().alpha(1f).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).setDuration(240).start();
}
} else { } else {
pickerBottomLayout.setBackground(Theme.createSelectorWithBackgroundDrawable(getThemedColor(Theme.key_dialogBackground), Theme.multAlpha(getThemedColor(Theme.key_text_RedBold), .1f))); pickerBottomLayout.setBackground(Theme.createSelectorWithBackgroundDrawable(getThemedColor(Theme.key_dialogBackground), Theme.multAlpha(getThemedColor(Theme.key_text_RedBold), .1f)));
pickerBottomFrameLayout.setBackgroundColor(Color.TRANSPARENT); pickerBottomFrameLayout.setBackgroundColor(Color.TRANSPARENT);
params.leftMargin = params.topMargin = params.rightMargin = params.bottomMargin = 0; params.leftMargin = params.topMargin = params.rightMargin = params.bottomMargin = 0;
emptyParams.bottomMargin = gridParams.bottomMargin = shadowParams.bottomMargin = dp(48); emptyParams.bottomMargin = gridParams.bottomMargin = shadowParams.bottomMargin = dp(48);
if (pickerBottomLayout.getAlpha() < 1f) {
pickerBottomLayout.animate().alpha(1f).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).setDuration(240).start();
}
} }
containerView.requestLayout(); containerView.requestLayout();
} }

View file

@ -235,10 +235,12 @@ public class ViewPagerFixed extends FrameLayout {
onTabPageSelected(page); onTabPageSelected(page);
int trasnlationX = viewPages[0] != null ? viewPages[0].getMeasuredWidth() : 0; int trasnlationX = viewPages[0] != null ? viewPages[0].getMeasuredWidth() : 0;
if (forward) { if (viewPages[1] != null) {
viewPages[1].setTranslationX(trasnlationX); if (forward) {
} else { viewPages[1].setTranslationX(trasnlationX);
viewPages[1].setTranslationX(-trasnlationX); } else {
viewPages[1].setTranslationX(-trasnlationX);
}
} }
} }

View file

@ -1916,7 +1916,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
protected void onMeasure(int widthSpec, int heightSpec) { protected void onMeasure(int widthSpec, int heightSpec) {
int t = 0; int t = 0;
int pos = parentPage.layoutManager.findFirstVisibleItemPosition(); int pos = parentPage.layoutManager.findFirstVisibleItemPosition();
if (pos != RecyclerView.NO_POSITION && parentPage.itemTouchhelper.isIdle() && !parentPage.layoutManager.hasPendingScrollPosition()) { if (pos != RecyclerView.NO_POSITION && parentPage.itemTouchhelper.isIdle() && !parentPage.layoutManager.hasPendingScrollPosition() && parentPage.listView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING) {
RecyclerView.ViewHolder holder = parentPage.listView.findViewHolderForAdapterPosition(pos); RecyclerView.ViewHolder holder = parentPage.listView.findViewHolderForAdapterPosition(pos);
if (holder != null) { if (holder != null) {
int top = holder.itemView.getTop(); int top = holder.itemView.getTop();
@ -6424,6 +6424,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
boolean hasNotStoragePermission = (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED; boolean hasNotStoragePermission = (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
boolean hasNotNotificationsPermission = Build.VERSION.SDK_INT >= 33 && activity.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED; boolean hasNotNotificationsPermission = Build.VERSION.SDK_INT >= 33 && activity.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED;
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (getParentActivity() == null) {
return;
}
afterSignup = false; afterSignup = false;
if (hasNotNotificationsPermission || hasNotContactsPermission || hasNotStoragePermission) { if (hasNotNotificationsPermission || hasNotContactsPermission || hasNotStoragePermission) {
askingForPermissions = true; askingForPermissions = true;

View file

@ -121,6 +121,8 @@ import org.telegram.ui.Components.AudioPlayerAlert;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.BlobDrawable; import org.telegram.ui.Components.BlobDrawable;
import org.telegram.ui.Components.Bulletin;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.CheckBoxSquare; import org.telegram.ui.Components.CheckBoxSquare;
import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EditTextBoldCursor; import org.telegram.ui.Components.EditTextBoldCursor;
@ -152,6 +154,7 @@ import org.telegram.ui.Components.voip.GroupCallStatusIcon;
import org.telegram.ui.Components.voip.PrivateVideoPreviewDialog; import org.telegram.ui.Components.voip.PrivateVideoPreviewDialog;
import org.telegram.ui.Components.voip.RTMPStreamPipOverlay; import org.telegram.ui.Components.voip.RTMPStreamPipOverlay;
import org.telegram.ui.Components.voip.VoIPToggleButton; import org.telegram.ui.Components.voip.VoIPToggleButton;
import org.webrtc.voiceengine.WebRtcAudioTrack;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -8704,4 +8707,26 @@ public class GroupCallActivity extends BottomSheet implements NotificationCenter
public boolean isRtmpStream() { public boolean isRtmpStream() {
return call != null && call.call.rtmp_stream; return call != null && call.call.rtmp_stream;
} }
@Override
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
if (parentActivity == null) {
return super.dispatchKeyEvent(event);
}
if (event.getAction() == KeyEvent.ACTION_DOWN && (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN)) {
if (VoIPService.getSharedInstance() != null) {
if (Build.VERSION.SDK_INT >= 32) {
boolean oldValue = WebRtcAudioTrack.isSpeakerMuted();
AudioManager am = (AudioManager) parentActivity.getSystemService(AUDIO_SERVICE);
int minVolume = am.getStreamMinVolume(AudioManager.STREAM_VOICE_CALL);
boolean mute = am.getStreamVolume(AudioManager.STREAM_VOICE_CALL) == minVolume && event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN;
WebRtcAudioTrack.setSpeakerMute(mute);
if (oldValue != WebRtcAudioTrack.isSpeakerMuted()) {
getUndoView().showWithAction(0, mute ? UndoView.ACTION_VOIP_SOUND_MUTED : UndoView.ACTION_VOIP_SOUND_UNMUTED, null);
}
}
}
}
return super.dispatchKeyEvent(event);
}
} }

View file

@ -7074,6 +7074,10 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
int keyCode = event.getKeyCode(); int keyCode = event.getKeyCode();
if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) { if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP || event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN) {
BaseFragment baseFragment = getLastFragment(); BaseFragment baseFragment = getLastFragment();
if (baseFragment != null && baseFragment.overlayStoryViewer != null && baseFragment.overlayStoryViewer.isShown()) {
baseFragment.overlayStoryViewer.dispatchKeyEvent(event);
return true;
}
if (baseFragment != null && baseFragment.storyViewer != null && baseFragment.storyViewer.isShown()) { if (baseFragment != null && baseFragment.storyViewer != null && baseFragment.storyViewer.isShown()) {
baseFragment.storyViewer.dispatchKeyEvent(event); baseFragment.storyViewer.dispatchKeyEvent(event);
return true; return true;
@ -7406,14 +7410,14 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
public void requestCustomNavigationBar() { public void requestCustomNavigationBar() {
if (customNavigationBar == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (customNavigationBar == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
customNavigationBar = drawerLayoutContainer.createNavigationBar(); customNavigationBar = drawerLayoutContainer.createNavigationBar();
if (customNavigationBar != null) { FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
FrameLayout decorView = (FrameLayout) getWindow().getDecorView(); decorView.addView(customNavigationBar);
decorView.addView(customNavigationBar); }
if (customNavigationBar.getLayoutParams().height != AndroidUtilities.navigationBarHeight || ((FrameLayout.LayoutParams)customNavigationBar.getLayoutParams()).topMargin != customNavigationBar.getHeight()) { if (customNavigationBar != null) {
customNavigationBar.getLayoutParams().height = AndroidUtilities.navigationBarHeight; if (customNavigationBar.getLayoutParams().height != AndroidUtilities.navigationBarHeight || ((FrameLayout.LayoutParams)customNavigationBar.getLayoutParams()).topMargin != customNavigationBar.getHeight()) {
((FrameLayout.LayoutParams)customNavigationBar.getLayoutParams()).topMargin = drawerLayoutContainer.getMeasuredHeight(); customNavigationBar.getLayoutParams().height = AndroidUtilities.navigationBarHeight;
customNavigationBar.requestLayout(); ((FrameLayout.LayoutParams)customNavigationBar.getLayoutParams()).topMargin = drawerLayoutContainer.getMeasuredHeight();
} customNavigationBar.requestLayout();
} }
} }
} }

View file

@ -1624,6 +1624,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
ContactsController.getInstance(currentAccount).checkAppAccount(); ContactsController.getInstance(currentAccount).checkAppAccount();
MessagesController.getInstance(currentAccount).checkPromoInfo(true); MessagesController.getInstance(currentAccount).checkPromoInfo(true);
ConnectionsManager.getInstance(currentAccount).updateDcSettings(); ConnectionsManager.getInstance(currentAccount).updateDcSettings();
MessagesController.getInstance(currentAccount).loadAppConfig();
if (res.future_auth_token != null) { if (res.future_auth_token != null) {
AuthTokensHelper.saveLogInToken(res); AuthTokensHelper.saveLogInToken(res);
@ -4063,7 +4064,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
} else if (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_SMS || nextType == AUTH_TYPE_MISSED_CALL) { } else if (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_SMS || nextType == AUTH_TYPE_MISSED_CALL) {
createTimer(); createTimer();
} }
} else if (currentType == AUTH_TYPE_SMS && (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_FLASH_CALL)) { } else if (currentType == AUTH_TYPE_SMS && (nextType == AUTH_TYPE_SMS || nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_FLASH_CALL)) {
timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, 2, 0)); timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, 2, 0));
setProblemTextVisible(time < 1000); setProblemTextVisible(time < 1000);
timeText.setVisibility(time < 1000 ? GONE : VISIBLE); timeText.setVisibility(time < 1000 ? GONE : VISIBLE);
@ -4139,6 +4140,9 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
return; return;
} }
codeTime = 15000; codeTime = 15000;
if (time > codeTime) {
codeTime = time;
}
codeTimer = new Timer(); codeTimer = new Timer();
lastCodeTime = System.currentTimeMillis(); lastCodeTime = System.currentTimeMillis();
codeTimer.schedule(new TimerTask() { codeTimer.schedule(new TimerTask() {
@ -4201,6 +4205,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
int seconds = time / 1000 - minutes * 60; int seconds = time / 1000 - minutes * 60;
if (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_FLASH_CALL || nextType == AUTH_TYPE_MISSED_CALL) { if (nextType == AUTH_TYPE_CALL || nextType == AUTH_TYPE_FLASH_CALL || nextType == AUTH_TYPE_MISSED_CALL) {
timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, minutes, seconds)); timeText.setText(LocaleController.formatString("CallAvailableIn", R.string.CallAvailableIn, minutes, seconds));
} else if (currentType == AUTH_TYPE_SMS && nextType == AUTH_TYPE_SMS) {
timeText.setText(LocaleController.formatString("ResendSmsAvailableIn", R.string.ResendSmsAvailableIn, minutes, seconds));
} else if (nextType == AUTH_TYPE_SMS) { } else if (nextType == AUTH_TYPE_SMS) {
timeText.setText(LocaleController.formatString("SmsAvailableIn", R.string.SmsAvailableIn, minutes, seconds)); timeText.setText(LocaleController.formatString("SmsAvailableIn", R.string.SmsAvailableIn, minutes, seconds));
} }
@ -4386,7 +4392,11 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
tryHideProgress(false); tryHideProgress(false);
nextPressed = false; nextPressed = false;
if (error == null) { if (error == null) {
animateSuccess(() -> new AlertDialog.Builder(getParentActivity()) Activity activity = getParentActivity();
if (activity == null) {
return;
}
animateSuccess(() -> new AlertDialog.Builder(activity)
.setTitle(LocaleController.getString(R.string.CancelLinkSuccessTitle)) .setTitle(LocaleController.getString(R.string.CancelLinkSuccessTitle))
.setMessage(LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone))) .setMessage(LocaleController.formatString("CancelLinkSuccess", R.string.CancelLinkSuccess, PhoneFormat.getInstance().format("+" + phone)))
.setPositiveButton(LocaleController.getString(R.string.Close), null) .setPositiveButton(LocaleController.getString(R.string.Close), null)

View file

@ -30,7 +30,6 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.Paint; import android.graphics.Paint;
@ -70,7 +69,6 @@ import android.transition.TransitionManager;
import android.transition.TransitionSet; import android.transition.TransitionSet;
import android.transition.TransitionValues; import android.transition.TransitionValues;
import android.util.FloatProperty; import android.util.FloatProperty;
import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.util.Property; import android.util.Property;
import android.util.Range; import android.util.Range;
@ -149,6 +147,7 @@ import org.telegram.messenger.DownloadController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FileStreamLoadOperation;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.ImageReceiver;
@ -156,7 +155,6 @@ import org.telegram.messenger.LiteMode;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController; import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageCustomParamsHelper;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.MessagesStorage;
@ -257,7 +255,6 @@ import org.telegram.ui.Components.VideoTimelinePlayView;
import org.telegram.ui.Components.ViewHelper; import org.telegram.ui.Components.ViewHelper;
import org.telegram.ui.Components.spoilers.SpoilersTextView; import org.telegram.ui.Components.spoilers.SpoilersTextView;
import org.telegram.ui.Stories.DarkThemeResourceProvider; import org.telegram.ui.Stories.DarkThemeResourceProvider;
import org.telegram.ui.Stories.StoryCaptionView;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
@ -283,6 +280,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private int classGuid; private int classGuid;
private PhotoViewerProvider placeProvider; private PhotoViewerProvider placeProvider;
private boolean isVisible; private boolean isVisible;
private boolean isVisibleOrAnimating;
private int maxSelectedPhotos = -1; private int maxSelectedPhotos = -1;
private boolean allowOrder = true; private boolean allowOrder = true;
@ -309,6 +307,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
public boolean closePhotoAfterSelect = true; public boolean closePhotoAfterSelect = true;
private TextSelectionHelper.SimpleTextSelectionHelper textSelectionHelper; private TextSelectionHelper.SimpleTextSelectionHelper textSelectionHelper;
public TextureView getVideoTextureView() {
return videoTextureView;
}
public boolean isVisibleOrAnimating() {
return isVisibleOrAnimating;
}
private static class PhotoViewerActionBarContainer extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { private static class PhotoViewerActionBarContainer extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
private FrameLayout container; private FrameLayout container;
@ -1744,6 +1750,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
TLRPC.PhotoSize getFileLocation(TLObject media, int[] size); TLRPC.PhotoSize getFileLocation(TLObject media, int[] size);
void updateSlideshowCell(TLRPC.PageBlock currentPageBlock); void updateSlideshowCell(TLRPC.PageBlock currentPageBlock);
Object getParentObject(); Object getParentObject();
boolean isHardwarePlayer(int index);
} }
private Rect hitRect = new Rect(); private Rect hitRect = new Rect();
@ -2533,6 +2540,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
default boolean canLoadMoreAvatars() { default boolean canLoadMoreAvatars() {
return true; return true;
} }
default void onReleasePlayerBeforeClose(int currentIndex) {};
} }
private class FrameLayoutDrawer extends SizeNotifierFrameLayoutPhoto { private class FrameLayoutDrawer extends SizeNotifierFrameLayoutPhoto {
@ -3737,7 +3745,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
boolean animated = a == 0 || a == 1 && sideImage == rightImage || a == 2 && sideImage == leftImage; boolean animated = a == 0 || a == 1 && sideImage == rightImage || a == 2 && sideImage == leftImage;
photoProgressViews[a].setProgress(1.0f, animated); photoProgressViews[a].setProgress(1.0f, animated);
checkProgress(a, false, animated); checkProgress(a, false, animated);
if (videoPlayer == null && a == 0 && (currentMessageObject != null && currentMessageObject.isVideo() || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || pageBlocksAdapter != null && pageBlocksAdapter.isVideo(currentIndex))) { if (videoPlayer == null && a == 0 && (currentMessageObject != null && currentMessageObject.isVideo() || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || pageBlocksAdapter != null && (pageBlocksAdapter.isVideo(currentIndex) || pageBlocksAdapter.isHardwarePlayer(currentIndex)))) {
onActionClick(false); onActionClick(false);
} }
if (a == 0 && videoPlayer != null) { if (a == 0 && videoPlayer != null) {
@ -5174,6 +5182,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
PipInstance = Instance; PipInstance = Instance;
Instance = null; Instance = null;
isVisible = false; isVisible = false;
isVisibleOrAnimating = false;
if (currentPlaceObject != null && !currentPlaceObject.imageReceiver.getVisible()) { if (currentPlaceObject != null && !currentPlaceObject.imageReceiver.getVisible()) {
currentPlaceObject.imageReceiver.setVisible(true, true); currentPlaceObject.imageReceiver.setVisible(true, true);
} }
@ -7732,6 +7741,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
Instance = null; Instance = null;
switchingInlineMode = true; switchingInlineMode = true;
isVisible = false; isVisible = false;
isVisibleOrAnimating = false;
AndroidUtilities.cancelRunOnUIThread(hideActionBarRunnable); AndroidUtilities.cancelRunOnUIThread(hideActionBarRunnable);
if (currentPlaceObject != null && !currentPlaceObject.imageReceiver.getVisible()) { if (currentPlaceObject != null && !currentPlaceObject.imageReceiver.getVisible()) {
currentPlaceObject.imageReceiver.setVisible(true, true); currentPlaceObject.imageReceiver.setVisible(true, true);
@ -8092,6 +8102,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
try { try {
isVisible = true; isVisible = true;
isVisibleOrAnimating = true;
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
wm.addView(windowView, windowLayoutParams); wm.addView(windowView, windowLayoutParams);
onShowView(); onShowView();
@ -9240,9 +9251,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
waitingForFirstTextureUpload = 0; waitingForFirstTextureUpload = 0;
} }
if (firstFrameView != null) { AndroidUtilities.runOnUIThread(() -> {
firstFrameView.checkFromPlayer(videoPlayer); if (firstFrameView != null) {
} firstFrameView.checkFromPlayer(videoPlayer);
}
});
} }
}); });
} }
@ -9303,7 +9316,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
videoPlayer.setPlayWhenReady(playWhenReady); videoPlayer.setPlayWhenReady(playWhenReady);
} }
playerLooping = currentMessageObject != null && currentMessageObject.getDuration() <= 30; playerLooping = (currentMessageObject != null && currentMessageObject.getDuration() <= 30) || (pageBlocksAdapter != null && pageBlocksAdapter.isHardwarePlayer(currentIndex));
videoPlayerControlFrameLayout.setSeekBarTransitionEnabled(playerLooping); videoPlayerControlFrameLayout.setSeekBarTransitionEnabled(playerLooping);
videoPlayer.setLooping(playerLooping); videoPlayer.setLooping(playerLooping);
@ -9323,8 +9336,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (pageBlocksAdapter != null) { if (pageBlocksAdapter != null) {
bottomLayout.setVisibility(View.VISIBLE); bottomLayout.setVisibility(View.VISIBLE);
} }
if (pageBlocksAdapter != null && pageBlocksAdapter.isHardwarePlayer(currentIndex) && !pageBlocksAdapter.isVideo(currentIndex)) {
setVideoPlayerControlVisible(!isCurrentVideo, true); setVideoPlayerControlVisible(false, true);
} else {
setVideoPlayerControlVisible(!isCurrentVideo, true);
}
if (!isCurrentVideo) { if (!isCurrentVideo) {
scheduleActionBarHide(playerAutoStarted ? 3000 : 1000); scheduleActionBarHide(playerAutoStarted ? 3000 : 1000);
} }
@ -12160,7 +12176,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
MessagesController.getInstance(currentAccount).loadDialogPhotos(avatarsDialogId, 80, 0, true, classGuid); MessagesController.getInstance(currentAccount).loadDialogPhotos(avatarsDialogId, 80, 0, true, classGuid);
} }
} }
if (currentMessageObject != null && currentMessageObject.isVideo() || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || (pageBlocksAdapter != null && pageBlocksAdapter.isVideo(index)) || (sendPhotoType == SELECT_TYPE_NO_SELECT && ((MediaController.PhotoEntry)imagesArrLocals.get(index)).isVideo)) { if (currentMessageObject != null && currentMessageObject.isVideo() || currentBotInlineResult != null && (currentBotInlineResult.type.equals("video") || MessageObject.isVideoDocument(currentBotInlineResult.document)) || (pageBlocksAdapter != null && (pageBlocksAdapter.isVideo(index) || pageBlocksAdapter.isHardwarePlayer(index))) || (sendPhotoType == SELECT_TYPE_NO_SELECT && ((MediaController.PhotoEntry)imagesArrLocals.get(index)).isVideo)) {
playerAutoStarted = true; playerAutoStarted = true;
onActionClick(false); onActionClick(false);
} else if (!imagesArrLocals.isEmpty()) { } else if (!imagesArrLocals.isEmpty()) {
@ -12782,7 +12798,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
countView.updateShow(size > 1, true); countView.updateShow(size > 1, true);
countView.set(switchingToIndex + 1, size); countView.set(switchingToIndex + 1, size);
} }
if (currentAnimation != null) { if (currentAnimation != null || (!pageBlocksAdapter.isVideo(index) && pageBlocksAdapter.isHardwarePlayer(index))) {
menuItem.hideSubItem(gallery_menu_save); menuItem.hideSubItem(gallery_menu_save);
if (allowShare) { if (allowShare) {
menuItem.showSubItem(gallery_menu_savegif); menuItem.showSubItem(gallery_menu_savegif);
@ -13108,7 +13124,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
final TLRPC.PageBlock pageBlock = pageBlocksAdapter.get(currentIndex); final TLRPC.PageBlock pageBlock = pageBlocksAdapter.get(currentIndex);
sameImage = currentPageBlock != null && currentPageBlock == pageBlock; sameImage = currentPageBlock != null && currentPageBlock == pageBlock;
currentPageBlock = pageBlock; currentPageBlock = pageBlock;
isVideo = pageBlocksAdapter.isVideo(currentIndex); isVideo = pageBlocksAdapter.isVideo(currentIndex) || pageBlocksAdapter.isHardwarePlayer(currentIndex);
} }
setMenuItemIcon(false, true); setMenuItemIcon(false, true);
@ -13595,7 +13611,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
f2 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), currentFileNames[a]); f2 = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), currentFileNames[a]);
} else if (pageBlocksAdapter != null) { } else if (pageBlocksAdapter != null) {
f1 = pageBlocksAdapter.getFile(index); f1 = pageBlocksAdapter.getFile(index);
isVideo = pageBlocksAdapter.isVideo(index); isVideo = pageBlocksAdapter.isVideo(index) || pageBlocksAdapter.isHardwarePlayer(index);
canAutoPlay = shouldIndexAutoPlayed(index); canAutoPlay = shouldIndexAutoPlayed(index);
} }
File f1Final = f1; File f1Final = f1;
@ -13911,7 +13927,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
ImageLocation imageLocation = needFullImage ? ImageLocation.getForPhoto(fileLocation, photo) : null; ImageLocation imageLocation = needFullImage ? ImageLocation.getForPhoto(fileLocation, photo) : null;
imageReceiver.setImage(imageLocation, null, imageThumbLocation, "b", thumbPlaceHolder, size[0], null, pageBlocksAdapter.getParentObject(), 1); imageReceiver.setImage(imageLocation, null, imageThumbLocation, "b", thumbPlaceHolder, size[0], null, pageBlocksAdapter.getParentObject(), 1);
imageReceiver.setMark(needFullImage ? null : MARK_DEFERRED_IMAGE_LOADING); imageReceiver.setMark(needFullImage ? null : MARK_DEFERRED_IMAGE_LOADING);
} else if (pageBlocksAdapter.isVideo(index)) { } else if (pageBlocksAdapter.isVideo(index) || pageBlocksAdapter.isHardwarePlayer(index)) {
if (!(fileLocation.location instanceof TLRPC.TL_fileLocationUnavailable)) { if (!(fileLocation.location instanceof TLRPC.TL_fileLocationUnavailable)) {
ImageReceiver.BitmapHolder placeHolder = null; ImageReceiver.BitmapHolder placeHolder = null;
if (currentThumb != null && imageReceiver == centerImage) { if (currentThumb != null && imageReceiver == centerImage) {
@ -14224,6 +14240,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
isVisible = true; isVisible = true;
isVisibleOrAnimating = true;
togglePhotosListView(false, false); togglePhotosListView(false, false);
@ -14530,6 +14547,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
isVisible = true; isVisible = true;
isVisibleOrAnimating = true;
togglePhotosListView(false, false); togglePhotosListView(false, false);
@ -15072,6 +15090,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
qualityPicker.cancelButton.callOnClick(); qualityPicker.cancelButton.callOnClick();
return; return;
} }
isVisibleOrAnimating = false;
openedFullScreenVideo = false; openedFullScreenVideo = false;
try { try {
if (visibleDialog != null) { if (visibleDialog != null) {
@ -15142,6 +15161,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
view.setScaleY(1f); view.setScaleY(1f);
} }
} }
if (placeProvider != null) {
placeProvider.onReleasePlayerBeforeClose(currentIndex);
}
final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, getFileLocation(currentFileLocation), currentIndex, true); final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, getFileLocation(currentFileLocation), currentIndex, true);
if (videoPlayer != null && object != null) { if (videoPlayer != null && object != null) {
AnimatedFileDrawable animation = object.imageReceiver.getAnimation(); AnimatedFileDrawable animation = object.imageReceiver.getAnimation();
@ -15530,6 +15552,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument());
} }
isVisible = false; isVisible = false;
isVisibleOrAnimating = false;
cropInitied = false; cropInitied = false;
disableShowCheck = true; disableShowCheck = true;
currentMessageObject = null; currentMessageObject = null;
@ -16212,7 +16235,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
private boolean shouldIndexAutoPlayed(int index) { private boolean shouldIndexAutoPlayed(int index) {
if (pageBlocksAdapter != null) { if (pageBlocksAdapter != null) {
if (pageBlocksAdapter.isVideo(index) && SharedConfig.isAutoplayVideo()) { if ((pageBlocksAdapter.isVideo(index) || pageBlocksAdapter.isHardwarePlayer(index)) && SharedConfig.isAutoplayVideo()) {
final File mediaFile = pageBlocksAdapter.getFile(index); final File mediaFile = pageBlocksAdapter.getFile(index);
if (mediaFile != null && mediaFile.exists()) { if (mediaFile != null && mediaFile.exists()) {
return true; return true;
@ -17137,7 +17160,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
} }
file = pageBlocksAdapter.getFile(currentIndex); file = pageBlocksAdapter.getFile(currentIndex);
if (file != null && !file.exists()) { if (file != null && !file.exists()) {
file = null; uri = FileStreamLoadOperation.prepareUri(currentAccount, (TLRPC.Document) media, pageBlocksAdapter.getParentObject());
isStreaming = true;
} }
} else if (sendPhotoType == SELECT_TYPE_NO_SELECT) { } else if (sendPhotoType == SELECT_TYPE_NO_SELECT) {
if (!imagesArrLocals.isEmpty() && currentIndex >= 0 && currentIndex < imagesArrLocals.size()) { if (!imagesArrLocals.isEmpty() && currentIndex >= 0 && currentIndex < imagesArrLocals.size()) {
@ -17190,6 +17214,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return; return;
} }
preparePlayer(uri, true, false); preparePlayer(uri, true, false);
videoSizeSet = true;
} }
} }

View file

@ -53,6 +53,7 @@ public class PinchToZoomHelper {
private ZoomOverlayView overlayView; private ZoomOverlayView overlayView;
private View child; private View child;
private ImageReceiver childImage; private ImageReceiver childImage;
private TextureView childTextureView;
private ImageReceiver fullImage = new ImageReceiver(); private ImageReceiver fullImage = new ImageReceiver();
private ImageReceiver blurImage = new ImageReceiver(); private ImageReceiver blurImage = new ImageReceiver();
@ -116,7 +117,7 @@ public class PinchToZoomHelper {
this.isSimple = true; this.isSimple = true;
} }
public void startZoom(View child, ImageReceiver image, MessageObject messageObject) { public void startZoom(View child, ImageReceiver image, TextureView textureView, MessageObject messageObject) {
this.child = child; this.child = child;
this.messageObject = messageObject; this.messageObject = messageObject;
@ -202,6 +203,7 @@ public class PinchToZoomHelper {
} else { } else {
isHardwareVideo = false; isHardwareVideo = false;
this.childImage = new ImageReceiver(); this.childImage = new ImageReceiver();
this.childTextureView = textureView;
this.childImage.onAttachedToWindow(); this.childImage.onAttachedToWindow();
Drawable drawable = image.getDrawable(); Drawable drawable = image.getDrawable();
this.childImage.setImageBitmap(drawable); this.childImage.setImageBitmap(drawable);
@ -584,6 +586,12 @@ public class PinchToZoomHelper {
fullImage.draw(canvas); fullImage.draw(canvas);
} }
} }
if (childTextureView != null) {
canvas.save();
canvas.translate(childImage.getImageX(), childImage.getImageY());
childTextureView.draw(canvas);
canvas.restore();
}
} else { } else {
videoPlayerContainer.setPivotX(pinchCenterX - imageX); videoPlayerContainer.setPivotX(pinchCenterX - imageX);
videoPlayerContainer.setPivotY(pinchCenterY - imageY); videoPlayerContainer.setPivotY(pinchCenterY - imageY);
@ -708,7 +716,7 @@ public class PinchToZoomHelper {
void getClipTopBottom(float[] topBottom); void getClipTopBottom(float[] topBottom);
} }
public boolean checkPinchToZoom(MotionEvent ev, View child, ImageReceiver image, MessageObject messageObject) { public boolean checkPinchToZoom(MotionEvent ev, View child, ImageReceiver image, TextureView textureView, MessageObject messageObject) {
if (!zoomEnabled(child, image)) { if (!zoomEnabled(child, image)) {
return false; return false;
} }
@ -749,7 +757,7 @@ public class PinchToZoomHelper {
pinchTranslationX = 0f; pinchTranslationX = 0f;
pinchTranslationY = 0f; pinchTranslationY = 0f;
child.getParent().requestDisallowInterceptTouchEvent(true); child.getParent().requestDisallowInterceptTouchEvent(true);
startZoom(child, image, messageObject); startZoom(child, image, textureView, messageObject);
} }

View file

@ -7774,7 +7774,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
onlineTextView[2].setVisibility(View.VISIBLE); onlineTextView[2].setVisibility(View.VISIBLE);
onlineTextView[3].setVisibility(View.VISIBLE); if (!searchMode) {
onlineTextView[3].setVisibility(View.VISIBLE);
}
if (previousTransitionFragment != null) { if (previousTransitionFragment != null) {
previousTransitionFragment.checkAndUpdateAvatar(); previousTransitionFragment.checkAndUpdateAvatar();
@ -8420,6 +8422,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
avatarContainer.setVisibility(View.VISIBLE); avatarContainer.setVisibility(View.VISIBLE);
nameTextView[1].setVisibility(View.VISIBLE); nameTextView[1].setVisibility(View.VISIBLE);
onlineTextView[1].setVisibility(View.VISIBLE); onlineTextView[1].setVisibility(View.VISIBLE);
onlineTextView[3].setVisibility(View.VISIBLE);
actionBar.onSearchFieldVisibilityChanged(searchTransitionProgress > 0.5f); actionBar.onSearchFieldVisibilityChanged(searchTransitionProgress > 0.5f);
int itemVisibility = searchTransitionProgress > 0.5f ? View.VISIBLE : View.GONE; int itemVisibility = searchTransitionProgress > 0.5f ? View.VISIBLE : View.GONE;
@ -8469,6 +8472,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
nameTextView[1].setAlpha(progressHalf); nameTextView[1].setAlpha(progressHalf);
onlineTextView[1].setAlpha(progressHalf); onlineTextView[1].setAlpha(progressHalf);
onlineTextView[3].setAlpha(progressHalf);
searchItem.getSearchField().setAlpha(progressHalfEnd); searchItem.getSearchField().setAlpha(progressHalfEnd);
if (enter && searchTransitionProgress < 0.7f) { if (enter && searchTransitionProgress < 0.7f) {
@ -8548,6 +8552,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
nameTextView[1].setVisibility(hide); nameTextView[1].setVisibility(hide);
onlineTextView[1].setVisibility(hide); onlineTextView[1].setVisibility(hide);
onlineTextView[3].setVisibility(hide);
if (otherItem != null) { if (otherItem != null) {
otherItem.setAlpha(1f); otherItem.setAlpha(1f);

View file

@ -52,6 +52,7 @@ import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.SimpleTextView; import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.AnimatedTextView; import org.telegram.ui.Components.AnimatedTextView;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.ButtonBounce; import org.telegram.ui.Components.ButtonBounce;
@ -333,7 +334,7 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
} }
return; return;
} }
if (!storiesController.hasStories(cell.dialogId)) { if (!storiesController.hasStories(cell.dialogId) && (!cell.isSelf || !storiesController.hasUploadingStories())) {
return; return;
} }
TLRPC.TL_userStories userStories = storiesController.getStories(cell.dialogId); TLRPC.TL_userStories userStories = storiesController.getStories(cell.dialogId);
@ -1075,6 +1076,7 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
SimpleTextView textView; SimpleTextView textView;
long dialogId; long dialogId;
boolean isSelf; boolean isSelf;
boolean isFail;
boolean crossfadeToDialog; boolean crossfadeToDialog;
long crossfadeToDialogId; long crossfadeToDialogId;
@ -1093,6 +1095,8 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
private float overscrollProgress; private float overscrollProgress;
private boolean selectedForOverscroll; private boolean selectedForOverscroll;
private final AnimatedFloat failT = new AnimatedFloat(this, 0, 350, CubicBezierInterpolator.EASE_OUT_QUINT);
public StoryCell(Context context) { public StoryCell(Context context) {
super(context); super(context);
params.isArchive = type == TYPE_ARCHIVE; params.isArchive = type == TYPE_ARCHIVE;
@ -1138,6 +1142,7 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
this.dialogId = dialogId; this.dialogId = dialogId;
isSelf = dialogId == UserConfig.getInstance(currentAccount).getClientUserId(); isSelf = dialogId == UserConfig.getInstance(currentAccount).getClientUserId();
isFail = isSelf && storiesController.isLastUploadingFailed();
TLObject object; TLObject object;
if (dialogId > 0) { if (dialogId > 0) {
object = user = MessagesController.getInstance(currentAccount).getUser(dialogId); object = user = MessagesController.getInstance(currentAccount).getUser(dialogId);
@ -1159,7 +1164,10 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
} }
if (dialogId == UserConfig.getInstance(currentAccount).getClientUserId()) { if (dialogId == UserConfig.getInstance(currentAccount).getClientUserId()) {
textView.setRightDrawable(null); textView.setRightDrawable(null);
if (!storiesController.getUploadingStories().isEmpty()) { if (storiesController.isLastUploadingFailed()) {
textView.setText(LocaleController.getString("FailedStory", R.string.FailedStory));
isUploadingState = false;
} else if (!storiesController.getUploadingStories().isEmpty()) {
StoriesUtilities.applyUploadingStr(textView, true, false); StoriesUtilities.applyUploadingStr(textView, true, false);
isUploadingState = true; isUploadingState = true;
} else if (storiesController.getEditingStory() != null) { } else if (storiesController.getEditingStory() != null) {
@ -1340,6 +1348,7 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
drawCircleForce = true; drawCircleForce = true;
invalidate(); invalidate();
} else { } else {
float failT = this.failT.set(isFail);
if (drawAvatar) { if (drawAvatar) {
if (progressWasDrawn) { if (progressWasDrawn) {
animateBounce(); animateBounce();
@ -1360,14 +1369,23 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
valueAnimator.setDuration(100); valueAnimator.setDuration(100);
valueAnimator.start(); valueAnimator.start();
} }
failT *= params.progressToSegments;
params.animate = !progressWasDrawn; params.animate = !progressWasDrawn;
params.progressToArc = getArcProgress(cx, radius); params.progressToArc = getArcProgress(cx, radius);
params.isLast = isLast; params.isLast = isLast;
params.isFirst = isFirst; params.isFirst = isFirst;
params.crossfadeToDialog = 0; params.crossfadeToDialog = 0;
params.alpha = 1f - failT;
StoriesUtilities.drawAvatarWithStory(dialogId, canvas, avatarImage, storiesController.hasSelfStories(), params); StoriesUtilities.drawAvatarWithStory(dialogId, canvas, avatarImage, storiesController.hasSelfStories(), params);
// avatarImage.draw(canvas);
if (failT > 0) {
final Paint paint = StoriesUtilities.getErrorPaint(avatarImage);
paint.setStrokeWidth(AndroidUtilities.dp(2));
paint.setAlpha((int) (0xFF * failT));
canvas.drawCircle(x + finalSize / 2, y + finalSize / 2, (finalSize / 2 + AndroidUtilities.dp(4)) * params.getScale(), paint);
}
} }
progressWasDrawn = false; progressWasDrawn = false;
if (drawAvatar) { if (drawAvatar) {
@ -1375,6 +1393,7 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
float s = 1f - progressHalf; float s = 1f - progressHalf;
canvas.scale(s, s, cx + AndroidUtilities.dp(16), cy + AndroidUtilities.dp(16)); canvas.scale(s, s, cx + AndroidUtilities.dp(16), cy + AndroidUtilities.dp(16));
drawPlus(canvas, cx, cy, 1f); drawPlus(canvas, cx, cy, 1f);
drawFail(canvas, cx, cy, failT);
canvas.restore(); canvas.restore();
} }
} }
@ -1542,6 +1561,31 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
addNewStoryDrawable.draw(canvas); addNewStoryDrawable.draw(canvas);
} }
public void drawFail(Canvas canvas, float cx, float cy, float alpha) {
if (!isSelf || alpha <= 0) {
return;
}
float cx2 = cx + AndroidUtilities.dp(17);
float cy2 = cy + AndroidUtilities.dp(17);
addCirclePaint.setColor(Theme.multAlpha(Theme.getColor(Theme.key_text_RedBold), alpha));
if (type == TYPE_DIALOGS) {
backgroundPaint.setColor(Theme.multAlpha(Theme.getColor(Theme.key_actionBarDefault), alpha));
} else {
backgroundPaint.setColor(Theme.multAlpha(Theme.getColor(Theme.key_actionBarDefaultArchived), alpha));
}
float r = AndroidUtilities.dp(9) * CubicBezierInterpolator.EASE_OUT_BACK.getInterpolation(alpha);
canvas.drawCircle(cx2, cy2, r + AndroidUtilities.dp(2), backgroundPaint);
canvas.drawCircle(cx2, cy2, r, addCirclePaint);
addCirclePaint.setColor(Theme.multAlpha(getTextColor(), alpha));
AndroidUtilities.rectTmp.set(cx2 - AndroidUtilities.dp(1), cy2 - AndroidUtilities.dpf2(4.6f), cx2 + AndroidUtilities.dp(1), cy2 + AndroidUtilities.dpf2(1.6f));
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(3), AndroidUtilities.dp(3), addCirclePaint);
AndroidUtilities.rectTmp.set(cx2 - AndroidUtilities.dp(1), cy2 + AndroidUtilities.dpf2(2.6f), cx2 + AndroidUtilities.dp(1), cy2 + AndroidUtilities.dpf2(2.6f + 2));
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(3), AndroidUtilities.dp(3), addCirclePaint);
}
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();

View file

@ -42,6 +42,7 @@ import android.view.SurfaceView;
import android.view.TextureView; import android.view.TextureView;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -125,6 +126,7 @@ import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.LoadingDrawable; import org.telegram.ui.Components.LoadingDrawable;
import org.telegram.ui.Components.MediaActivity; import org.telegram.ui.Components.MediaActivity;
import org.telegram.ui.Components.MentionsContainerView; import org.telegram.ui.Components.MentionsContainerView;
import org.telegram.ui.Components.Premium.LimitReachedBottomSheet;
import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet; import org.telegram.ui.Components.Premium.PremiumFeatureBottomSheet;
import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView; import org.telegram.ui.Components.RLottieImageView;
@ -240,12 +242,15 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
Delegate delegate; Delegate delegate;
private boolean paused; private boolean paused;
StoriesController storiesController; StoriesController storiesController;
private boolean isUploading, isEditing; private boolean isUploading, isEditing, isFailed;
private FrameLayout selfView; private FrameLayout selfView;
ChatActivityEnterView chatActivityEnterView; ChatActivityEnterView chatActivityEnterView;
private ValueAnimator changeBoundAnimator; private ValueAnimator changeBoundAnimator;
ReactionsContainerLayout reactionsContainerLayout; ReactionsContainerLayout reactionsContainerLayout;
private StoryFailView failView;
private ViewPropertyAnimator failViewAnimator;
Paint inputBackgroundPaint; Paint inputBackgroundPaint;
int lastKeyboardHeight; int lastKeyboardHeight;
@ -431,12 +436,12 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
imageReceiver.setImageCoords(0, 0, getMeasuredWidth(), getMeasuredHeight() + 1); imageReceiver.setImageCoords(0, 0, getMeasuredWidth(), getMeasuredHeight() + 1);
imageReceiver.draw(canvas); imageReceiver.draw(canvas);
if (isActive) { if (isActive) {
if (storyViewer.USE_SURFACE_VIEW && playerSharedScope.player != null && playerSharedScope.player.paused && storyViewer.playerStubBitmap != null && playerSharedScope.player.stubAvailable) { if (storyViewer.USE_SURFACE_VIEW && playerSharedScope.player != null && playerSharedScope.player.paused && playerSharedScope.player.playerStubBitmap != null && playerSharedScope.player.stubAvailable) {
float sx = getMeasuredWidth() / (float) storyViewer.playerStubBitmap.getWidth(); float sx = getMeasuredWidth() / (float) playerSharedScope.player.playerStubBitmap.getWidth();
float sy = getMeasuredHeight() / (float) storyViewer.playerStubBitmap.getHeight(); float sy = getMeasuredHeight() / (float) playerSharedScope.player.playerStubBitmap.getHeight();
canvas.save(); canvas.save();
canvas.scale(sx, sy); canvas.scale(sx, sy);
canvas.drawBitmap(storyViewer.playerStubBitmap, 0, 0, storyViewer.playerStubPaint); canvas.drawBitmap(playerSharedScope.player.playerStubBitmap, 0, 0, playerSharedScope.player.playerStubPaint);
canvas.restore(); canvas.restore();
} else { } else {
if (!storyViewer.USE_SURFACE_VIEW || allowDrawSurface) { if (!storyViewer.USE_SURFACE_VIEW || allowDrawSurface) {
@ -467,11 +472,11 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
boolean storyDrawing; boolean storyDrawing;
if (currentStory.isVideo) { if (currentStory.isVideo) {
storyDrawing = playerSharedScope.renderView != null && playerSharedScope.firstFrameRendered && !(playerSharedScope.player.progress == 0 && playerSharedScope.isBuffering()); storyDrawing = playerSharedScope.renderView != null && playerSharedScope.player != null && playerSharedScope.firstFrameRendered && !(playerSharedScope.player.progress == 0 && playerSharedScope.isBuffering() && !playerSharedScope.player.paused);
} else { } else {
storyDrawing = imageReceiver.hasNotThumb(); storyDrawing = imageReceiver.hasNotThumb();
} }
loadingDrawableAlpha2.set(!storyDrawing && currentStory.uploadingStory == null ? 1f : 0f); loadingDrawableAlpha2.set(isActive && !storyDrawing && currentStory.uploadingStory == null ? 1f : 0f);
loadingDrawableAlpha.set(loadingDrawableAlpha2.get() == 1f ? 1f : 0); loadingDrawableAlpha.set(loadingDrawableAlpha2.get() == 1f ? 1f : 0);
if (loadingDrawableAlpha.get() > 0) { if (loadingDrawableAlpha.get() > 0) {
@ -617,7 +622,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
} }
invalidate(); invalidate();
} else if (!paused && isActive && !isUploading && !isEditing && imageReceiver.hasNotThumb()) { } else if (!paused && isActive && !isUploading && !isEditing && !isFailed && imageReceiver.hasNotThumb()) {
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
if (lastDrawTime != 0) { if (lastDrawTime != 0) {
if (!isCaptionPartVisible) { if (!isCaptionPartVisible) {
@ -638,7 +643,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
switchEventSent = true; switchEventSent = true;
post(() -> { post(() -> {
if (delegate != null) { if (delegate != null) {
if (isUploading || isEditing) { if (isUploading || isEditing || isFailed) {
if (currentStory.isVideo()) { if (currentStory.isVideo()) {
playerSharedScope.player.loopBack(); playerSharedScope.player.loopBack();
} else { } else {
@ -951,6 +956,17 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (isSelf) { if (isSelf) {
TLRPC.StoryItem storyItem = currentStory.storyItem; TLRPC.StoryItem storyItem = currentStory.storyItem;
if (currentStory.uploadingStory != null) { if (currentStory.uploadingStory != null) {
// if (currentStory.uploadingStory.failed) {
// ActionBarMenuSubItem item = ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_edit, LocaleController.getString("Edit", R.string.Edit), false, resourcesProvider);
// item.setOnClickListener(v -> {
// Activity activity = AndroidUtilities.findActivity(context);
// if (activity == null) {
// return;
// }
// StoryRecorder.getInstance(activity, currentAccount)
// .openEdit(StoryRecorder.SourceView.fromStoryViewer(storyViewer), currentStory.uploadingStory.entry, 0, true);
// });
// }
ActionBarMenuSubItem item = ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_cancel, LocaleController.getString("Cancel", R.string.Cancel), false, resourcesProvider); ActionBarMenuSubItem item = ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_cancel, LocaleController.getString("Cancel", R.string.Cancel), false, resourcesProvider);
item.setOnClickListener(v -> { item.setOnClickListener(v -> {
if (currentStory.uploadingStory != null) { if (currentStory.uploadingStory != null) {
@ -1079,7 +1095,9 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
}); });
} }
createStealthModeItem(popupLayout); if (!MessagesController.getInstance(currentAccount).premiumLocked) {
createStealthModeItem(popupLayout);
}
if (allowShareLink) { if (allowShareLink) {
ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_shareout, LocaleController.getString("BotShare", R.string.BotShare), false, resourcesProvider).setOnClickListener(v -> { ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_shareout, LocaleController.getString("BotShare", R.string.BotShare), false, resourcesProvider).setOnClickListener(v -> {
@ -1171,7 +1189,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
popupMenu.dismiss(); popupMenu.dismiss();
} }
}); });
} else { } else if (!MessagesController.getInstance(currentAccount).premiumLocked) {
Drawable lockIcon = ContextCompat.getDrawable(context, R.drawable.msg_gallery_locked2); Drawable lockIcon = ContextCompat.getDrawable(context, R.drawable.msg_gallery_locked2);
lockIcon.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(Color.WHITE, Color.BLACK, 0.5f), PorterDuff.Mode.MULTIPLY)); lockIcon.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(Color.WHITE, Color.BLACK, 0.5f), PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable( CombinedDrawable combinedDrawable = new CombinedDrawable(
@ -1200,7 +1218,9 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
} }
createStealthModeItem(popupLayout); if (!MessagesController.getInstance(currentAccount).premiumLocked) {
createStealthModeItem(popupLayout);
}
if (allowShareLink) { if (allowShareLink) {
ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_link, LocaleController.getString("CopyLink", R.string.CopyLink), false, resourcesProvider).setOnClickListener(v -> { ActionBarMenuItem.addItem(popupLayout, R.drawable.msg_link, LocaleController.getString("CopyLink", R.string.CopyLink), false, resourcesProvider).setOnClickListener(v -> {
AndroidUtilities.addToClipboard(currentStory.createLink()); AndroidUtilities.addToClipboard(currentStory.createLink());
@ -1628,6 +1648,22 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
return false;//linesCount > 20; return false;//linesCount > 20;
} }
private void createFailView() {
if (failView != null) {
return;
}
failView = new StoryFailView(getContext(), resourcesProvider);
failView.setOnClickListener(v -> {
if (currentStory != null && currentStory.uploadingStory != null) {
currentStory.uploadingStory.tryAgain();
updatePosition();
}
});
failView.setAlpha(0f);
failView.setVisibility(View.GONE);
addView(failView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 0, 0, 0, 0));
}
private void createEnterView() { private void createEnterView() {
Theme.ResourcesProvider emojiResourceProvider = new WrappedResourceProvider(resourcesProvider) { Theme.ResourcesProvider emojiResourceProvider = new WrappedResourceProvider(resourcesProvider) {
@Override @Override
@ -1960,7 +1996,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
params.put("query_id", "" + result.query_id); params.put("query_id", "" + result.query_id);
params.put("bot", "" + uid); params.put("bot", "" + uid);
params.put("bot_name", mentionContainer.getAdapter().getContextBotName()); params.put("bot_name", mentionContainer.getAdapter().getContextBotName());
SendMessagesHelper.prepareSendingBotContextResult(storyViewer.fragment, getAccountInstance(), result, params, dialogId, null, null, null, notify, scheduleDate); SendMessagesHelper.prepareSendingBotContextResult(storyViewer.fragment, getAccountInstance(), result, params, dialogId, null, null, currentStory.storyItem, notify, scheduleDate);
chatActivityEnterView.setFieldText(""); chatActivityEnterView.setFieldText("");
afterMessageSend(); afterMessageSend();
MediaDataController.getInstance(currentAccount).increaseInlineRaiting(uid); MediaDataController.getInstance(currentAccount).increaseInlineRaiting(uid);
@ -2372,14 +2408,15 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (chatActivityEnterView == null) { if (chatActivityEnterView == null) {
createEnterView(); createEnterView();
} }
if (failView != null) {
failView.setVisibility(View.GONE);
}
if (startFromPosition == -1) { if (startFromPosition == -1) {
updateSelectedPosition(); updateSelectedPosition();
} }
if (chatActivityEnterView != null) { if (chatActivityEnterView != null) {
chatActivityEnterView.setVisibility(View.VISIBLE); chatActivityEnterView.setVisibility(View.VISIBLE);
if (!TextUtils.isEmpty(chatActivityEnterView.getEditField().getText())) { chatActivityEnterView.getEditField().setText(storyViewer.getDraft(dialogId, currentStory.storyItem));
chatActivityEnterView.getEditField().setText("");
}
chatActivityEnterView.setDialogId(dialogId, currentAccount); chatActivityEnterView.setDialogId(dialogId, currentAccount);
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId); TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId);
if (userFull != null) { if (userFull != null) {
@ -2717,6 +2754,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesUpdated); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesUpdated);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesListUpdated); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesListUpdated);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stealthModeChanged); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.stealthModeChanged);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.storiesLimitUpdate);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded);
} }
@ -2744,6 +2782,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesUpdated); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesUpdated);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesListUpdated); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesListUpdated);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.stealthModeChanged); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.stealthModeChanged);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.storiesLimitUpdate);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded);
} }
@ -2782,6 +2821,44 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
storyCaptionView.captionTextview.invalidate(); storyCaptionView.captionTextview.invalidate();
} else if (id == NotificationCenter.stealthModeChanged) { } else if (id == NotificationCenter.stealthModeChanged) {
checkStealthMode(true); checkStealthMode(true);
} else if (id == NotificationCenter.storiesLimitUpdate) {
StoriesController.StoryLimit storyLimit = MessagesController.getInstance(currentAccount).getStoriesController().checkStoryLimit();
if (storyLimit == null || delegate == null) {
return;
}
final Activity activity = storyViewer != null && storyViewer.parentActivity != null ? storyViewer.parentActivity : AndroidUtilities.findActivity(getContext());
if (activity == null) {
return;
}
final LimitReachedBottomSheet sheet = new LimitReachedBottomSheet(new BaseFragment() {
@Override
public boolean isLightStatusBar() {
return false;
}
@Override
public Activity getParentActivity() {
return activity;
}
@Override
public Theme.ResourcesProvider getResourceProvider() {
return new WrappedResourceProvider(resourcesProvider) {
@Override
public void appendColors() {
sparseIntArray.append(Theme.key_dialogBackground, 0xFF1F1F1F);
sparseIntArray.append(Theme.key_windowBackgroundGray, 0xFF333333);
}
};
}
@Override
public boolean presentFragment(BaseFragment fragment) {
storyViewer.presentFragment(fragment);
return true;
}
}, activity, storyLimit.getLimitReachedType(), currentAccount);
delegate.showDialog(sheet);
} }
} }
@ -2830,6 +2907,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
final boolean wasUploading = isUploading; final boolean wasUploading = isUploading;
final boolean wasEditing = isEditing; final boolean wasEditing = isEditing;
final boolean wasFailed = isFailed;
currentStory.editingSourceItem = null; currentStory.editingSourceItem = null;
if (!uploadingStories.isEmpty() && position >= storyItems.size()) { if (!uploadingStories.isEmpty() && position >= storyItems.size()) {
@ -2840,6 +2918,8 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
return; return;
} }
StoriesController.UploadingStory uploadingStory = uploadingStories.get(position); StoriesController.UploadingStory uploadingStory = uploadingStories.get(position);
isFailed = uploadingStory.failed;
isUploading = !isFailed;
Drawable thumbDrawable = null; Drawable thumbDrawable = null;
imageReceiver.setCrossfadeWithOldImage(false); imageReceiver.setCrossfadeWithOldImage(false);
imageReceiver.setCrossfadeDuration(ImageReceiver.DEFAULT_CROSSFADE_DURATION); imageReceiver.setCrossfadeDuration(ImageReceiver.DEFAULT_CROSSFADE_DURATION);
@ -2848,7 +2928,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
Utilities.blurBitmap(blurredBitmap, 3, 1, blurredBitmap.getWidth(), blurredBitmap.getHeight(), blurredBitmap.getRowBytes()); Utilities.blurBitmap(blurredBitmap, 3, 1, blurredBitmap.getWidth(), blurredBitmap.getHeight(), blurredBitmap.getRowBytes());
thumbDrawable = new BitmapDrawable(blurredBitmap); thumbDrawable = new BitmapDrawable(blurredBitmap);
} }
if (uploadingStory.isVideo) { if (uploadingStory.isVideo || uploadingStory.hadFailed) {
imageReceiver.setImage(null, null, ImageLocation.getForPath(uploadingStory.firstFramePath), filter, null, null, thumbDrawable, 0, null, null, 0); imageReceiver.setImage(null, null, ImageLocation.getForPath(uploadingStory.firstFramePath), filter, null, null, thumbDrawable, 0, null, null, 0);
} else { } else {
imageReceiver.setImage(null, null, ImageLocation.getForPath(uploadingStory.path), filter, null, null, thumbDrawable, 0, null, null, 0); imageReceiver.setImage(null, null, ImageLocation.getForPath(uploadingStory.path), filter, null, null, thumbDrawable, 0, null, null, 0);
@ -2859,6 +2939,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} else { } else {
isUploading = false; isUploading = false;
isEditing = false; isEditing = false;
isFailed = false;
if (position < 0 || position > storyItems.size() - 1) { if (position < 0 || position > storyItems.size() - 1) {
storyViewer.close(true); storyViewer.close(true);
return; return;
@ -2968,7 +3049,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
final boolean sameId = final boolean sameId =
getStoryId(currentStory.storyItem, currentStory.uploadingStory) == getStoryId(oldStoryItem, oldUploadingStory) || getStoryId(currentStory.storyItem, currentStory.uploadingStory) == getStoryId(oldStoryItem, oldUploadingStory) ||
oldUploadingStory != null && currentStory.storyItem != null && TextUtils.equals(oldUploadingStory.path, currentStory.storyItem.attachPath); oldUploadingStory != null && currentStory.storyItem != null && TextUtils.equals(oldUploadingStory.path, currentStory.storyItem.attachPath);
final boolean animateSubtitle = sameId && (isEditing != wasEditing || isUploading != wasUploading); final boolean animateSubtitle = sameId && (isEditing != wasEditing || isUploading != wasUploading || isFailed != wasFailed);
boolean storyChanged = false; boolean storyChanged = false;
if (!( if (!(
@ -2977,7 +3058,10 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
)) { )) {
storyChanged = true; storyChanged = true;
if (chatActivityEnterView != null) { if (chatActivityEnterView != null) {
chatActivityEnterView.getEditField().setText(""); if (oldStoryItem != null) {
storyViewer.saveDraft(oldStoryItem.dialogId, oldStoryItem, chatActivityEnterView.getEditField().getText());
}
chatActivityEnterView.getEditField().setText(storyViewer.getDraft(dialogId, currentStory.storyItem));
} }
currentImageTime = 0; currentImageTime = 0;
switchEventSent = false; switchEventSent = false;
@ -2997,7 +3081,11 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if (storyChanged || oldUploadingStory != null && currentStory.uploadingStory == null) { if (storyChanged || oldUploadingStory != null && currentStory.uploadingStory == null) {
if (currentStory.uploadingStory != null) { if (currentStory.uploadingStory != null) {
headerView.setSubtitle(StoriesUtilities.getUploadingStr(headerView.subtitleView[0], false, isEditing), animateSubtitle); if (currentStory.uploadingStory.failed) {
headerView.setSubtitle(LocaleController.getString("FailedToUploadStory", R.string.FailedToUploadStory), animateSubtitle);
} else {
headerView.setSubtitle(StoriesUtilities.getUploadingStr(headerView.subtitleView[0], false, isEditing), animateSubtitle);
}
} else if (currentStory.storyItem != null) { } else if (currentStory.storyItem != null) {
if (currentStory.storyItem.date == -1) { if (currentStory.storyItem.date == -1) {
headerView.setSubtitle(LocaleController.getString("CachedStory", R.string.CachedStory)); headerView.setSubtitle(LocaleController.getString("CachedStory", R.string.CachedStory));
@ -3144,26 +3232,36 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
} }
// final boolean closeFriends = currentStory.forCloseFriends(); if (currentStory.uploadingStory != null && currentStory.uploadingStory.failed) {
// if (oldStoryItem != null && currentStory.storyItem != null && oldStoryItem.id == currentStory.storyItem.id) { createFailView();
// if (closeFriends) { failView.set(currentStory.uploadingStory.entry.error);
// closeFriendsBadge.setVisibility(View.VISIBLE); failView.setVisibility(View.VISIBLE);
// } if (failViewAnimator != null) {
// closeFriendsBadge.clearAnimation(); failViewAnimator.cancel();
// closeFriendsBadge.animate().scaleX(closeFriends ? 1 : 0).scaleY(closeFriends ? 1 : 0).withEndAction(() -> { failViewAnimator = null;
// if (!closeFriends) { }
// closeFriendsBadge.setVisibility(View.GONE); if (sameId) {
// } failViewAnimator = failView.animate().alpha(1f).setDuration(180).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
// }).setInterpolator(closeFriends ? new OvershootInterpolator(3) : CubicBezierInterpolator.DEFAULT).setDuration(closeFriends ? 240 : 120).start(); failViewAnimator.start();
// } else { } else {
// closeFriendsBadge.setScaleX(closeFriends ? 1 : 0); failView.setAlpha(1f);
// closeFriendsBadge.setScaleY(closeFriends ? 1 : 0); }
// closeFriendsBadge.setVisibility(currentStory.forCloseFriends() ? View.VISIBLE : View.GONE); } else if (failView != null) {
// } if (failViewAnimator != null) {
// closeFriendsBadge.setTranslationX(muteIconContainer.getVisibility() == View.VISIBLE ? -AndroidUtilities.dp(44) : 0); failViewAnimator.cancel();
//sharedResources.muteDrawable.setIcon(storyViewer.soundEnabled() ? R.drawable.media_mute : R.drawable.media_unmute, false); failViewAnimator = null;
sharedResources.setIconMuted(!storyViewer.soundEnabled(), false); }
if (sameId) {
failView.setVisibility(View.VISIBLE);
failViewAnimator = failView.animate().alpha(0f).setDuration(180).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).withEndAction(() -> failView.setVisibility(View.GONE));
failViewAnimator.start();
} else {
failView.setAlpha(0f);
failView.setVisibility(View.GONE);
}
}
sharedResources.setIconMuted(!storyViewer.soundEnabled(), false);
if (isActive && currentStory.storyItem != null) { if (isActive && currentStory.storyItem != null) {
FileLog.d("StoryViewer displayed story dialogId=" + dialogId + " storyId=" + currentStory.storyItem.id); FileLog.d("StoryViewer displayed story dialogId=" + dialogId + " storyId=" + currentStory.storyItem.id);
} }
@ -3244,6 +3342,9 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
StoriesController.UploadingStory uploadingStory = uploadingStories.get(position); StoriesController.UploadingStory uploadingStory = uploadingStories.get(position);
setStoryImage(uploadingStory, imageReceiver, filter); setStoryImage(uploadingStory, imageReceiver, filter);
} else { } else {
if (storyItems.isEmpty()) {
continue;
}
if (position < 0) { if (position < 0) {
position = 0; position = 0;
} }
@ -3654,6 +3755,9 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
updatePreloadImages(); updatePreloadImages();
muteIconView.setAnimation(sharedResources.muteDrawable); muteIconView.setAnimation(sharedResources.muteDrawable);
isActive = true; isActive = true;
if (currentStory.storyItem != null) {
FileLog.d("StoryViewer displayed story dialogId=" + dialogId + " storyId=" + currentStory.storyItem.id);
}
//storyViewer.allowScreenshots(allowScreenshots); //storyViewer.allowScreenshots(allowScreenshots);
} else { } else {
@ -3809,7 +3913,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
} }
public void checkPinchToZoom(MotionEvent ev) { public void checkPinchToZoom(MotionEvent ev) {
pinchToZoomHelper.checkPinchToZoom(ev, storyContainer, null, null); pinchToZoomHelper.checkPinchToZoom(ev, storyContainer, null, null,null);
} }
@ -4056,7 +4160,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
if ((storyItemHolder != null && storyItemHolder.uploadingStory != null) || progressToUploading != 0) { if ((storyItemHolder != null && storyItemHolder.uploadingStory != null) || progressToUploading != 0) {
float progress = 1f; float progress = 1f;
final boolean disappearing; final boolean disappearing;
if (storyItemHolder != null && storyItemHolder.uploadingStory != null) { if (storyItemHolder != null && storyItemHolder.uploadingStory != null && !storyItemHolder.uploadingStory.failed) {
progressToUploading = 1f; progressToUploading = 1f;
progress = storyItemHolder.uploadingStory.progress; progress = storyItemHolder.uploadingStory.progress;
disappearing = false; disappearing = false;
@ -4451,6 +4555,8 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
lastOpenedKeyboardHeight = keyboardHeight; lastOpenedKeyboardHeight = keyboardHeight;
checkReactionsLayout(); checkReactionsLayout();
ReactionsEffectOverlay.dismissAll(); ReactionsEffectOverlay.dismissAll();
} else {
storyViewer.saveDraft(dialogId, currentStory.storyItem, chatActivityEnterView.getEditText());
} }
if (keyboardVisible && mentionContainer != null) { if (keyboardVisible && mentionContainer != null) {
mentionContainer.setVisibility(View.VISIBLE); mentionContainer.setVisibility(View.VISIBLE);
@ -4882,6 +4988,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
instantCameraView.resetCameraFile(); instantCameraView.resetCameraFile();
instantCameraView.cancel(false); instantCameraView.cancel(false);
} }
storyViewer.clearDraft(dialogId, currentStory.storyItem);
messageSent = true; messageSent = true;
storyViewer.closeKeyboardOrEmoji(); storyViewer.closeKeyboardOrEmoji();
BulletinFactory bulletinFactory = BulletinFactory.of(storyContainer, resourcesProvider); BulletinFactory bulletinFactory = BulletinFactory.of(storyContainer, resourcesProvider);
@ -5152,7 +5259,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica
@Override @Override
public boolean needEnterText() { public boolean needEnterText() {
delegate.requestAdjust(true); delegate.requestAdjust(false);
return false; return false;
} }
}); });

View file

@ -840,7 +840,7 @@ public class ProfileStoriesView extends View implements NotificationCenter.Notif
if (a != null && b != null) { if (a != null && b != null) {
final RectF aRect = new RectF(a.cachedRect), bRect = new RectF(b.cachedRect); final RectF aRect = new RectF(a.cachedRect), bRect = new RectF(b.cachedRect);
final StoryCircle circle = a, nextCircle = b; final StoryCircle circle = a, nextCircle = b;
holder.drawClip = (canvas, bounds, alpha) -> { holder.drawClip = (canvas, bounds, alpha, opening) -> {
aRect.set(circle.cachedRect); aRect.set(circle.cachedRect);
bRect.set(nextCircle.cachedRect); bRect.set(nextCircle.cachedRect);
circle.cachedRect.set(bounds); circle.cachedRect.set(bounds);

View file

@ -642,7 +642,7 @@ public class SelfStoryViewsPage extends FrameLayout implements NotificationCente
updateViewsVisibility(); updateViewsVisibility();
} }
listAdapter.updateRows(); listAdapter.updateRows();
recyclerItemsEnterAnimator.showItemsAnimated(oldCount); recyclerItemsEnterAnimator.showItemsAnimated(oldCount - 1);
checkLoadMore(); checkLoadMore();
// }); // });
} }
@ -742,8 +742,15 @@ public class SelfStoryViewsPage extends FrameLayout implements NotificationCente
view = new ReactedUserHolderView(ReactedUserHolderView.STYLE_STORY, currentAccount, getContext(), resourcesProvider) { view = new ReactedUserHolderView(ReactedUserHolderView.STYLE_STORY, currentAccount, getContext(), resourcesProvider) {
@Override @Override
public void openStory(long dialogId, Runnable onDone) { public void openStory(long dialogId, Runnable onDone) {
LaunchActivity.getLastFragment().getOrCreateOverlayStoryViewer().doOnAnimationReady(onDone); BaseFragment lastFragment = LaunchActivity.getLastFragment();
LaunchActivity.getLastFragment().getOrCreateOverlayStoryViewer().open(getContext(), dialogId, StoriesListPlaceProvider.of(recyclerListView)); if (lastFragment == null) {
return;
}
if (lastFragment.getOrCreateOverlayStoryViewer().isShowing) {
return;
}
lastFragment.getOrCreateOverlayStoryViewer().doOnAnimationReady(onDone);
lastFragment.getOrCreateOverlayStoryViewer().open(getContext(), dialogId, StoriesListPlaceProvider.of(recyclerListView));
} }
}; };
break; break;
@ -830,14 +837,12 @@ public class SelfStoryViewsPage extends FrameLayout implements NotificationCente
emptyView.title.setVisibility(View.GONE); emptyView.title.setVisibility(View.GONE);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
spannableStringBuilder.append(AndroidUtilities.replaceTags(LocaleController.getString("ExpiredViewsStub", R.string.ExpiredViewsStub))); spannableStringBuilder.append(AndroidUtilities.replaceTags(LocaleController.getString("ExpiredViewsStub", R.string.ExpiredViewsStub)));
spannableStringBuilder.append("\n\n"); if (!MessagesController.getInstance(currentAccount).premiumLocked) {
spannableStringBuilder.append(AndroidUtilities.replaceSingleTag(LocaleController.getString("ExpiredViewsStubPremiumDescription", R.string.ExpiredViewsStubPremiumDescription), () -> { spannableStringBuilder.append("\n\n");
showPremiumAlert(); spannableStringBuilder.append(AndroidUtilities.replaceSingleTag(LocaleController.getString("ExpiredViewsStubPremiumDescription", R.string.ExpiredViewsStubPremiumDescription), SelfStoryViewsPage.this::showPremiumAlert));
})); emptyView.createButtonLayout(LocaleController.getString("LearnMore", R.string.LearnMore), SelfStoryViewsPage.this::showPremiumAlert);
}
emptyView.subtitle.setText(spannableStringBuilder); emptyView.subtitle.setText(spannableStringBuilder);
emptyView.createButtonLayout(LocaleController.getString("LearnMore", R.string.LearnMore), () -> {
showPremiumAlert();
});
} else { } else {
emptyView.title.setVisibility(View.VISIBLE); emptyView.title.setVisibility(View.VISIBLE);
emptyView.title.setText(LocaleController.getString("NoViews", R.string.NoViews)); emptyView.title.setText(LocaleController.getString("NoViews", R.string.NoViews));

View file

@ -312,7 +312,8 @@ public class SelfStoryViewsView extends FrameLayout {
final PeerStoriesView currentView = storyViewer.getCurrentPeerView(); final PeerStoriesView currentView = storyViewer.getCurrentPeerView();
if (oldProgressToOpen == 1f && progressToOpen != 1f) { if (oldProgressToOpen == 1f && progressToOpen != 1f) {
if (storyViewer.storiesList != null) { if (storyViewer.storiesList != null) {
MessageObject object = storyViewer.storiesList.messageObjects.get(selfStoriesPreviewView.getClosestPosition()); int p = Utilities.clamp(selfStoriesPreviewView.getClosestPosition(), storyViewer.storiesList.messageObjects.size() - 1, 0);
MessageObject object = storyViewer.storiesList.messageObjects.get(p);
long date = StoriesController.StoriesList.day(object); long date = StoriesController.StoriesList.day(object);
if (storyViewer.transitionViewHolder.storyImage != null) { if (storyViewer.transitionViewHolder.storyImage != null) {
storyViewer.transitionViewHolder.storyImage.setVisible(true, true); storyViewer.transitionViewHolder.storyImage.setVisible(true, true);

View file

@ -8,6 +8,7 @@ import android.util.SparseArray;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray; import androidx.collection.LongSparseArray;
import com.google.android.exoplayer2.util.Consumer; import com.google.android.exoplayer2.util.Consumer;
@ -199,9 +200,11 @@ public class StoriesController {
for (int k = 0; k < list.size(); k++) { for (int k = 0; k < list.size(); k++) {
TLRPC.TL_userStories userStories = list.get(k); TLRPC.TL_userStories userStories = list.get(k);
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(userStories.user_id); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(userStories.user_id);
boolean removed = false;
if (user != null && !isContactOrService(user)) { if (user != null && !isContactOrService(user)) {
list.remove(k); list.remove(k);
k--; k--;
removed = true;
} }
for (int i = 0; i < userStories.stories.size(); i++) { for (int i = 0; i < userStories.stories.size(); i++) {
if (userStories.stories.get(i) instanceof TLRPC.TL_storyItemDeleted) { if (userStories.stories.get(i) instanceof TLRPC.TL_storyItemDeleted) {
@ -209,7 +212,7 @@ public class StoriesController {
i--; i--;
} }
} }
if (userStories.stories.isEmpty()) { if (!removed && userStories.stories.isEmpty()) {
list.remove(k); list.remove(k);
k--; k--;
} }
@ -222,6 +225,9 @@ public class StoriesController {
} }
public boolean hasStories(long dialogId) { public boolean hasStories(long dialogId) {
if (getSelfUserId() == dialogId && hasUploadingStories()) {
return true;
}
TLRPC.TL_userStories stories = allStoriesMap.get(dialogId); TLRPC.TL_userStories stories = allStoriesMap.get(dialogId);
return stories != null && !stories.stories.isEmpty(); return stories != null && !stories.stories.isEmpty();
} }
@ -389,8 +395,16 @@ public class StoriesController {
hiddenListStories.clear(); hiddenListStories.clear();
} }
} }
FileLog.d("StoriesController processAllStoriesResponse " + storiesResponse.user_stories.size() + " " + fromCache + " " + hidden); if (BuildVars.LOGS_ENABLED) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < storiesResponse.user_stories.size(); i++) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(storiesResponse.user_stories.get(i).user_id);
}
FileLog.d("StoriesController cache=" + fromCache + " hidden=" + hidden + " processAllStoriesResponse {" + builder + "}");
}
MessagesController.getInstance(currentAccount).putUsers(storiesResponse.users, fromCache); MessagesController.getInstance(currentAccount).putUsers(storiesResponse.users, fromCache);
for (int i = 0; i < storiesResponse.user_stories.size(); i++) { for (int i = 0; i < storiesResponse.user_stories.size(); i++) {
@ -406,14 +420,12 @@ public class StoriesController {
allStoriesMap.put(userStories.user_id, userStories); allStoriesMap.put(userStories.user_id, userStories);
for (int k = 0; k < 2; k++) { for (int k = 0; k < 2; k++) {
ArrayList<TLRPC.TL_userStories> storiesList = k == 0 ? hiddenListStories : dialogListStories; ArrayList<TLRPC.TL_userStories> storiesList = k == 0 ? hiddenListStories : dialogListStories;
// if (isNext) { for (int j = 0; j < storiesList.size(); j++) {
for (int j = 0; j < storiesList.size(); j++) { if (storiesList.get(j).user_id == userStories.user_id) {
if (storiesList.get(j).user_id == userStories.user_id) { storiesList.remove(j);
storiesList.remove(j); break;
break;
}
} }
// } }
} }
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(userStories.user_id); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(userStories.user_id);
if (user == null) { if (user == null) {
@ -523,6 +535,13 @@ public class StoriesController {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesUpdated); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesUpdated);
} }
public void putUploadingDrafts(ArrayList<StoryEntry> entries) {
for (StoryEntry entry : entries) {
uploadingStories.add(new UploadingStory(entry));
}
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesUpdated);
}
public ArrayList<TLRPC.TL_userStories> getDialogListStories() { public ArrayList<TLRPC.TL_userStories> getDialogListStories() {
return dialogListStories; return dialogListStories;
} }
@ -535,6 +554,13 @@ public class StoriesController {
return uploadingStories; return uploadingStories;
} }
public boolean isLastUploadingFailed() {
if (uploadingStories.isEmpty()) {
return false;
}
return uploadingStories.get(uploadingStories.size() - 1).failed;
}
public ArrayList<UploadingStory> getUploadingAndEditingStories() { public ArrayList<UploadingStory> getUploadingAndEditingStories() {
return uploadingAndEditingStories; return uploadingAndEditingStories;
} }
@ -910,7 +936,9 @@ public class StoriesController {
TLRPC.TL_userStories userStories = getStories(dialogId); TLRPC.TL_userStories userStories = getStories(dialogId);
if (userStories == null) { if (userStories == null) {
TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId); TLRPC.UserFull userFull = MessagesController.getInstance(currentAccount).getUserFull(dialogId);
userStories = userFull.stories; if (userFull != null) {
userStories = userFull.stories;
}
} }
return markStoryAsRead(userStories, storyItem, false); return markStoryAsRead(userStories, storyItem, false);
} }
@ -1361,13 +1389,17 @@ public class StoriesController {
private boolean putMessages; private boolean putMessages;
private boolean isCloseFriends; private boolean isCloseFriends;
public boolean hadFailed;
public boolean failed;
public UploadingStory(StoryEntry entry) { public UploadingStory(StoryEntry entry) {
this.entry = entry;
random_id = Utilities.random.nextLong(); random_id = Utilities.random.nextLong();
edit = entry.isEdit; edit = entry.isEdit;
this.entry = entry;
if (entry.uploadThumbFile != null) { if (entry.uploadThumbFile != null) {
this.firstFramePath = entry.uploadThumbFile.getAbsolutePath(); this.firstFramePath = entry.uploadThumbFile.getAbsolutePath();
} }
failed = hadFailed = entry.isError;
} }
private void startForeground() { private void startForeground() {
@ -1425,6 +1457,21 @@ public class StoriesController {
startForeground(); startForeground();
} }
public void tryAgain() {
failed = false;
entryDestroyed = false;
progress = 0;
uploadProgress = 0;
convertingProgress = 0;
if (path != null) {
try {
new File(path).delete();
path = null;
} catch (Exception ignore) {}
}
start();
}
private void upload() { private void upload() {
if (entry.shareUserIds != null) { if (entry.shareUserIds != null) {
putMessages(); putMessages();
@ -1440,7 +1487,9 @@ public class StoriesController {
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.filePreparingFailed); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.filePreparingFailed);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.filePreparingStarted); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.filePreparingStarted);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileNewChunkAvailable); NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileNewChunkAvailable);
uploadingStories.remove(UploadingStory.this); if (!failed) {
uploadingStories.remove(UploadingStory.this);
}
uploadingAndEditingStories.remove(UploadingStory.this); uploadingAndEditingStories.remove(UploadingStory.this);
if (edit) { if (edit) {
editingStories.remove(entry.editStoryId); editingStories.remove(entry.editStoryId);
@ -1484,7 +1533,15 @@ public class StoriesController {
} }
} else if (id == NotificationCenter.filePreparingFailed) { } else if (id == NotificationCenter.filePreparingFailed) {
if (args[0] == messageObject) { if (args[0] == messageObject) {
// TODO if (!edit) {
entry.isError = true;
entry.error = new TLRPC.TL_error();
entry.error.code = 400;
entry.error.text = "FILE_PREPARE_FAILED";
entryDestroyed = true;
hadFailed = failed = true;
getDraftsController().edit(entry);
}
cleanup(); cleanup();
} }
} else if (id == NotificationCenter.fileUploaded) { } else if (id == NotificationCenter.fileUploaded) {
@ -1659,8 +1716,9 @@ public class StoriesController {
req = sendStory; req = sendStory;
} }
currentRequest = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { final RequestDelegate requestDelegate = (response, error) -> {
if (response != null) { if (response != null) {
failed = false;
TLRPC.Updates updates = (TLRPC.Updates) response; TLRPC.Updates updates = (TLRPC.Updates) response;
int storyId = 0; int storyId = 0;
TLRPC.StoryItem storyItem = null; TLRPC.StoryItem storyItem = null;
@ -1713,6 +1771,11 @@ public class StoriesController {
final TLRPC.StoryItem storyItemFinal = storyItem; final TLRPC.StoryItem storyItemFinal = storyItem;
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
entryDestroyed = true; entryDestroyed = true;
if (entry.isError) {
getDraftsController().delete(entry);
}
entry.isError = false;
entry.error = null;
getDraftsController().saveForEdit(entry, did, storyItemFinal); getDraftsController().saveForEdit(entry, did, storyItemFinal);
if (!edit) { if (!edit) {
invalidateStoryLimit(); invalidateStoryLimit();
@ -1720,10 +1783,31 @@ public class StoriesController {
}); });
MessagesController.getInstance(currentAccount).processUpdateArray(updates.updates, updates.users, updates.chats, false, updates.date); MessagesController.getInstance(currentAccount).processUpdateArray(updates.updates, updates.users, updates.chats, false, updates.date);
} }
} else if (error != null && !edit) {
AndroidUtilities.runOnUIThread(() -> {
entry.isError = true;
if (checkStoryError(error)) {
entry.error = null;
} else {
entry.error = error;
}
entryDestroyed = true;
hadFailed = failed = true;
getDraftsController().edit(entry);
});
} }
AndroidUtilities.runOnUIThread(this::cleanup); AndroidUtilities.runOnUIThread(this::cleanup);
}); };
if (BuildVars.DEBUG_PRIVATE_VERSION && !edit && entry.caption != null && entry.caption.toString().contains("#failtest") && !hadFailed) {
TLRPC.TL_error error = new TLRPC.TL_error();
error.code = 400;
error.text = "FORCED_TO_FAIL";
requestDelegate.run(null, error);
} else {
currentRequest = ConnectionsManager.getInstance(currentAccount).sendRequest(req, requestDelegate);
}
} }
private void putMessages() { private void putMessages() {
@ -1745,6 +1829,10 @@ public class StoriesController {
} }
public void cancel() { public void cancel() {
if (failed) {
getDraftsController().delete(entry);
uploadingStories.remove(UploadingStory.this);
}
canceled = true; canceled = true;
if (entry.wouldBeVideo()) { if (entry.wouldBeVideo()) {
MediaController.getInstance().cancelVideoConvert(messageObject); MediaController.getInstance().cancelVideoConvert(messageObject);
@ -1763,12 +1851,16 @@ public class StoriesController {
private final HashMap<Long, StoriesList>[] storiesLists = new HashMap[2]; private final HashMap<Long, StoriesList>[] storiesLists = new HashMap[2];
@NonNull @Nullable
public StoriesList getStoriesList(long userId, int type) { public StoriesList getStoriesList(long userId, int type) {
return getStoriesList(userId, type, true); return getStoriesList(userId, type, true);
} }
@Nullable
private StoriesList getStoriesList(long userId, int type, boolean createIfNotExist) { private StoriesList getStoriesList(long userId, int type, boolean createIfNotExist) {
if (type == StoriesList.TYPE_ARCHIVE && userId != getSelfUserId()) {
return null;
}
if (storiesLists[type] == null) { if (storiesLists[type] == null) {
storiesLists[type] = new HashMap<>(); storiesLists[type] = new HashMap<>();
} }
@ -2711,26 +2803,49 @@ public class StoriesController {
storyLimitFetched = true; storyLimitFetched = true;
if (res instanceof TLRPC.TL_boolTrue) { if (res instanceof TLRPC.TL_boolTrue) {
storyLimitCached = null; storyLimitCached = null;
} else if (err != null && err.text != null) { NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesLimitUpdate);
if (err.text.startsWith("STORY_SEND_FLOOD_WEEKLY_")) { } else {
long until = 0; checkStoryError(err);
try {
until = Long.parseLong(err.text.substring("STORY_SEND_FLOOD_WEEKLY_".length()));
} catch (Exception ignore) {}
storyLimitCached = new StoryLimit(StoryLimit.LIMIT_WEEK, until);
} else if (err.text.startsWith("STORY_SEND_FLOOD_MONTHLY_")) {
long until = 0;
try {
until = Long.parseLong(err.text.substring("STORY_SEND_FLOOD_MONTHLY_".length()));
} catch (Exception ignore) {}
storyLimitCached = new StoryLimit(StoryLimit.LIMIT_MONTH, until);
}
} }
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesLimitUpdate); }), ConnectionsManager.RequestFlagDoNotWaitFloodWait);
}));
return null; return null;
} }
public boolean checkStoryError(TLRPC.TL_error err) {
boolean limitUpdate = false;
if (err != null && err.text != null) {
if (err.text.startsWith("STORY_SEND_FLOOD_WEEKLY_")) {
long until = 0;
try {
until = Long.parseLong(err.text.substring("STORY_SEND_FLOOD_WEEKLY_".length()));
} catch (Exception ignore) {}
storyLimitCached = new StoryLimit(StoryLimit.LIMIT_WEEK, until);
limitUpdate = true;
} else if (err.text.startsWith("STORY_SEND_FLOOD_MONTHLY_")) {
long until = 0;
try {
until = Long.parseLong(err.text.substring("STORY_SEND_FLOOD_MONTHLY_".length()));
} catch (Exception ignore) {}
storyLimitCached = new StoryLimit(StoryLimit.LIMIT_MONTH, until);
limitUpdate = true;
} else if (err.text.equals("STORIES_TOO_MUCH")) {
storyLimitCached = new StoryLimit(StoryLimit.LIMIT_COUNT, 0);
limitUpdate = true;
} else if (err.text.equals("PREMIUM_ACCOUNT_REQUIRED")) {
MessagesController mc = MessagesController.getInstance(currentAccount);
if ("enabled".equals(mc.storiesPosting)) {
mc.getMainSettings().edit().putString("storiesPosting", mc.storiesPosting = "premium").apply();
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesEnabledUpdate);
}
limitUpdate = true;
}
}
if (limitUpdate) {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesLimitUpdate);
}
return limitUpdate;
}
public boolean hasStoryLimit() { public boolean hasStoryLimit() {
StoryLimit storyLimit = checkStoryLimit(); StoryLimit storyLimit = checkStoryLimit();
return storyLimit != null && storyLimit.active(currentAccount); return storyLimit != null && storyLimit.active(currentAccount);

View file

@ -1,7 +1,11 @@
package org.telegram.ui.Stories; package org.telegram.ui.Stories;
import static org.telegram.messenger.AndroidUtilities.dp;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Region;
import android.view.View; import android.view.View;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
@ -9,6 +13,7 @@ import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.SharedConfig; import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Cells.ChatActionCell; import org.telegram.ui.Cells.ChatActionCell;
@ -102,12 +107,23 @@ public class StoriesListPlaceProvider implements StoryViewer.PlaceProvider {
holder.clipParent = storiesCell; holder.clipParent = storiesCell;
holder.clipTop = holder.clipBottom = 0; holder.clipTop = holder.clipBottom = 0;
holder.alpha = 1; holder.alpha = 1;
if (cell.isFail) {
final Path path = new Path();
holder.drawClip = (canvas, bounds, alpha, opening) -> {
path.rewind();
final float t = opening ? 1f - (float) Math.pow(1f - alpha, 2) : (float) Math.pow(alpha, 2);
path.addCircle(bounds.right + dp(7) - dp(14) * t, bounds.bottom + dp(7) - dp(14) * t, dp(11), Path.Direction.CW);
canvas.clipPath(path, Region.Op.DIFFERENCE);
};
} else {
holder.drawClip = null;
}
// updateClip(holder); // updateClip(holder);
return true; return true;
} }
} else if (child instanceof DialogCell) { } else if (child instanceof DialogCell) {
DialogCell cell = (DialogCell) child; DialogCell cell = (DialogCell) child;
if (cell.getDialogId() == dialogId || (isHiddenArchive && cell.isDialogFolder())) { if ((cell.getDialogId() == dialogId && !isHiddenArchive) || (isHiddenArchive && cell.isDialogFolder())) {
holder.view = child; holder.view = child;
holder.params = cell.storyParams; holder.params = cell.storyParams;
holder.avatarImage = cell.avatarImage; holder.avatarImage = cell.avatarImage;
@ -162,7 +178,7 @@ public class StoriesListPlaceProvider implements StoryViewer.PlaceProvider {
} }
holder.view = child; holder.view = child;
holder.storyImage = cell.imageReceiver; holder.storyImage = cell.imageReceiver;
holder.drawAbove = (canvas, bounds, alpha) -> { holder.drawAbove = (canvas, bounds, alpha, opening) -> {
cell.drawDuration(canvas, bounds, alpha); cell.drawDuration(canvas, bounds, alpha);
if (fastScroll != null && fastScroll.isVisible && fastScroll.getVisibility() == View.VISIBLE) { if (fastScroll != null && fastScroll.isVisible && fastScroll.getVisibility() == View.VISIBLE) {
canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int) (0xFF * alpha), Canvas.ALL_SAVE_FLAG); canvas.saveLayerAlpha(0, 0, canvas.getWidth(), canvas.getHeight(), (int) (0xFF * alpha), Canvas.ALL_SAVE_FLAG);

View file

@ -281,11 +281,11 @@ public class StoriesStorage {
} }
if (!isNext) { if (!isNext) {
try { try {
SQLiteCursor cursor = database.queryFinalized("SELECT dialog_id FROM stories"); SQLiteCursor cursor = database.queryFinalized("SELECT DISTINCT dialog_id FROM stories");
ArrayList<Long> dialogsToDelete = new ArrayList<>(); ArrayList<Long> dialogsToDelete = new ArrayList<>();
while (cursor.next()) { while (cursor.next()) {
long dialogId = cursor.longValue(1); long dialogId = cursor.longValue(0);
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId); TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(dialogId);
if (user == null) { if (user == null) {
user = MessagesStorage.getInstance(currentAccount).getUser(dialogId); user = MessagesStorage.getInstance(currentAccount).getUser(dialogId);

View file

@ -59,6 +59,7 @@ public class StoriesUtilities {
public static final int STATE_PROGRESS = 3; public static final int STATE_PROGRESS = 3;
public static GradientTools[] storiesGradientTools = new GradientTools[2]; public static GradientTools[] storiesGradientTools = new GradientTools[2];
public static GradientTools closeFriendsGradientTools; public static GradientTools closeFriendsGradientTools;
public static GradientTools errorGradientTools;
public static Paint grayPaint; public static Paint grayPaint;
public static Paint closeFriendsLastColor; public static Paint closeFriendsLastColor;
@ -207,9 +208,9 @@ public class StoriesUtilities {
float inset = params.isStoryCell ? -AndroidUtilities.dp(4) : 0;//AndroidUtilities.lerp(AndroidUtilities.dp(2), 0, imageScale); float inset = params.isStoryCell ? -AndroidUtilities.dp(4) : 0;//AndroidUtilities.lerp(AndroidUtilities.dp(2), 0, imageScale);
if (animateOut) { if (animateOut) {
inset += AndroidUtilities.dp(5) * progressToSate; inset += AndroidUtilities.dp(5) * progressToSate;
gradientTools.paint.setAlpha((int) (255 * (1f - progressToSate))); gradientTools.paint.setAlpha((int) (0xFF * params.alpha * (1f - progressToSate)));
} else { } else {
gradientTools.paint.setAlpha((int) (255 * progressToSate)); gradientTools.paint.setAlpha((int) (0xFF * params.alpha * progressToSate));
inset += AndroidUtilities.dp(5) * (1f - progressToSate); inset += AndroidUtilities.dp(5) * (1f - progressToSate);
} }
rectTmp.set(params.originalAvatarRect); rectTmp.set(params.originalAvatarRect);
@ -231,9 +232,9 @@ public class StoriesUtilities {
Paint closeFriendsPaint = null; Paint closeFriendsPaint = null;
if (params.drawSegments) { if (params.drawSegments) {
unreadPaint = getActiveCirclePaint(avatarImage, params.isStoryCell); unreadPaint = getActiveCirclePaint(avatarImage, params.isStoryCell);
unreadPaint.setAlpha(255); unreadPaint.setAlpha((int) (0xFF * params.alpha));
closeFriendsPaint = getCloseFriendsPaint(avatarImage); closeFriendsPaint = getCloseFriendsPaint(avatarImage);
closeFriendsPaint.setAlpha(255); closeFriendsPaint.setAlpha((int) (0xFF * params.alpha));
checkGrayPaint(params.resourcesProvider); checkGrayPaint(params.resourcesProvider);
} }
float inset; float inset;
@ -244,9 +245,9 @@ public class StoriesUtilities {
} }
if (animateOut) { if (animateOut) {
inset += AndroidUtilities.dp(5) * progressToSate; inset += AndroidUtilities.dp(5) * progressToSate;
paint.setAlpha((int) (255 * (1f - progressToSate))); paint.setAlpha((int) (0xFF * params.alpha * (1f - progressToSate)));
} else { } else {
paint.setAlpha((int) (255 * progressToSate)); paint.setAlpha((int) (0xFF * params.alpha * progressToSate));
inset += AndroidUtilities.dp(5) * (1f - progressToSate); inset += AndroidUtilities.dp(5) * (1f - progressToSate);
} }
rectTmp.set(params.originalAvatarRect); rectTmp.set(params.originalAvatarRect);
@ -277,9 +278,9 @@ public class StoriesUtilities {
Paint closeFriendsPaint = null; Paint closeFriendsPaint = null;
if (params.drawSegments) { if (params.drawSegments) {
unreadPaint = getActiveCirclePaint(avatarImage, params.isStoryCell); unreadPaint = getActiveCirclePaint(avatarImage, params.isStoryCell);
unreadPaint.setAlpha(255); unreadPaint.setAlpha((int) (0xFF * params.alpha));
closeFriendsPaint = getCloseFriendsPaint(avatarImage); closeFriendsPaint = getCloseFriendsPaint(avatarImage);
closeFriendsPaint.setAlpha(255); closeFriendsPaint.setAlpha((int) (0xFF * params.alpha));
checkGrayPaint(params.resourcesProvider); checkGrayPaint(params.resourcesProvider);
} }
float inset; float inset;
@ -291,9 +292,9 @@ public class StoriesUtilities {
boolean animateOut = params.prevState == STATE_PROGRESS && params.progressToSate != 1f; boolean animateOut = params.prevState == STATE_PROGRESS && params.progressToSate != 1f;
if (animateOut) { if (animateOut) {
inset += AndroidUtilities.dp(7) * progressToSate; inset += AndroidUtilities.dp(7) * progressToSate;
paint.setAlpha((int) (255 * (1f - progressToSate))); paint.setAlpha((int) (0xFF * params.alpha * (1f - progressToSate)));
} else { } else {
paint.setAlpha((int) (255 * progressToSate)); paint.setAlpha((int) (0xFF * params.alpha * progressToSate));
inset += AndroidUtilities.dp(5) * (1f - progressToSate); inset += AndroidUtilities.dp(5) * (1f - progressToSate);
} }
rectTmp.set(params.originalAvatarRect); rectTmp.set(params.originalAvatarRect);
@ -587,6 +588,12 @@ public class StoriesUtilities {
if (storiesGradientTools[1] != null) { if (storiesGradientTools[1] != null) {
storiesGradientTools[1].setColors(Theme.getColor(Theme.key_stories_circle1), Theme.getColor(Theme.key_stories_circle2)); storiesGradientTools[1].setColors(Theme.getColor(Theme.key_stories_circle1), Theme.getColor(Theme.key_stories_circle2));
} }
if (errorGradientTools != null) {
int orange = Theme.getColor(Theme.key_color_orange);
final int red = Theme.getColor(Theme.key_text_RedBold);
orange = ColorUtils.blendARGB(orange, red, .25f);
errorGradientTools.setColors(orange, red);
}
} }
public static Paint getCloseFriendsPaint(ImageReceiver avatarImage) { public static Paint getCloseFriendsPaint(ImageReceiver avatarImage) {
@ -595,7 +602,7 @@ public class StoriesUtilities {
closeFriendsGradientTools.isDiagonal = true; closeFriendsGradientTools.isDiagonal = true;
closeFriendsGradientTools.isRotate = true; closeFriendsGradientTools.isRotate = true;
closeFriendsGradientTools.setColors(Theme.getColor(Theme.key_stories_circle_closeFriends1), Theme.getColor(Theme.key_stories_circle_closeFriends2)); closeFriendsGradientTools.setColors(Theme.getColor(Theme.key_stories_circle_closeFriends1), Theme.getColor(Theme.key_stories_circle_closeFriends2));
closeFriendsGradientTools.paint.setStrokeWidth(AndroidUtilities.dp(2.3f)); closeFriendsGradientTools.paint.setStrokeWidth(AndroidUtilities.dpf2(2.3f));
closeFriendsGradientTools.paint.setStyle(Paint.Style.STROKE); closeFriendsGradientTools.paint.setStyle(Paint.Style.STROKE);
closeFriendsGradientTools.paint.setStrokeCap(Paint.Cap.ROUND); closeFriendsGradientTools.paint.setStrokeCap(Paint.Cap.ROUND);
} }
@ -603,6 +610,23 @@ public class StoriesUtilities {
return closeFriendsGradientTools.paint; return closeFriendsGradientTools.paint;
} }
public static Paint getErrorPaint(ImageReceiver avatarImage) {
if (errorGradientTools == null) {
errorGradientTools = new GradientTools();
errorGradientTools.isDiagonal = true;
errorGradientTools.isRotate = true;
int orange = Theme.getColor(Theme.key_color_orange);
final int red = Theme.getColor(Theme.key_text_RedBold);
orange = ColorUtils.blendARGB(orange, red, .25f);
errorGradientTools.setColors(orange, red);
errorGradientTools.paint.setStrokeWidth(AndroidUtilities.dpf2(2.3f));
errorGradientTools.paint.setStyle(Paint.Style.STROKE);
errorGradientTools.paint.setStrokeCap(Paint.Cap.ROUND);
}
errorGradientTools.setBounds(avatarImage.getImageX(), avatarImage.getImageY(), avatarImage.getImageX2(), avatarImage.getImageY2());
return errorGradientTools.paint;
}
public static void setStoryMiniImage(ImageReceiver imageReceiver, TLRPC.StoryItem storyItem) { public static void setStoryMiniImage(ImageReceiver imageReceiver, TLRPC.StoryItem storyItem) {
if (storyItem == null) { if (storyItem == null) {
return; return;
@ -960,6 +984,7 @@ public class StoriesUtilities {
public long crossfadeToDialog; public long crossfadeToDialog;
public float crossfadeToDialogProgress; public float crossfadeToDialogProgress;
public float progressToProgressSegments; public float progressToProgressSegments;
public float alpha = 1f;
private long dialogId; private long dialogId;
public int currentState; public int currentState;

View file

@ -488,7 +488,7 @@ public class StoryCaptionView extends NestedScrollView {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f); ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1f);
valueAnimator.addUpdateListener(animation -> { valueAnimator.addUpdateListener(animation -> {
float value = (float) animation.getAnimatedValue(); float value = (float) animation.getAnimatedValue();
final float toScrollY = (captionContainer.getBottom() - getMeasuredHeight()); final float toScrollY = Math.min(getMeasuredHeight() - blackoutBottomOffset - AndroidUtilities.dp(64), captionContainer.getBottom() - getMeasuredHeight());
setScrollY((int) AndroidUtilities.lerp(fromScrollY, toScrollY, value)); setScrollY((int) AndroidUtilities.lerp(fromScrollY, toScrollY, value));
captionTextview.progressToExpand = AndroidUtilities.lerp(fromP, toP, value); captionTextview.progressToExpand = AndroidUtilities.lerp(fromP, toP, value);
captionTextview.invalidate(); captionTextview.invalidate();

View file

@ -0,0 +1,95 @@
package org.telegram.ui.Stories;
import static org.telegram.messenger.AndroidUtilities.dp;
import static org.telegram.messenger.AndroidUtilities.dpf2;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.LayoutHelper;
import org.webrtc.voiceengine.WebRtcAudioEffects;
public class StoryFailView extends FrameLayout {
private final Paint redPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final Paint whitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private final TextView titleTextView;
private final TextView subtitleTextView;
private final TextView button;
public StoryFailView(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
redPaint.setColor(Theme.getColor(Theme.key_text_RedBold, resourcesProvider));
whitePaint.setColor(Color.WHITE);
setWillNotDraw(false);
titleTextView = new TextView(context);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
titleTextView.setText(LocaleController.getString(R.string.StoryError));
titleTextView.setTextColor(Color.WHITE);
addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 44, 0, 0, 0));
subtitleTextView = new TextView(context);
subtitleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 8);
subtitleTextView.setTextColor(Theme.multAlpha(Color.WHITE, .5f));
subtitleTextView.setVisibility(View.GONE);
subtitleTextView.setTranslationY(dp(9));
addView(subtitleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 44, 0, 0, 0));
button = new TextView(context);
button.setPadding(dp(13), 0, dp(13), 0);
button.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(16), 0x1fffffff, 0x38ffffff));
button.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM));
button.setText(LocaleController.getString(R.string.TryAgain));
button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
button.setTextColor(Color.WHITE);
button.setGravity(Gravity.CENTER);
addView(button, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 32, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 0, 12, 0));
}
public void set(TLRPC.TL_error error) {
if (error == null || TextUtils.isEmpty(error.text)) {
titleTextView.setTranslationY(0);
subtitleTextView.setVisibility(View.GONE);
} else {
titleTextView.setTranslationY(-dpf2(5.33f));
subtitleTextView.setText(error.text);
subtitleTextView.setVisibility(View.VISIBLE);
}
}
@Override
public void setOnClickListener(@Nullable OnClickListener l) {
button.setOnClickListener(l);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
final float cx = dp(13 + 10), cy = getHeight() / 2f;
canvas.drawCircle(cx, cy, dp(10), redPaint);
AndroidUtilities.rectTmp.set(cx - AndroidUtilities.dp(1), cy - AndroidUtilities.dpf2(4.6f), cx + AndroidUtilities.dp(1), cy + AndroidUtilities.dpf2(1.6f));
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(3), AndroidUtilities.dp(3), whitePaint);
AndroidUtilities.rectTmp.set(cx - AndroidUtilities.dp(1), cy + AndroidUtilities.dpf2(2.6f), cx + AndroidUtilities.dp(1), cy + AndroidUtilities.dpf2(2.6f + 2));
canvas.drawRoundRect(AndroidUtilities.rectTmp, AndroidUtilities.dp(3), AndroidUtilities.dp(3), whitePaint);
}
}

View file

@ -18,11 +18,11 @@ import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.PixelFormat; import android.graphics.PixelFormat;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.SurfaceTexture;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.text.Editable;
import android.util.LongSparseArray;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.Gravity; import android.view.Gravity;
@ -45,12 +45,11 @@ import androidx.viewpager.widget.ViewPager;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout; import com.google.android.exoplayer2.ui.AspectRatioFrameLayout;
import com.google.android.exoplayer2.util.Log;
import org.checkerframework.checker.units.qual.A;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.AnimationNotificationsLocker; import org.telegram.messenger.AnimationNotificationsLocker;
import org.telegram.messenger.BuildVars; import org.telegram.messenger.BuildVars;
import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.FileStreamLoadOperation; import org.telegram.messenger.FileStreamLoadOperation;
@ -62,6 +61,8 @@ import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.support.LongSparseIntArray; import org.telegram.messenger.support.LongSparseIntArray;
import org.telegram.messenger.support.SparseLongArray;
import org.telegram.messenger.video.VideoPlayerHolderBase;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.AdjustPanLayoutHelper; import org.telegram.ui.ActionBar.AdjustPanLayoutHelper;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
@ -73,9 +74,7 @@ import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.RadialProgress; import org.telegram.ui.Components.RadialProgress;
import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.SharedMediaLayout;
import org.telegram.ui.Components.SizeNotifierFrameLayout; import org.telegram.ui.Components.SizeNotifierFrameLayout;
import org.telegram.ui.Components.VideoPlayer;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
import java.util.ArrayList; import java.util.ArrayList;
@ -106,6 +105,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
private static TLRPC.StoryItem lastStoryItem; private static TLRPC.StoryItem lastStoryItem;
Theme.ResourcesProvider resourcesProvider = new DarkThemeResourceProvider(); Theme.ResourcesProvider resourcesProvider = new DarkThemeResourceProvider();
private boolean opening;
ValueAnimator openCloseAnimator; ValueAnimator openCloseAnimator;
ValueAnimator swipeToDissmissBackAnimator; ValueAnimator swipeToDissmissBackAnimator;
ValueAnimator swipeToReplyBackAnimator; ValueAnimator swipeToReplyBackAnimator;
@ -221,6 +221,8 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
private boolean isLikesReactions; private boolean isLikesReactions;
private float lastStoryContainerHeight; private float lastStoryContainerHeight;
LongSparseArray<CharSequence> replyDrafts = new LongSparseArray<>();
public static boolean isShowingImage(MessageObject messageObject) { public static boolean isShowingImage(MessageObject messageObject) {
if (lastStoryItem == null || messageObject.type != MessageObject.TYPE_STORY && !messageObject.isWebpage() || runOpenAnimationAfterLayout) { if (lastStoryItem == null || messageObject.type != MessageObject.TYPE_STORY && !messageObject.isWebpage() || runOpenAnimationAfterLayout) {
return false; return false;
@ -654,11 +656,11 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
transitionViewHolder.storyImage.setVisible(true, false); transitionViewHolder.storyImage.setVisible(true, false);
int r = canvas.getSaveCount(); int r = canvas.getSaveCount();
if (transitionViewHolder.drawClip != null) { if (transitionViewHolder.drawClip != null) {
transitionViewHolder.drawClip.clip(canvas, rect3, 1f - progress2); transitionViewHolder.drawClip.clip(canvas, rect3, 1f - progress2, opening);
} }
transitionViewHolder.storyImage.draw(canvas); transitionViewHolder.storyImage.draw(canvas);
if (transitionViewHolder.drawAbove != null) { if (transitionViewHolder.drawAbove != null) {
transitionViewHolder.drawAbove.draw(canvas, rect3, 1f - progress2); transitionViewHolder.drawAbove.draw(canvas, rect3, 1f - progress2, opening);
} }
transitionViewHolder.storyImage.setVisible(wasVisible, false); transitionViewHolder.storyImage.setVisible(wasVisible, false);
transitionViewHolder.storyImage.setImageCoords(x, y, w, h); transitionViewHolder.storyImage.setImageCoords(x, y, w, h);
@ -686,23 +688,27 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
rect2.set(toX, toY, toX + headerView.backupImageView.getMeasuredWidth(), toY + headerView.backupImageView.getMeasuredHeight()); rect2.set(toX, toY, toX + headerView.backupImageView.getMeasuredWidth(), toY + headerView.backupImageView.getMeasuredHeight());
} }
AndroidUtilities.lerp(rect1, rect2, progressToOpen, AndroidUtilities.rectTmp); AndroidUtilities.lerp(rect1, rect2, progressToOpen, rect3);
int r = canvas.getSaveCount();
if (transitionViewHolder != null && transitionViewHolder.drawClip != null) {
transitionViewHolder.drawClip.clip(canvas, rect3, 1f - progress2, opening);
}
if (animateAvatar) { if (animateAvatar) {
boolean crossfade = transitionViewHolder != null && transitionViewHolder.crossfadeToAvatarImage != null; boolean crossfade = transitionViewHolder != null && transitionViewHolder.crossfadeToAvatarImage != null;
if (!crossfade || progressToOpen != 0) { if (!crossfade || progressToOpen != 0) {
headerView.backupImageView.getImageReceiver().setImageCoords(AndroidUtilities.rectTmp); headerView.backupImageView.getImageReceiver().setImageCoords(rect3);
headerView.backupImageView.getImageReceiver().setRoundRadius((int) (AndroidUtilities.rectTmp.width() / 2f)); headerView.backupImageView.getImageReceiver().setRoundRadius((int) (rect3.width() / 2f));
headerView.backupImageView.getImageReceiver().setVisible(true, false); headerView.backupImageView.getImageReceiver().setVisible(true, false);
final float alpha = crossfade ? progressToOpen : 1f; final float alpha = crossfade ? progressToOpen : 1f;
float thisAlpha = alpha; float thisAlpha = alpha;
if (transitionViewHolder != null && transitionViewHolder.alpha < 1 && transitionViewHolder.bgPaint != null) { if (transitionViewHolder != null && transitionViewHolder.alpha < 1 && transitionViewHolder.bgPaint != null) {
transitionViewHolder.bgPaint.setAlpha((int) (0xFF * (1f - progress2))); transitionViewHolder.bgPaint.setAlpha((int) (0xFF * (1f - progress2)));
canvas.drawCircle(AndroidUtilities.rectTmp.centerX(), AndroidUtilities.rectTmp.centerY(), AndroidUtilities.rectTmp.width() / 2f, transitionViewHolder.bgPaint); canvas.drawCircle(rect3.centerX(), rect3.centerY(), rect3.width() / 2f, transitionViewHolder.bgPaint);
thisAlpha = AndroidUtilities.lerp(transitionViewHolder.alpha, thisAlpha, progress2); thisAlpha = AndroidUtilities.lerp(transitionViewHolder.alpha, thisAlpha, progress2);
} }
headerView.backupImageView.getImageReceiver().setAlpha(thisAlpha); headerView.backupImageView.getImageReceiver().setAlpha(thisAlpha);
headerView.drawUploadingProgress(canvas, AndroidUtilities.rectTmp, !runOpenAnimationAfterLayout, progressToOpen); headerView.drawUploadingProgress(canvas, rect3, !runOpenAnimationAfterLayout, progressToOpen);
headerView.backupImageView.getImageReceiver().draw(canvas); headerView.backupImageView.getImageReceiver().draw(canvas);
headerView.backupImageView.getImageReceiver().setAlpha(alpha); headerView.backupImageView.getImageReceiver().setAlpha(alpha);
headerView.backupImageView.getImageReceiver().setVisible(false, false); headerView.backupImageView.getImageReceiver().setVisible(false, false);
@ -716,10 +722,10 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
); );
int oldRadius = transitionViewHolder.crossfadeToAvatarImage.getRoundRadius()[0]; int oldRadius = transitionViewHolder.crossfadeToAvatarImage.getRoundRadius()[0];
boolean isVisible = transitionViewHolder.crossfadeToAvatarImage.getVisible(); boolean isVisible = transitionViewHolder.crossfadeToAvatarImage.getVisible();
transitionViewHolder.crossfadeToAvatarImage.setImageCoords(AndroidUtilities.rectTmp); transitionViewHolder.crossfadeToAvatarImage.setImageCoords(rect3);
transitionViewHolder.crossfadeToAvatarImage.setRoundRadius((int) (AndroidUtilities.rectTmp.width() / 2f)); transitionViewHolder.crossfadeToAvatarImage.setRoundRadius((int) (rect3.width() / 2f));
transitionViewHolder.crossfadeToAvatarImage.setVisible(true, false); transitionViewHolder.crossfadeToAvatarImage.setVisible(true, false);
canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (255 * (1f - progressToOpen)), Canvas.ALL_SAVE_FLAG); canvas.saveLayerAlpha(rect3, (int) (255 * (1f - progressToOpen)), Canvas.ALL_SAVE_FLAG);
transitionViewHolder.crossfadeToAvatarImage.draw(canvas); transitionViewHolder.crossfadeToAvatarImage.draw(canvas);
canvas.restore(); canvas.restore();
transitionViewHolder.crossfadeToAvatarImage.setVisible(isVisible, false); transitionViewHolder.crossfadeToAvatarImage.setVisible(isVisible, false);
@ -728,6 +734,10 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
// transitionViewHolder.crossfadeToAvatarImage.setVisible(false, false); // transitionViewHolder.crossfadeToAvatarImage.setVisible(false, false);
} }
} }
if (transitionViewHolder != null && transitionViewHolder.drawAbove != null) {
transitionViewHolder.drawAbove.draw(canvas, rect3, 1f - progress2, opening);
}
canvas.restoreToCount(r);
} }
@ -1272,7 +1282,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
} }
if (playerHolder == null) { if (playerHolder == null) {
playerHolder = new VideoPlayerHolder(); playerHolder = new VideoPlayerHolder(surfaceView, textureView);
playerHolder.document = document; playerHolder.document = document;
} }
// if (surfaceView != null) { // if (surfaceView != null) {
@ -1412,7 +1422,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
for (int i = 0; i < uries.size(); i++) { for (int i = 0; i < uries.size(); i++) {
Uri uri = uries.get(i); Uri uri = uries.get(i);
VideoPlayerHolder playerHolder = new VideoPlayerHolder(); VideoPlayerHolder playerHolder = new VideoPlayerHolder(surfaceView, textureView);
playerHolder.uri = uri; playerHolder.uri = uri;
playerHolder.document = documents.get(i); playerHolder.document = documents.get(i);
FileStreamLoadOperation.setPriorityForDocument(playerHolder.document, FileLoader.PRIORITY_LOW); FileStreamLoadOperation.setPriorityForDocument(playerHolder.document, FileLoader.PRIORITY_LOW);
@ -1476,6 +1486,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
if (ATTACH_TO_FRAGMENT) { if (ATTACH_TO_FRAGMENT) {
AndroidUtilities.removeFromParent(windowView);
windowView.setFitsSystemWindows(true); windowView.setFitsSystemWindows(true);
fragment.getLayoutContainer().addView(windowView); fragment.getLayoutContainer().addView(windowView);
AndroidUtilities.requestAdjustResize(fragment.getParentActivity(), fragment.getClassGuid()); AndroidUtilities.requestAdjustResize(fragment.getParentActivity(), fragment.getClassGuid());
@ -1707,7 +1718,9 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
private void lockOrientation(boolean lock) { private void lockOrientation(boolean lock) {
Activity activity = AndroidUtilities.findActivity(fragment.getContext()); Activity activity = AndroidUtilities.findActivity(fragment.getContext());
if (activity != null) { if (activity != null) {
activity.setRequestedOrientation(lock ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); try {
activity.setRequestedOrientation(lock ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT : ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} catch (Exception ignore) {}
if (lock) { if (lock) {
activity.getWindow().addFlags(FLAG_KEEP_SCREEN_ON); activity.getWindow().addFlags(FLAG_KEEP_SCREEN_ON);
} else { } else {
@ -2001,6 +2014,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
peerStoriesView.headerView.radialProgress.copyParams(transitionViewHolder.radialProgressUpload); peerStoriesView.headerView.radialProgress.copyParams(transitionViewHolder.radialProgressUpload);
} }
} }
opening = true;
openCloseAnimator = ValueAnimator.ofFloat(0, 1f); openCloseAnimator = ValueAnimator.ofFloat(0, 1f);
openCloseAnimator.addUpdateListener(animation -> { openCloseAnimator.addUpdateListener(animation -> {
progressToOpen = (float) animation.getAnimatedValue(); progressToOpen = (float) animation.getAnimatedValue();
@ -2095,6 +2109,7 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
updateTransitionParams(); updateTransitionParams();
locker.lock(); locker.lock();
fromDismissOffset = swipeToDismissOffset; fromDismissOffset = swipeToDismissOffset;
opening = false;
openCloseAnimator = ValueAnimator.ofFloat(progressToOpen, 0); openCloseAnimator = ValueAnimator.ofFloat(progressToOpen, 0);
openCloseAnimator.addUpdateListener(animation -> { openCloseAnimator.addUpdateListener(animation -> {
progressToOpen = (float) animation.getAnimatedValue(); progressToOpen = (float) animation.getAnimatedValue();
@ -2117,6 +2132,9 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
layoutAndFindView(); layoutAndFindView();
} }
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (openCloseAnimator == null) {
return;
}
containerView.enableHwAcceleration(); containerView.enableHwAcceleration();
openCloseAnimator.addListener(new AnimatorListenerAdapter() { openCloseAnimator.addListener(new AnimatorListenerAdapter() {
@Override @Override
@ -2473,6 +2491,33 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
} }
public void saveDraft(long dialogId, TLRPC.StoryItem storyItem, CharSequence text) {
if (dialogId == 0 || storyItem == null) {
return;
}
Log.d("kek", "saveDraft" + dialogId + "_" + storyItem.id + " " + text);
replyDrafts.put(draftHash(dialogId, storyItem), text);
}
public CharSequence getDraft(long dialogId, TLRPC.StoryItem storyItem) {
if (dialogId == 0 || storyItem == null) {
return "";
}
Log.d("kek", "getDraft " + dialogId + "_" + storyItem.id + " " + replyDrafts.get(draftHash(dialogId, storyItem), ""));
return replyDrafts.get(draftHash(dialogId, storyItem), "");
}
public void clearDraft(long dialogId, TLRPC.StoryItem storyItem) {
if (dialogId == 0 || storyItem == null) {
return;
}
replyDrafts.remove(draftHash(dialogId, storyItem));
}
private long draftHash(long dialogId, TLRPC.StoryItem oldStoryItem) {
return dialogId + (dialogId >> 16) + ((long) oldStoryItem.id << 16);
}
public interface PlaceProvider { public interface PlaceProvider {
boolean findView(long dialogId, int messageId, int storyId, int type, TransitionViewHolder holder); boolean findView(long dialogId, int messageId, int storyId, int type, TransitionViewHolder holder);
@ -2483,11 +2528,11 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
} }
public interface HolderDrawAbove { public interface HolderDrawAbove {
void draw(Canvas canvas, RectF bounds, float alpha); void draw(Canvas canvas, RectF bounds, float alpha, boolean opening);
} }
public interface HolderClip { public interface HolderClip {
void clip(Canvas canvas, RectF bounds, float alpha); void clip(Canvas canvas, RectF bounds, float alpha, boolean opening);
} }
public static class TransitionViewHolder { public static class TransitionViewHolder {
@ -2527,356 +2572,55 @@ public class StoryViewer implements NotificationCenter.NotificationCenterDelegat
static int queuePointer = 0; static int queuePointer = 0;
public class VideoPlayerHolder { public class VideoPlayerHolder extends VideoPlayerHolderBase {
public boolean paused;
public TLRPC.Document document;
VideoPlayer videoPlayer;
Runnable initRunnable;
volatile boolean released;
boolean firstFrameRendered;
float progress;
int lastState;
public long currentPosition;
long playerDuration;
boolean audioDisabled;
boolean stubAvailable;
boolean logBuffering; boolean logBuffering;
final DispatchQueue dispatchQueue = Utilities.getOrCreatePlayerQueue(); public VideoPlayerHolder(SurfaceView surfaceView, TextureView textureView) {
Uri uri; if (USE_SURFACE_VIEW) {
with(surfaceView);
Runnable progressRunnable = new Runnable() {
@Override
public void run() {
if (videoPlayer != null) {
if (lastState == ExoPlayer.STATE_ENDED) {
progress = 1f;
} else {
currentPosition = videoPlayer.getCurrentPosition();
playerDuration = videoPlayer.getDuration();
}
if (lastState == ExoPlayer.STATE_READY) {
dispatchQueue.cancelRunnable(progressRunnable);
dispatchQueue.postRunnable(progressRunnable, 16);
}
}
}
};
long startTime;
void preparePlayer(Uri uri, boolean audioDisabled) {
this.audioDisabled = audioDisabled;
paused = true;
if (initRunnable != null) {
dispatchQueue.cancelRunnable(initRunnable);
}
dispatchQueue.postRunnable(initRunnable = () -> {
if (released) {
return;
}
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other", FileLoader.PRIORITY_LOW);
videoPlayer.setPlayWhenReady(false);
videoPlayer.setWorkerQueue(dispatchQueue);
});
}
void start(boolean paused, Uri uri, long t, boolean audioDisabled) {
startTime = System.currentTimeMillis();
this.audioDisabled = audioDisabled;
this.paused = paused;
dispatchQueue.postRunnable(initRunnable = () -> {
if (released) {
return;
}
if (videoPlayer == null) {
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other");
videoPlayer.setWorkerQueue(dispatchQueue);
if (!paused) {
if (USE_SURFACE_VIEW) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
videoPlayer.setPlayWhenReady(true);
}
} else {
if (!paused) {
if (USE_SURFACE_VIEW) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
videoPlayer.play();
}
}
if (t > 0) {
videoPlayer.seekTo(t);
}
videoPlayer.setVolume(isInSilentMode ? 0 : 1f);
AndroidUtilities.runOnUIThread(() -> initRunnable = null);
});
}
private void ensurePlayerCreated(boolean audioDisabled) {
if (videoPlayer != null) {
videoPlayer.releasePlayer(true);
}
videoPlayer = new VideoPlayer(false, audioDisabled);
videoPlayer.setDelegate(new VideoPlayer.VideoPlayerDelegate() {
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
lastState = playbackState;
if (playbackState == ExoPlayer.STATE_READY || playbackState == ExoPlayer.STATE_BUFFERING) {
dispatchQueue.cancelRunnable(progressRunnable);
dispatchQueue.postRunnable(progressRunnable);
if (firstFrameRendered && playbackState == ExoPlayer.STATE_BUFFERING) {
logBuffering = true;
AndroidUtilities.runOnUIThread(() -> {
final PeerStoriesView storiesView = getCurrentPeerView();
if (storiesView != null && storiesView.currentStory.storyItem != null) {
FileLog.d("StoryViewer displayed story buffering dialogId=" + storiesView.getCurrentPeer() + " storyId=" + storiesView.currentStory.storyItem.id);
}
});
}
if (logBuffering && playbackState == ExoPlayer.STATE_READY) {
logBuffering = false;
AndroidUtilities.runOnUIThread(() -> {
final PeerStoriesView storiesView = getCurrentPeerView();
if (storiesView != null && storiesView.currentStory.storyItem != null) {
FileLog.d("StoryViewer displayed story playing dialogId=" + storiesView.getCurrentPeer() + " storyId=" + storiesView.currentStory.storyItem.id);
}
});
}
} else if (playbackState == ExoPlayer.STATE_ENDED) {
if (isCaptionPartVisible) {
progress = 0;
videoPlayer.seekTo(0);
videoPlayer.play();
} else {
progress = 1f;
}
}
}
@Override
public void onError(VideoPlayer player, Exception e) {
FileLog.e(e);
}
@Override
public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
}
@Override
public void onRenderedFirstFrame() {
AndroidUtilities.runOnUIThread(() -> {
if (released || currentPlayerScope == null) {
return;
}
firstFrameRendered = currentPlayerScope.firstFrameRendered = true;
currentPlayerScope.invalidate();
if (onReadyListener != null) {
onReadyListener.run();
onReadyListener = null;
}
}, 16);
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
}
@Override
public boolean onSurfaceDestroyed(SurfaceTexture surfaceTexture) {
return false;
}
});
videoPlayer.setIsStory();
}
private Runnable onReadyListener;
public void setOnReadyListener(Runnable listener) {
onReadyListener = listener;
}
boolean release(Runnable whenReleased) {
TLRPC.Document document = this.document;
if (document != null) {
int priority = FileStreamLoadOperation.getStreamPrioriy(document);
if (priority != FileLoader.PRIORITY_LOW) {
FileStreamLoadOperation.setPriorityForDocument(document, FileLoader.PRIORITY_LOW);
FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_LOW, document, null, null, null, null, null);
// FileLoader.getInstance(currentAccount).cancelLoadFile(document);
}
// FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_LOW, document, null, null, null, null, null);
}
released = true;
dispatchQueue.cancelRunnable(initRunnable);
initRunnable = null;
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
try {
videoPlayer.setTextureView(null);
videoPlayer.setSurfaceView(null);
} catch (Exception e) {
}
videoPlayer.releasePlayer(false);
}
if (document != null) {
FileLoader.getInstance(currentAccount).cancelLoadFile(document);
// FileLoader.getInstance(currentAccount).changePriority(FileLoader.PRIORITY_LOW, document, null, null, null, null, null);
}
if (whenReleased != null) {
AndroidUtilities.runOnUIThread(whenReleased);
}
videoPlayer = null;
});
if (playerStubBitmap != null) {
AndroidUtilities.recycleBitmap(playerStubBitmap);
playerStubBitmap = null;
}
return true;
}
public void pause() {
if (released) {
return;
}
if (paused) {
return;
}
paused = true;
if (USE_SURFACE_VIEW && surfaceView != null && firstFrameRendered && surfaceView.getHolder().getSurface().isValid()) {
stubAvailable = true;
if (playerStubBitmap == null) {
playerStubBitmap = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
playerStubPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
AndroidUtilities.getBitmapFromSurface(surfaceView, playerStubBitmap);
}
}
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
videoPlayer.pause();
}
});
}
public void play() {
if (released) {
return;
}
if (!paused) {
return;
}
paused = false;
dispatchQueue.postRunnable(() -> {
if (videoPlayer != null) {
if (USE_SURFACE_VIEW) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
videoPlayer.setPlayWhenReady(true);
}
});
}
public void setAudioEnabled(boolean enabled, boolean prepared) {
boolean disabled = !enabled;
if (audioDisabled == disabled) {
return;
}
audioDisabled = disabled;
dispatchQueue.postRunnable(() -> {
if (videoPlayer == null) {
return;
}
boolean playing = videoPlayer.isPlaying();
if (enabled && !videoPlayer.createdWithAudioTrack()) {
//release and create new with audio track
videoPlayer.pause();
long position = videoPlayer.getCurrentPosition();
videoPlayer.releasePlayer(false);
videoPlayer = null;
ensurePlayerCreated(audioDisabled);
videoPlayer.preparePlayer(uri, "other");
videoPlayer.setWorkerQueue(dispatchQueue);
if (!prepared) {
if (USE_SURFACE_VIEW) {
videoPlayer.setSurfaceView(surfaceView);
} else {
videoPlayer.setTextureView(textureView);
}
}
// videoPlayer.setTextureView(textureView);
videoPlayer.seekTo(position + 50);
if (playing && !prepared) {
videoPlayer.setPlayWhenReady(true);
videoPlayer.play();
} else {
videoPlayer.setPlayWhenReady(false);
videoPlayer.pause();
}
} else {
videoPlayer.setVolume(enabled ? 1f : 0);
}
});
}
public float getPlaybackProgress(long totalDuration) {
if (lastState == ExoPlayer.STATE_ENDED) {
progress = 1f;
} else { } else {
float localProgress; with(textureView);
if (totalDuration != 0) {
localProgress = currentPosition / (float) totalDuration;
} else {
localProgress = currentPosition / (float) playerDuration;
}
if (localProgress < progress) {
return progress;
}
progress = localProgress;
} }
return progress;
} }
public void loopBack() {
progress = 0; @Override
lastState = ExoPlayer.STATE_IDLE; public boolean needRepeat() {
dispatchQueue.postRunnable(() -> { return isCaptionPartVisible;
if (videoPlayer != null) { }
videoPlayer.seekTo(0);
@Override
public void onRenderedFirstFrame() {
if (currentPlayerScope == null) {
return;
}
firstFrameRendered = currentPlayerScope.firstFrameRendered = true;
currentPlayerScope.invalidate();
}
@Override
public void onStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_READY || playbackState == ExoPlayer.STATE_BUFFERING) {
if (firstFrameRendered && playbackState == ExoPlayer.STATE_BUFFERING) {
logBuffering = true;
AndroidUtilities.runOnUIThread(() -> {
final PeerStoriesView storiesView = getCurrentPeerView();
if (storiesView != null && storiesView.currentStory.storyItem != null) {
FileLog.d("StoryViewer displayed story buffering dialogId=" + storiesView.getCurrentPeer() + " storyId=" + storiesView.currentStory.storyItem.id);
}
});
} }
progress = 0; if (logBuffering && playbackState == ExoPlayer.STATE_READY) {
currentPosition = 0; logBuffering = false;
}); AndroidUtilities.runOnUIThread(() -> {
} final PeerStoriesView storiesView = getCurrentPeerView();
if (storiesView != null && storiesView.currentStory.storyItem != null) {
public void setVolume(float v) { FileLog.d("StoryViewer displayed story playing dialogId=" + storiesView.getCurrentPeer() + " storyId=" + storiesView.currentStory.storyItem.id);
dispatchQueue.postRunnable(() -> { }
if (videoPlayer != null) { });
videoPlayer.setVolume(v);
} }
}); }
}
public boolean isBuffering() {
return !released && lastState == ExoPlayer.STATE_BUFFERING;
} }
} }
} }

View file

@ -205,7 +205,7 @@ public class CaptionContainerView extends FrameLayout {
limitTextView.cancelAnimation(); limitTextView.cancelAnimation();
limitTextView.setText(limitText); limitTextView.setText(limitText);
limitTextView.setTextColor(length >= limit ? 0xffEC7777 : 0xffffffff); limitTextView.setTextColor(length >= limit ? 0xffEC7777 : 0xffffffff);
if (length > limit && !premium && length < MessagesController.getInstance(currentAccount).storyCaptionLengthLimitPremium && length > lastLength && captionLimitToast()) { if (length > limit && !premium && length < MessagesController.getInstance(currentAccount).storyCaptionLengthLimitPremium && length > lastLength && (captionLimitToast() || MessagesController.getInstance(currentAccount).premiumLocked)) {
AndroidUtilities.shakeViewSpring(limitTextView, shiftDp = -shiftDp); AndroidUtilities.shakeViewSpring(limitTextView, shiftDp = -shiftDp);
BotWebViewVibrationEffect.APP_ERROR.vibrate(); BotWebViewVibrationEffect.APP_ERROR.vibrate();
} }

View file

@ -174,7 +174,7 @@ public class DownloadButton extends ImageView {
} }
private void onClickInternal() { private void onClickInternal() {
if (!preparing) { if (!preparing || currentEntry == null) {
return; return;
} }
preparing = false; preparing = false;

View file

@ -1,13 +1,10 @@
package org.telegram.ui.Stories.recorder; package org.telegram.ui.Stories.recorder;
import android.net.wifi.WifiManager;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import org.checkerframework.checker.units.qual.A;
import org.telegram.SQLite.SQLiteCursor; import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase; import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.SQLite.SQLitePreparedStatement;
@ -15,27 +12,22 @@ import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.MediaController; import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.VideoEditedInfo; import org.telegram.messenger.VideoEditedInfo;
import org.telegram.tgnet.AbstractSerializedData; import org.telegram.tgnet.AbstractSerializedData;
import org.telegram.tgnet.NativeByteBuffer; import org.telegram.tgnet.NativeByteBuffer;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.Theme;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.CopyOption;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List; import java.util.List;
public class DraftsController { public class DraftsController {
@ -46,27 +38,22 @@ public class DraftsController {
public DraftsController(int currentAccount) { public DraftsController(int currentAccount) {
this.currentAccount = currentAccount; this.currentAccount = currentAccount;
loadFailed();
} }
private boolean loaded, loading;
public final ArrayList<StoryEntry> drafts = new ArrayList<>(); public final ArrayList<StoryEntry> drafts = new ArrayList<>();
public void load() { private void loadInternal(final boolean failed, Utilities.Callback<ArrayList<StoryDraft>> callback) {
if (loaded || loading) {
return;
}
loading = true;
final MessagesStorage storage = MessagesStorage.getInstance(currentAccount); final MessagesStorage storage = MessagesStorage.getInstance(currentAccount);
storage.getStorageQueue().postRunnable(() -> { storage.getStorageQueue().postRunnable(() -> {
SQLiteCursor cursor = null; SQLiteCursor cursor = null;
final ArrayList<StoryDraft> savedDrafts = new ArrayList<>(); final ArrayList<StoryDraft> loadedDrafts = new ArrayList<>();
try { try {
SQLiteDatabase database = storage.getDatabase(); SQLiteDatabase database = storage.getDatabase();
if (database == null) { if (database == null) {
return; return;
} }
cursor = database.queryFinalized("SELECT id, data FROM story_drafts ORDER BY date DESC"); cursor = database.queryFinalized("SELECT id, data, type FROM story_drafts WHERE type = " + (failed ? "2" : "0 OR type = 1") + " ORDER BY date DESC");
while (cursor.next()) { while (cursor.next()) {
long id = cursor.longValue(0); long id = cursor.longValue(0);
NativeByteBuffer buffer = cursor.byteBufferValue(1); NativeByteBuffer buffer = cursor.byteBufferValue(1);
@ -74,7 +61,7 @@ public class DraftsController {
try { try {
StoryDraft draft = new StoryDraft(buffer, true); StoryDraft draft = new StoryDraft(buffer, true);
draft.id = id; draft.id = id;
savedDrafts.add(draft); loadedDrafts.add(draft);
} catch (Exception e) { } catch (Exception e) {
FileLog.e(e); FileLog.e(e);
} }
@ -89,36 +76,83 @@ public class DraftsController {
} }
} }
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> callback.run(loadedDrafts));
final long now = System.currentTimeMillis(); });
ArrayList<Long> ids = new ArrayList<>(); }
ArrayList<StoryEntry> deleteEntries = new ArrayList<>();
for (int i = 0; i < savedDrafts.size(); ++i) { private boolean loaded, loading;
StoryEntry entry = savedDrafts.get(i).toEntry(); public void load() {
if (entry == null) { if (loaded || loading) {
continue; return;
} }
if (
entry.file == null || loading = true;
!entry.file.exists() || loadInternal(false, loadedDrafts -> {
(entry.isEdit ? final long now = System.currentTimeMillis();
(now > entry.editExpireDate) : ArrayList<Long> ids = new ArrayList<>();
(now - entry.draftDate > EXPIRATION_PERIOD) ArrayList<StoryEntry> deleteEntries = new ArrayList<>();
) for (int i = 0; i < loadedDrafts.size(); ++i) {
) { StoryEntry entry = loadedDrafts.get(i).toEntry();
deleteEntries.add(entry); if (entry == null) {
} else { continue;
drafts.add(entry);
ids.add(entry.draftId);
}
} }
delete(deleteEntries); if (
entry.file == null ||
!entry.file.exists() ||
(entry.isEdit ?
(now > entry.editExpireDate) :
(now - entry.draftDate > EXPIRATION_PERIOD)
)
) {
deleteEntries.add(entry);
} else {
drafts.add(entry);
ids.add(entry.draftId);
}
}
delete(deleteEntries);
loading = false; loading = false;
loaded = true; loaded = true;
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesDraftsUpdated); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesDraftsUpdated);
}); });
}
private boolean loadedFailed, loadingFailed;
private void loadFailed() {
if (loadedFailed || loadingFailed) {
return;
}
loadingFailed = true;
loadInternal(true, loadedDrafts -> {
final long now = System.currentTimeMillis();
ArrayList<Long> ids = new ArrayList<>();
ArrayList<StoryEntry> deleteEntries = new ArrayList<>();
ArrayList<StoryEntry> appendEntries = new ArrayList<>();
for (int i = 0; i < loadedDrafts.size(); ++i) {
StoryEntry entry = loadedDrafts.get(i).toEntry();
if (entry == null) {
continue;
}
if (
entry.file == null ||
!entry.file.exists() ||
now - entry.draftDate > EXPIRATION_PERIOD
) {
deleteEntries.add(entry);
} else {
appendEntries.add(entry);
ids.add(entry.draftId);
}
}
delete(deleteEntries);
loadingFailed = false;
loadedFailed = true;
MessagesController.getInstance(currentAccount).getStoriesController().putUploadingDrafts(appendEntries);
}); });
} }
@ -128,7 +162,9 @@ public class DraftsController {
} }
prepare(entry); prepare(entry);
drafts.remove(entry); drafts.remove(entry);
drafts.add(0, entry); if (!entry.isError) {
drafts.add(0, entry);
}
final StoryDraft draft = new StoryDraft(entry); final StoryDraft draft = new StoryDraft(entry);
final MessagesStorage storage = MessagesStorage.getInstance(currentAccount); final MessagesStorage storage = MessagesStorage.getInstance(currentAccount);
storage.getStorageQueue().postRunnable(() -> { storage.getStorageQueue().postRunnable(() -> {
@ -139,13 +175,20 @@ public class DraftsController {
return; return;
} }
state = database.executeFast("REPLACE INTO story_drafts VALUES (?, ?, ?)"); state = database.executeFast("REPLACE INTO story_drafts VALUES (?, ?, ?, ?)");
state.requery(); state.requery();
NativeByteBuffer data = new NativeByteBuffer(draft.getObjectSize()); NativeByteBuffer data = new NativeByteBuffer(draft.getObjectSize());
draft.toStream(data); draft.toStream(data);
state.bindLong(1, draft.id); state.bindLong(1, draft.id);
state.bindLong(2, draft.date); state.bindLong(2, draft.date);
state.bindByteBuffer(3, data); state.bindByteBuffer(3, data);
int type = 0;
if (draft.isEdit) {
type = 1;
} else if (draft.isError) {
type = 2;
}
state.bindInteger(4, type);
state.step(); state.step();
data.reuse(); data.reuse();
state.dispose(); state.dispose();
@ -166,6 +209,8 @@ public class DraftsController {
return; return;
} }
if (entry.draftId == 0)
entry.draftId = Utilities.random.nextLong();
entry.draftDate = System.currentTimeMillis(); entry.draftDate = System.currentTimeMillis();
entry.isDraft = true; entry.isDraft = true;
@ -211,8 +256,7 @@ public class DraftsController {
return; return;
} }
prepare(entry); prepare(entry);
final long id = Utilities.random.nextLong(); entry.draftId = Utilities.random.nextLong();
entry.draftId = id;
final StoryDraft draft = new StoryDraft(entry); final StoryDraft draft = new StoryDraft(entry);
drafts.remove(entry); drafts.remove(entry);
drafts.add(0, entry); drafts.add(0, entry);
@ -221,7 +265,7 @@ public class DraftsController {
private void append(StoryDraft draft) { private void append(StoryDraft draft) {
final MessagesStorage storage = MessagesStorage.getInstance(currentAccount); final MessagesStorage storage = MessagesStorage.getInstance(currentAccount);
FileLog.d("StoryDraft append " + draft.id + " (edit=" + draft.edit + (draft.edit ? ", storyId=" + draft.editStoryId + ", " + (draft.editDocumentId != 0 ? "documentId=" + draft.editDocumentId : "photoId=" + draft.editPhotoId) + ", expireDate=" + draft.editExpireDate : "") + ", now="+System.currentTimeMillis()+")"); FileLog.d("StoryDraft append " + draft.id + " (edit=" + draft.isEdit + (draft.isEdit ? ", storyId=" + draft.editStoryId + ", " + (draft.editDocumentId != 0 ? "documentId=" + draft.editDocumentId : "photoId=" + draft.editPhotoId) + ", expireDate=" + draft.editExpireDate : "") + ", now="+System.currentTimeMillis()+")");
storage.getStorageQueue().postRunnable(() -> { storage.getStorageQueue().postRunnable(() -> {
SQLitePreparedStatement state = null; SQLitePreparedStatement state = null;
try { try {
@ -230,13 +274,20 @@ public class DraftsController {
return; return;
} }
state = database.executeFast("INSERT INTO story_drafts VALUES (?, ?, ?)"); state = database.executeFast("INSERT INTO story_drafts VALUES (?, ?, ?, ?)");
state.requery(); state.requery();
NativeByteBuffer data = new NativeByteBuffer(draft.getObjectSize()); NativeByteBuffer data = new NativeByteBuffer(draft.getObjectSize());
draft.toStream(data); draft.toStream(data);
state.bindLong(1, draft.id); state.bindLong(1, draft.id);
state.bindLong(2, draft.date); state.bindLong(2, draft.date);
state.bindByteBuffer(3, data); state.bindByteBuffer(3, data);
int type = 0;
if (draft.isEdit) {
type = 1;
} else if (draft.isError) {
type = 2;
}
state.bindInteger(4, type);
state.step(); state.step();
data.reuse(); data.reuse();
state.dispose(); state.dispose();
@ -294,7 +345,7 @@ public class DraftsController {
final long id = Utilities.random.nextLong(); final long id = Utilities.random.nextLong();
entry.draftId = id; entry.draftId = id;
final StoryDraft draft = new StoryDraft(entry); final StoryDraft draft = new StoryDraft(entry);
draft.edit = entry.isEdit = true; draft.isEdit = entry.isEdit = true;
draft.editStoryPeerId = entry.editStoryPeerId = dialogId; draft.editStoryPeerId = entry.editStoryPeerId = dialogId;
draft.editStoryId = entry.editStoryId = storyItem.id; draft.editStoryId = entry.editStoryId = storyItem.id;
draft.editExpireDate = entry.editExpireDate = storyItem.expire_date * 1000L; draft.editExpireDate = entry.editExpireDate = storyItem.expire_date * 1000L;
@ -393,6 +444,7 @@ public class DraftsController {
public long id; public long id;
public long date; public long date;
public String thumb; public String thumb;
public String fullThumb;
public boolean isVideo; public boolean isVideo;
public String file; public String file;
@ -426,17 +478,21 @@ public class DraftsController {
private final ArrayList<StoryEntry.Part> parts = new ArrayList<>(); private final ArrayList<StoryEntry.Part> parts = new ArrayList<>();
public boolean edit; public boolean isEdit;
public int editStoryId; public int editStoryId;
public long editStoryPeerId; public long editStoryPeerId;
public long editDocumentId; public long editDocumentId;
public long editPhotoId; public long editPhotoId;
public long editExpireDate; public long editExpireDate;
public boolean isError;
public TLRPC.TL_error error;
public StoryDraft(@NonNull StoryEntry entry) { public StoryDraft(@NonNull StoryEntry entry) {
this.id = entry.draftId; this.id = entry.draftId;
this.date = entry.draftDate; this.date = entry.draftDate;
this.thumb = entry.draftThumbFile == null ? "" : entry.draftThumbFile.toString(); this.thumb = entry.draftThumbFile == null ? "" : entry.draftThumbFile.toString();
this.fullThumb = entry.uploadThumbFile == null ? "" : entry.uploadThumbFile.toString();
this.isVideo = entry.isVideo; this.isVideo = entry.isVideo;
this.file = entry.file == null ? "" : entry.file.toString(); this.file = entry.file == null ? "" : entry.file.toString();
this.fileDeletable = entry.fileDeletable; this.fileDeletable = entry.fileDeletable;
@ -467,6 +523,8 @@ public class DraftsController {
this.period = entry.period; this.period = entry.period;
this.parts.clear(); this.parts.clear();
this.parts.addAll(entry.parts); this.parts.addAll(entry.parts);
this.isError = entry.isError;
this.error = entry.error;
} }
public StoryEntry toEntry() { public StoryEntry toEntry() {
@ -474,9 +532,12 @@ public class DraftsController {
entry.draftId = id; entry.draftId = id;
entry.isDraft = true; entry.isDraft = true;
entry.draftDate = date; entry.draftDate = date;
if (thumb != null) { if (!TextUtils.isEmpty(thumb)) {
entry.draftThumbFile = new File(thumb); entry.draftThumbFile = new File(thumb);
} }
if (!TextUtils.isEmpty(fullThumb)) {
entry.uploadThumbFile = new File(fullThumb);
}
entry.isVideo = isVideo; entry.isVideo = isVideo;
if (file != null) { if (file != null) {
entry.file = new File(file); entry.file = new File(file);
@ -530,12 +591,14 @@ public class DraftsController {
for (int i = 0; i < parts.size(); ++i) { for (int i = 0; i < parts.size(); ++i) {
entry.partsMaxId = Math.max(entry.partsMaxId, parts.get(i).id); entry.partsMaxId = Math.max(entry.partsMaxId, parts.get(i).id);
} }
entry.isEdit = edit; entry.isEdit = isEdit;
entry.editStoryId = editStoryId; entry.editStoryId = editStoryId;
entry.editStoryPeerId = editStoryPeerId; entry.editStoryPeerId = editStoryPeerId;
entry.editExpireDate = editExpireDate; entry.editExpireDate = editExpireDate;
entry.editPhotoId = editPhotoId; entry.editPhotoId = editPhotoId;
entry.editDocumentId = editDocumentId; entry.editDocumentId = editDocumentId;
entry.isError = isError;
entry.error = error;
return entry; return entry;
} }
@ -606,13 +669,20 @@ public class DraftsController {
for (int i = 0; i < parts.size(); ++i) { for (int i = 0; i < parts.size(); ++i) {
parts.get(i).serializeToStream(stream); parts.get(i).serializeToStream(stream);
} }
stream.writeBool(edit); stream.writeBool(isEdit);
stream.writeInt32(editStoryId); stream.writeInt32(editStoryId);
stream.writeInt64(editStoryPeerId); stream.writeInt64(editStoryPeerId);
stream.writeInt64(editExpireDate); stream.writeInt64(editExpireDate);
stream.writeInt64(editPhotoId); stream.writeInt64(editPhotoId);
stream.writeInt64(editDocumentId); stream.writeInt64(editDocumentId);
stream.writeString(paintEntitiesFilePath); stream.writeString(paintEntitiesFilePath);
stream.writeBool(isError);
if (error == null) {
stream.writeInt32(TLRPC.TL_null.constructor);
} else {
error.serializeToStream(stream);
}
stream.writeString(fullThumb);
} }
public int getObjectSize() { public int getObjectSize() {
@ -745,7 +815,7 @@ public class DraftsController {
} }
} }
if (stream.remaining() > 0) { if (stream.remaining() > 0) {
edit = stream.readBool(exception); isEdit = stream.readBool(exception);
editStoryId = stream.readInt32(exception); editStoryId = stream.readInt32(exception);
editStoryPeerId = stream.readInt64(exception); editStoryPeerId = stream.readInt64(exception);
editExpireDate = stream.readInt64(exception); editExpireDate = stream.readInt64(exception);
@ -758,6 +828,16 @@ public class DraftsController {
paintEntitiesFilePath = null; paintEntitiesFilePath = null;
} }
} }
if (stream.remaining() > 0) {
isError = stream.readBool(exception);
magic = stream.readInt32(exception);
if (magic == TLRPC.TL_null.constructor) {
error = null;
} else {
error = TLRPC.TL_error.TLdeserialize(stream, magic, exception);
}
fullThumb = stream.readString(exception);
}
} }
} }
} }

View file

@ -454,7 +454,7 @@ public class GalleryListView extends FrameLayout implements NotificationCenter.N
if (!onlyPhotos) { if (!onlyPhotos) {
ArrayList<StoryEntry> draftArray = MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().drafts; ArrayList<StoryEntry> draftArray = MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().drafts;
for (StoryEntry draft : draftArray) { for (StoryEntry draft : draftArray) {
if (!draft.isEdit) { if (!draft.isEdit && !draft.isError) {
drafts.add(draft); drafts.add(draft);
} }
} }
@ -1406,7 +1406,7 @@ public class GalleryListView extends FrameLayout implements NotificationCenter.N
if (!onlyPhotos) { if (!onlyPhotos) {
ArrayList<StoryEntry> draftArray = MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().drafts; ArrayList<StoryEntry> draftArray = MessagesController.getInstance(currentAccount).getStoriesController().getDraftsController().drafts;
for (StoryEntry draft : draftArray) { for (StoryEntry draft : draftArray) {
if (!draft.isEdit) { if (!draft.isEdit && !draft.isError) {
drafts.add(draft); drafts.add(draft);
} }
} }

View file

@ -3530,6 +3530,7 @@ public class PaintView extends SizeNotifierFrameLayoutPhoto implements IPhotoPai
@Override @Override
public void onEntityDragEnd(boolean delete) { public void onEntityDragEnd(boolean delete) {
updatePreviewViewTranslationY(); updatePreviewViewTranslationY();
forceChanges = true;
} }
@Override @Override

View file

@ -65,6 +65,9 @@ public class StoryEntry extends IStoryPart {
public boolean editedMedia, editedCaption, editedPrivacy; public boolean editedMedia, editedCaption, editedPrivacy;
public ArrayList<TLRPC.MediaArea> editedMediaAreas; public ArrayList<TLRPC.MediaArea> editedMediaAreas;
public boolean isError;
public TLRPC.TL_error error;
public long editDocumentId; public long editDocumentId;
public long editPhotoId; public long editPhotoId;
public long editExpireDate; public long editExpireDate;
@ -828,9 +831,10 @@ public class StoryEntry extends IStoryPart {
public float minlum; public float minlum;
public int getHDRType() { public int getHDRType() {
if (maxlum <= 0 && minlum <= 0) { // if (maxlum <= 0 && minlum <= 0) {
return 0; // return 0;
} else if (colorStandard == MediaFormat.COLOR_STANDARD_BT2020) { // } else
if (colorStandard == MediaFormat.COLOR_STANDARD_BT2020) {
if (colorTransfer == MediaFormat.COLOR_TRANSFER_HLG) { if (colorTransfer == MediaFormat.COLOR_TRANSFER_HLG) {
return 1; return 1;
} else if (colorTransfer == MediaFormat.COLOR_TRANSFER_ST2084) { } else if (colorTransfer == MediaFormat.COLOR_TRANSFER_ST2084) {

View file

@ -413,7 +413,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
} else { } else {
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(id); TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(id);
TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(id); TLRPC.ChatFull chatFull = MessagesController.getInstance(currentAccount).getChatFull(id);
if (chatFull != null && chatFull.participants != null && !chatFull.participants.participants.isEmpty()) { if (chatFull != null && chatFull.participants != null && chatFull.participants.participants != null && !chatFull.participants.participants.isEmpty() && chatFull.participants.participants.size() >= (chatFull.participants_count - 1)) {
selectChat(id, chatFull.participants); selectChat(id, chatFull.participants);
} else { } else {
if (progressDialog != null) { if (progressDialog != null) {
@ -427,7 +427,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
storage.getStorageQueue().postRunnable(() -> { storage.getStorageQueue().postRunnable(() -> {
boolean isChannel = ChatObject.isChannel(chat); boolean isChannel = ChatObject.isChannel(chat);
TLRPC.ChatFull info = storage.loadChatInfoInQueue(id, isChannel, true, true, 0); TLRPC.ChatFull info = storage.loadChatInfoInQueue(id, isChannel, true, true, 0);
if (info == null || info.participants == null) { if (info == null || info.participants == null || info.participants.participants != null && info.participants.participants.size() < (info.participants_count - 1)) {
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
if (isChannel) { if (isChannel) {
MessagesController.getInstance(currentAccount).loadChannelParticipants(id, participants -> { MessagesController.getInstance(currentAccount).loadChannelParticipants(id, participants -> {
@ -1599,7 +1599,11 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
ItemInner item = items.get(position); ItemInner item = items.get(position);
UserCell cell = (UserCell) child; UserCell cell = (UserCell) child;
cell.setChecked(item.checked || item.halfChecked, animated); cell.setChecked(item.checked || item.halfChecked, animated);
cell.setCheckboxAlpha(item.halfChecked && !item.checked ? .5f : 1f, animated); if (item.chat != null) {
cell.setCheckboxAlpha(getParticipantsCount(item.chat) > 200 ? .3f : 1f, animated);
} else {
cell.setCheckboxAlpha(item.halfChecked && !item.checked ? .5f : 1f, animated);
}
} }
} }
@ -1929,6 +1933,8 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
smallChatsParticipantsCount.putAll(participantsCountByChat); smallChatsParticipantsCount.putAll(participantsCountByChat);
}); });
}); });
MessagesController.getInstance(currentAccount).getStoriesController().loadBlocklist(false);
} }
private void init(Context context) { private void init(Context context) {
@ -2499,7 +2505,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
} }
} else if (includeSmallChats && DialogObject.isChatDialog(dialog.id)) { } else if (includeSmallChats && DialogObject.isChatDialog(dialog.id)) {
TLRPC.Chat chat = messagesController.getChat(-dialog.id); TLRPC.Chat chat = messagesController.getChat(-dialog.id);
if (chat == null || ChatObject.isForum(chat) || ChatObject.isChannelAndNotMegaGroup(chat)) { if (chat == null || ChatObject.isChannelAndNotMegaGroup(chat)) {
continue; continue;
} }
// int participants_count = getParticipantsCount(chat); // int participants_count = getParticipantsCount(chat);
@ -2583,7 +2589,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
avatarDrawable.setRoundRadius(AndroidUtilities.dp(40)); avatarDrawable.setRoundRadius(AndroidUtilities.dp(40));
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(40)); imageView.setRoundRadius(AndroidUtilities.dp(20));
addView(imageView, LayoutHelper.createFrame(40, 40, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 53, 0, 53, 0)); addView(imageView, LayoutHelper.createFrame(40, 40, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 53, 0, 53, 0));
titleTextView = new SimpleTextView(context); titleTextView = new SimpleTextView(context);
@ -2651,6 +2657,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
public void setUser(TLRPC.User user) { public void setUser(TLRPC.User user) {
avatarDrawable.setInfo(user); avatarDrawable.setInfo(user);
imageView.setRoundRadius(dp(20));
imageView.setForUserOrChat(user, avatarDrawable); imageView.setForUserOrChat(user, avatarDrawable);
CharSequence text = UserObject.getUserName(user); CharSequence text = UserObject.getUserName(user);
@ -2667,6 +2674,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
public void setChat(TLRPC.Chat chat, int participants_count) { public void setChat(TLRPC.Chat chat, int participants_count) {
avatarDrawable.setInfo(chat); avatarDrawable.setInfo(chat);
imageView.setRoundRadius(dp(ChatObject.isForum(chat) ? 12 : 20));
imageView.setForUserOrChat(chat, avatarDrawable); imageView.setForUserOrChat(chat, avatarDrawable);
CharSequence text = chat.title; CharSequence text = chat.title;
@ -2778,6 +2786,7 @@ public class StoryPrivacyBottomSheet extends BottomSheet implements Notification
checkBox.setVisibility(View.GONE); checkBox.setVisibility(View.GONE);
radioButton.setVisibility(View.VISIBLE); radioButton.setVisibility(View.VISIBLE);
imageView.setImageDrawable(avatarDrawable); imageView.setImageDrawable(avatarDrawable);
imageView.setRoundRadius(dp(20));
} }
private void setSubtitle(CharSequence text) { private void setSubtitle(CharSequence text) {

View file

@ -1609,6 +1609,9 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
@Override @Override
protected boolean captionLimitToast() { protected boolean captionLimitToast() {
if (MessagesController.getInstance(currentAccount).premiumLocked) {
return false;
}
Bulletin visibleBulletin = Bulletin.getVisibleBulletin(); Bulletin visibleBulletin = Bulletin.getVisibleBulletin();
if (visibleBulletin != null && visibleBulletin.tag == 2) { if (visibleBulletin != null && visibleBulletin.tag == 2) {
return false; return false;
@ -2108,9 +2111,9 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
if (storyEntry == null || previewView.getWidth() <= 0 || previewView.getHeight() <= 0) { if (storyEntry == null || previewView.getWidth() <= 0 || previewView.getHeight() <= 0) {
return null; return null;
} }
if (!forDraft && !storyEntry.wouldBeVideo() && !storyEntry.isEdit) { // if (!forDraft && !storyEntry.wouldBeVideo() && !storyEntry.isEdit) {
return null; // return null;
} // }
File file = forDraft ? storyEntry.draftThumbFile : storyEntry.uploadThumbFile; File file = forDraft ? storyEntry.draftThumbFile : storyEntry.uploadThumbFile;
if (file != null) { if (file != null) {
file.delete(); file.delete();
@ -3069,7 +3072,7 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
// privacySelector.setStoryPeriod(outputEntry == null || !UserConfig.getInstance(currentAccount).isPremium() ? 86400 : outputEntry.period); // privacySelector.setStoryPeriod(outputEntry == null || !UserConfig.getInstance(currentAccount).isPremium() ? 86400 : outputEntry.period);
captionEdit.setPeriod(outputEntry == null ? 86400 : outputEntry.period, false); captionEdit.setPeriod(outputEntry == null ? 86400 : outputEntry.period, false);
captionEdit.setPeriodVisible(outputEntry == null || !outputEntry.isEdit); captionEdit.setPeriodVisible(!MessagesController.getInstance(currentAccount).premiumLocked && (outputEntry == null || !outputEntry.isEdit));
} }
if (toPage == PAGE_PREVIEW) { if (toPage == PAGE_PREVIEW) {
videoError = false; videoError = false;
@ -3224,11 +3227,14 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
createFilterPhotoView(); createFilterPhotoView();
// animatePhotoFilterTexture(true, animated); // animatePhotoFilterTexture(true, animated);
previewTouchable = photoFilterView; previewTouchable = photoFilterView;
photoFilterView.getToolsView().setAlpha(0f); View toolsView = photoFilterView != null ? photoFilterView.getToolsView() : null;
photoFilterView.getToolsView().setVisibility(View.VISIBLE); if (toolsView != null) {
animators.add(ObjectAnimator.ofFloat(photoFilterView.getToolsView(), View.TRANSLATION_Y, 0)); toolsView.setAlpha(0f);
animators.add(ObjectAnimator.ofFloat(photoFilterView.getToolsView(), View.ALPHA, 1)); toolsView.setVisibility(View.VISIBLE);
TextureView textureView = photoFilterView.getMyTextureView(); animators.add(ObjectAnimator.ofFloat(toolsView, View.TRANSLATION_Y, 0));
animators.add(ObjectAnimator.ofFloat(toolsView, View.ALPHA, 1));
}
TextureView textureView = photoFilterView != null ? photoFilterView.getMyTextureView() : null;
if (textureView != null) { if (textureView != null) {
animators.add(ObjectAnimator.ofFloat(textureView, View.ALPHA, 1)); animators.add(ObjectAnimator.ofFloat(textureView, View.ALPHA, 1));
} }

View file

@ -62,6 +62,7 @@
<string name="CancelLinkSuccess">The deletion process was cancelled for your account %1$s. You may close this window now.</string> <string name="CancelLinkSuccess">The deletion process was cancelled for your account %1$s. You may close this window now.</string>
<string name="OtherLoginCode">Your login code is **%1$s**. Enter it in the Telegram app where you are trying to log in.\n\nDo not give this code to anyone.</string> <string name="OtherLoginCode">Your login code is **%1$s**. Enter it in the Telegram app where you are trying to log in.\n\nDo not give this code to anyone.</string>
<string name="SmsAvailableIn">You can request an SMS in %1$d:%2$02d</string> <string name="SmsAvailableIn">You can request an SMS in %1$d:%2$02d</string>
<string name="ResendSmsAvailableIn">You can request a new SMS in %1$d:%2$02d</string>
<string name="RequestSmsButton">Get the code via SMS</string> <string name="RequestSmsButton">Get the code via SMS</string>
<string name="CallAvailableIn">You can request a voice call in %1$d:%2$02d</string> <string name="CallAvailableIn">You can request a voice call in %1$d:%2$02d</string>
<string name="RequestCallButton">Call me to dictate the code</string> <string name="RequestCallButton">Call me to dictate the code</string>
@ -6685,6 +6686,10 @@
<string name="StoryUploadError">Uploading story error</string> <string name="StoryUploadError">Uploading story error</string>
<string name="MyStory">My Story</string> <string name="MyStory">My Story</string>
<string name="UploadingStory">Uploading…</string> <string name="UploadingStory">Uploading…</string>
<string name="FailedStory">Failed</string>
<string name="FailedToUploadStory">failed to upload</string>
<string name="StoryError">Couldnt upload</string>
<string name="TryAgain">Try Again</string>
<string name="Story">Story</string> <string name="Story">Story</string>
<string name="MessageSent">Message sent.</string> <string name="MessageSent">Message sent.</string>
<string name="RightNow">Just now</string> <string name="RightNow">Just now</string>
@ -7100,7 +7105,7 @@
<string name="Likes_many">%d likes</string> <string name="Likes_many">%d likes</string>
<string name="Likes_other">%d likes</string> <string name="Likes_other">%d likes</string>
<string name="LimitReachedStoriesCount">You can post **%1$d** stories in **24** hours.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string> <string name="LimitReachedStoriesCount">You can post **%1$d** stories in **24** hours.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string>
<string name="LimitReachedStoriesCountPremium">Sorry, you cant post more than **%1$d** stories.</string> <string name="LimitReachedStoriesCountPremium">Sorry, you cant post more than **%1$d** stories in **24** hours.</string>
<string name="LimitReachedStoriesWeekly">You can post **%1$d** stories in a week.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string> <string name="LimitReachedStoriesWeekly">You can post **%1$d** stories in a week.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string>
<string name="LimitReachedStoriesWeeklyPremium">Sorry, you cant post more than **%1$d** stories in a week.</string> <string name="LimitReachedStoriesWeeklyPremium">Sorry, you cant post more than **%1$d** stories in a week.</string>
<string name="LimitReachedStoriesMonthly">You can post **%1$d** stories in a month.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string> <string name="LimitReachedStoriesMonthly">You can post **%1$d** stories in a month.\nSubscribe to **Telegram Premium** to increase this limit to **%2$d**.</string>

View file

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