mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-05 23:51:00 +00:00
Update to 6.0.0 (1908)
This commit is contained in:
parent
df90eface5
commit
80c4acfa3b
1160 changed files with 237084 additions and 5423 deletions
|
|
@ -782,7 +782,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
}
|
||||
|
||||
private class CounterView extends View {
|
||||
private static class CounterView extends View {
|
||||
|
||||
private StaticLayout staticLayout;
|
||||
private TextPaint textPaint;
|
||||
|
|
@ -1048,6 +1048,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
public boolean isEvent;
|
||||
public ClippingImageView animatingImageView;
|
||||
public int animatingImageViewYOffset;
|
||||
public boolean allowTakeAnimation = true;
|
||||
}
|
||||
|
||||
public static class EmptyPhotoViewerProvider implements PhotoViewerProvider {
|
||||
|
|
@ -1371,9 +1372,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
} else if (child == cameraItem || child == pickerView || child == pickerViewSendButton || child == captionTextView || muteItem.getVisibility() == VISIBLE && child == bottomLayout) {
|
||||
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? captionEditText.getEmojiPadding() : 0;
|
||||
if (captionEditText.isPopupShowing() || AndroidUtilities.usingHardwareInput && captionEditText.getTag() != null || getKeyboardHeight() > AndroidUtilities.dp(80) || paddingBottom != 0) {
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.d("keyboard height = " + getKeyboardHeight() + " padding = " + paddingBottom);
|
||||
}
|
||||
bottomTouchEnabled = false;
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -2141,7 +2139,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
disableShowCheck = true;
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putLong("dialog_id", currentDialogId);
|
||||
MediaActivity mediaActivity = new MediaActivity(args2, new int[]{-1, -1, -1, -1, -1}, null, sharedMediaType);
|
||||
MediaActivity mediaActivity = new MediaActivity(args2, new int[]{-1, -1, -1, -1, -1, -1}, null, sharedMediaType);
|
||||
if (parentChatActivity != null) {
|
||||
mediaActivity.setChatInfo(parentChatActivity.getCurrentChatInfo());
|
||||
}
|
||||
|
|
@ -2393,8 +2391,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
onSharePressed();
|
||||
} else if (id == gallery_menu_openin) {
|
||||
try {
|
||||
AndroidUtilities.openForView(currentMessageObject, parentActivity);
|
||||
closePhoto(false, false);
|
||||
if (AndroidUtilities.openForView(currentMessageObject, parentActivity)) {
|
||||
closePhoto(false, false);
|
||||
} else {
|
||||
showDownloadAlert();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
|
|
@ -2429,8 +2430,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
@Override
|
||||
public boolean canOpenMenu() {
|
||||
if (currentMessageObject != null) {
|
||||
File f = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
return f.exists();
|
||||
return true;
|
||||
} else if (currentFileLocation != null) {
|
||||
File f = FileLoader.getPathToAttach(getFileLocation(currentFileLocation), avatarsDialogId != 0 || isEvent);
|
||||
return f.exists();
|
||||
|
|
@ -3170,7 +3170,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
gestureDetector.setIsLongpressEnabled(false);
|
||||
setDoubleTapEnabled(true);
|
||||
|
||||
ImageReceiver.ImageReceiverDelegate imageReceiverDelegate = (imageReceiver, set, thumb) -> {
|
||||
ImageReceiver.ImageReceiverDelegate imageReceiverDelegate = (imageReceiver, set, thumb, memCache) -> {
|
||||
if (imageReceiver == centerImage && set && !thumb && (currentEditMode == 1 || sendPhotoType == SELECT_TYPE_AVATAR) && photoCropView != null) {
|
||||
Bitmap bitmap = imageReceiver.getBitmap();
|
||||
if (bitmap != null) {
|
||||
|
|
@ -4664,7 +4664,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (currentEditMode == 1) {
|
||||
float scaleX = photoCropView.getRectSizeX() / (float) getContainerViewWidth();
|
||||
float scaleY = photoCropView.getRectSizeY() / (float) getContainerViewHeight();
|
||||
scale = scaleX > scaleY ? scaleX : scaleY;
|
||||
scale = Math.max(scaleX, scaleY);
|
||||
translationX = photoCropView.getRectX() + photoCropView.getRectSizeX() / 2 - getContainerViewWidth() / 2;
|
||||
translationY = photoCropView.getRectY() + photoCropView.getRectSizeY() / 2 - getContainerViewHeight() / 2;
|
||||
zoomAnimation = true;
|
||||
|
|
@ -4736,8 +4736,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float newScaleX = (float) getContainerViewWidth(0) / (float) bitmapWidth;
|
||||
float newScaleY = (float) getContainerViewHeight(0) / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float newScale = newScaleX > newScaleY ? newScaleY : newScaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
float newScale = Math.min(newScaleX, newScaleY);
|
||||
|
||||
if (sendPhotoType == SELECT_TYPE_AVATAR) {
|
||||
setCropTranslations(true);
|
||||
|
|
@ -4906,13 +4906,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float newScaleX = (float) getContainerViewWidth(1) / (float) bitmapWidth;
|
||||
float newScaleY = (float) getContainerViewHeight(1) / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float newScale = newScaleX > newScaleY ? newScaleY : newScaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
float newScale = Math.min(newScaleX, newScaleY);
|
||||
if (sendPhotoType == SELECT_TYPE_AVATAR) {
|
||||
float minSide = Math.min(getContainerViewWidth(1), getContainerViewHeight(1));
|
||||
newScaleX = minSide / (float) bitmapWidth;
|
||||
newScaleY = minSide / (float) bitmapHeight;
|
||||
newScale = newScaleX > newScaleY ? newScaleX : newScaleY;
|
||||
newScale = Math.max(newScaleX, newScaleY);
|
||||
}
|
||||
|
||||
animateToScale = newScale / scale;
|
||||
|
|
@ -5057,8 +5057,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float newScaleX = (float) getContainerViewWidth(2) / (float) bitmapWidth;
|
||||
float newScaleY = (float) getContainerViewHeight(2) / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float newScale = newScaleX > newScaleY ? newScaleY : newScaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
float newScale = Math.min(newScaleX, newScaleY);
|
||||
|
||||
animateToScale = newScale / scale;
|
||||
animateToX = getLeftInset() / 2 - getRightInset() / 2;
|
||||
|
|
@ -5166,8 +5166,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float newScaleX = (float) getContainerViewWidth(3) / (float) bitmapWidth;
|
||||
float newScaleY = (float) getContainerViewHeight(3) / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float newScale = newScaleX > newScaleY ? newScaleY : newScaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
float newScale = Math.min(newScaleX, newScaleY);
|
||||
|
||||
animateToScale = newScale / scale;
|
||||
animateToX = getLeftInset() / 2 - getRightInset() / 2;
|
||||
|
|
@ -5513,16 +5513,20 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
} else if (message.messageOwner.media instanceof TLRPC.TL_messageMediaInvoice) {
|
||||
return ImageLocation.getForWebFile(WebFile.createWithWebDocument(((TLRPC.TL_messageMediaInvoice) message.messageOwner.media).photo));
|
||||
} else if (message.getDocument() != null && MessageObject.isDocumentHasThumb(message.getDocument())) {
|
||||
} else if (message.getDocument() != null) {
|
||||
TLRPC.Document document = message.getDocument();
|
||||
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
|
||||
if (size != null) {
|
||||
size[0] = thumb.size;
|
||||
if (size[0] == 0) {
|
||||
size[0] = -1;
|
||||
if (sharedMediaType == MediaDataController.MEDIA_GIF) {
|
||||
return ImageLocation.getForDocument(document);
|
||||
} else if (MessageObject.isDocumentHasThumb(message.getDocument())) {
|
||||
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90);
|
||||
if (size != null) {
|
||||
size[0] = thumb.size;
|
||||
if (size[0] == 0) {
|
||||
size[0] = -1;
|
||||
}
|
||||
}
|
||||
return ImageLocation.getForDocument(thumb, document);
|
||||
}
|
||||
return ImageLocation.getForDocument(thumb, document);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -5771,6 +5775,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (messageObject.canPreviewDocument()) {
|
||||
sharedMediaType = MediaDataController.MEDIA_FILE;
|
||||
allMediaItem.setText(LocaleController.getString("ShowAllFiles", R.string.ShowAllFiles));
|
||||
} else if (messageObject.isGif()) {
|
||||
sharedMediaType = MediaDataController.MEDIA_GIF;
|
||||
allMediaItem.setText(LocaleController.getString("ShowAllGIFs", R.string.ShowAllGIFs));
|
||||
}
|
||||
if (slideshowMessageId == 0) {
|
||||
imagesArr.add(messageObject);
|
||||
|
|
@ -5832,6 +5839,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (openingObject.canPreviewDocument()) {
|
||||
sharedMediaType = MediaDataController.MEDIA_FILE;
|
||||
allMediaItem.setText(LocaleController.getString("ShowAllFiles", R.string.ShowAllFiles));
|
||||
} else if (openingObject.isGif()) {
|
||||
sharedMediaType = MediaDataController.MEDIA_GIF;
|
||||
allMediaItem.setText(LocaleController.getString("ShowAllGIFs", R.string.ShowAllGIFs));
|
||||
}
|
||||
} else {
|
||||
totalImagesCount = imagesArr.size();
|
||||
|
|
@ -7127,12 +7137,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
float scaleX = (float) getContainerViewWidth() / (float) bitmapWidth;
|
||||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float scaleFinal = scaleX > scaleY ? scaleY : scaleX;
|
||||
float scaleFinal = Math.min(scaleX, scaleY);
|
||||
|
||||
float minSide = Math.min(getContainerViewWidth(1), getContainerViewHeight(1));
|
||||
float newScaleX = minSide / (float) bitmapWidth;
|
||||
float newScaleY = minSide / (float) bitmapHeight;
|
||||
float newScale = newScaleX > newScaleY ? newScaleX : newScaleY;
|
||||
float newScale = Math.max(newScaleX, newScaleY);
|
||||
|
||||
if (animated) {
|
||||
animationStartTime = System.currentTimeMillis();
|
||||
|
|
@ -7270,7 +7280,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
disableShowCheck = true;
|
||||
animationInProgress = 1;
|
||||
if (messageObject != null) {
|
||||
currentAnimation = object.imageReceiver.getAnimation();
|
||||
currentAnimation = object.allowTakeAnimation ? object.imageReceiver.getAnimation() : null;
|
||||
if (currentAnimation != null) {
|
||||
if (messageObject.isVideo()) {
|
||||
object.imageReceiver.setAllowStartAnimation(false);
|
||||
|
|
@ -7374,7 +7384,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
} else {
|
||||
scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width;
|
||||
scaleY = (float) (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height;
|
||||
scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
scale = Math.min(scaleX, scaleY);
|
||||
yPos = ((AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) - (layoutParams.height * scale)) / 2.0f;
|
||||
xPos = (windowView.getMeasuredWidth() - layoutParams.width * scale) / 2.0f;
|
||||
}
|
||||
|
|
@ -7636,7 +7646,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
}
|
||||
}
|
||||
animation.seekTo(videoPlayer.getCurrentPosition(), !FileLoader.getInstance(currentMessageObject.currentAccount).isLoadingVideo(currentMessageObject.getDocument(), true));
|
||||
if (currentMessageObject != null) {
|
||||
animation.seekTo(videoPlayer.getCurrentPosition(), !FileLoader.getInstance(currentMessageObject.currentAccount).isLoadingVideo(currentMessageObject.getDocument(), true));
|
||||
}
|
||||
object.imageReceiver.setAllowStartAnimation(true);
|
||||
object.imageReceiver.startAnimation();
|
||||
}
|
||||
|
|
@ -7705,7 +7717,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
float scaleX = (float) windowView.getMeasuredWidth() / layoutParams.width;
|
||||
float scaleY = (float) (AndroidUtilities.displaySize.y + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)) / layoutParams.height;
|
||||
float scale2 = scaleX > scaleY ? scaleY : scaleX;
|
||||
float scale2 = Math.min(scaleX, scaleY);
|
||||
float width = layoutParams.width * scale * scale2;
|
||||
float height = layoutParams.height * scale * scale2;
|
||||
float xPos = (windowView.getMeasuredWidth() - width) / 2.0f;
|
||||
|
|
@ -8513,7 +8525,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
float scaleX = (float) getContainerViewWidth() / (float) bitmapWidth;
|
||||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
int width = (int) (bitmapWidth * scale);
|
||||
int height = (int) (bitmapHeight * scale);
|
||||
|
||||
|
|
@ -8561,7 +8573,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
float scaleX = (float) getContainerViewWidth() / (float) bitmapWidth;
|
||||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
int width = (int) (bitmapWidth * scale);
|
||||
int height = (int) (bitmapHeight * scale);
|
||||
|
||||
|
|
@ -8573,7 +8585,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
if (drawTextureView) {
|
||||
scaleX = (float) canvas.getWidth() / (float) bitmapWidth;
|
||||
scaleY = (float) canvas.getHeight() / (float) bitmapHeight;
|
||||
scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
scale = Math.min(scaleX, scaleY);
|
||||
height = (int) (bitmapHeight * scale);
|
||||
if (!videoCrossfadeStarted && textureUploaded) {
|
||||
videoCrossfadeStarted = true;
|
||||
|
|
@ -8655,7 +8667,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
|
||||
float scaleX = (float) getContainerViewWidth() / (float) bitmapWidth;
|
||||
float scaleY = (float) getContainerViewHeight() / (float) bitmapHeight;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
int width = (int) (bitmapWidth * scale);
|
||||
int height = (int) (bitmapHeight * scale);
|
||||
|
||||
|
|
@ -8812,7 +8824,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
public boolean onDown(MotionEvent e) {
|
||||
if (!doubleTap && checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) {
|
||||
float x = e.getX();
|
||||
int side = containerView.getMeasuredWidth() / 6;
|
||||
int side = Math.min(135, containerView.getMeasuredWidth() / 8);
|
||||
if (x < side) {
|
||||
if (leftImage.hasImageSet()) {
|
||||
drawPressedDrawable[0] = true;
|
||||
|
|
@ -8832,9 +8844,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
public boolean canDoubleTap(MotionEvent e) {
|
||||
if (checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) {
|
||||
float x = e.getX();
|
||||
int side = containerView.getMeasuredWidth() / 6;
|
||||
int side = Math.min(135, containerView.getMeasuredWidth() / 8);
|
||||
if (x < side || x > containerView.getMeasuredWidth() - side) {
|
||||
return currentMessageObject == null || currentMessageObject.isVideo() && (SystemClock.elapsedRealtime() - lastPhotoSetTime) >= 500;
|
||||
return currentMessageObject == null || currentMessageObject.isVideo() && (SystemClock.elapsedRealtime() - lastPhotoSetTime) >= 500 && canDoubleTapSeekVideo(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
@ -8890,7 +8902,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
}
|
||||
float x = e.getX();
|
||||
if (checkImageView.getVisibility() != View.VISIBLE) {
|
||||
int side = containerView.getMeasuredWidth() / 6;
|
||||
int side = Math.min(135, containerView.getMeasuredWidth() / 8);
|
||||
if (x < side) {
|
||||
if (leftImage.hasImageSet()) {
|
||||
switchToNextIndex(-1, true);
|
||||
|
|
@ -8953,14 +8965,27 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
|||
return true;
|
||||
}
|
||||
|
||||
private boolean canDoubleTapSeekVideo(MotionEvent e) {
|
||||
if (videoPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
int width = getContainerViewWidth();
|
||||
float x = e.getX();
|
||||
boolean forward = x >= width / 3 * 2;
|
||||
long current = videoPlayer.getCurrentPosition();
|
||||
long total = videoPlayer.getDuration();
|
||||
return current != C.TIME_UNSET && total > 15 * 1000 && (!forward || total - current > 10000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
if (videoPlayer != null && videoPlayerControlFrameLayout.getVisibility() == View.VISIBLE) {
|
||||
long current = videoPlayer.getCurrentPosition();
|
||||
long total = videoPlayer.getDuration();
|
||||
if (total >= 0 && current >= 0 && total != C.TIME_UNSET && current != C.TIME_UNSET) {
|
||||
int width = getContainerViewWidth();
|
||||
float x = e.getX();
|
||||
float x = e.getX();
|
||||
int width = getContainerViewWidth();
|
||||
boolean forward = x >= width / 3 * 2;
|
||||
if (canDoubleTapSeekVideo(e)) {
|
||||
long old = current;
|
||||
if (x >= width / 3 * 2) {
|
||||
current += 10000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue