From dae819b5a3d1ec89312385f6e7eedcd7866e82fd Mon Sep 17 00:00:00 2001 From: DrKLO Date: Fri, 14 Feb 2020 20:15:39 +0300 Subject: [PATCH] Update to 5.15.0 (1868) --- TMessagesProj/build.gradle | 2 +- .../org/telegram/messenger/BuildVars.java | 2 +- .../org/telegram/messenger/EmojiData.java | 6 +- .../messenger/LocationController.java | 9 +- .../messenger/MediaDataController.java | 6 + .../org/telegram/messenger/UserConfig.java | 4 + .../java/org/telegram/ui/ArticleViewer.java | 35 ++++- .../telegram/ui/Cells/ChatMessageCell.java | 7 +- .../telegram/ui/Cells/SharedAudioCell.java | 2 +- .../ui/Components/GestureDetector2.java | 140 +++--------------- .../ui/Components/SharedMediaLayout.java | 85 ++++++++--- .../org/telegram/ui/PeopleNearbyActivity.java | 20 ++- .../java/org/telegram/ui/PhotoViewer.java | 20 ++- .../java/org/telegram/ui/ProfileActivity.java | 7 +- 14 files changed, 180 insertions(+), 165 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index f10a0f2d6..b5a03a11d 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -283,7 +283,7 @@ android { } } - defaultConfig.versionCode = 1867 + defaultConfig.versionCode = 1868 applicationVariants.all { variant -> variant.outputs.all { output -> diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 25c8e7b3a..e40f47417 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -19,7 +19,7 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean TON_WALLET_STANDALONE = false; - public static int BUILD_VERSION = 1867; + public static int BUILD_VERSION = 1868; public static String BUILD_VERSION_STRING = "5.15.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java b/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java index bee8c32a6..e0a6ef5f8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/EmojiData.java @@ -429,7 +429,8 @@ public class EmojiData { "๐Ÿง˜", "๐Ÿง˜๐Ÿป", "๐Ÿง˜๐Ÿผ", "๐Ÿง˜๐Ÿฝ", "๐Ÿง˜๐Ÿพ", "๐Ÿง˜๐Ÿฟ", "๐Ÿคฝ", "๐Ÿคฝ๐Ÿป", "๐Ÿคฝ๐Ÿผ", "๐Ÿคฝ๐Ÿฝ", "๐Ÿคฝ๐Ÿพ", "๐Ÿคฝ๐Ÿฟ", "๐Ÿง—", "๐Ÿง—๐Ÿป", "๐Ÿง—๐Ÿผ", "๐Ÿง—๐Ÿฝ", "๐Ÿง—๐Ÿพ", "๐Ÿง—๐Ÿฟ", - "๐Ÿคน", "๐Ÿคน๐Ÿป", "๐Ÿคน๐Ÿผ", "๐Ÿคน๐Ÿฝ", "๐Ÿคน๐Ÿพ", "๐Ÿคน๐Ÿฟ"}; + "๐Ÿคน", "๐Ÿคน๐Ÿป", "๐Ÿคน๐Ÿผ", "๐Ÿคน๐Ÿฝ", "๐Ÿคน๐Ÿพ", "๐Ÿคน๐Ÿฟ", + "\uD83D\uDC91"}; public static final String[] aliasNew = new String[] { "๐Ÿ‘ฑโ€โ™‚", "๐Ÿ‘ฑ๐Ÿปโ€โ™‚", "๐Ÿ‘ฑ๐Ÿผโ€โ™‚", "๐Ÿ‘ฑ๐Ÿฝโ€โ™‚", "๐Ÿ‘ฑ๐Ÿพโ€โ™‚", "๐Ÿ‘ฑ๐Ÿฟโ€โ™‚", @@ -477,7 +478,8 @@ public class EmojiData { "๐Ÿง˜โ€โ™€", "๐Ÿง˜๐Ÿปโ€โ™€", "๐Ÿง˜๐Ÿผโ€โ™€", "๐Ÿง˜๐Ÿฝโ€โ™€", "๐Ÿง˜๐Ÿพโ€โ™€", "๐Ÿง˜๐Ÿฟโ€โ™€", "๐Ÿคฝโ€โ™‚", "๐Ÿคฝ๐Ÿปโ€โ™‚", "๐Ÿคฝ๐Ÿผโ€โ™‚", "๐Ÿคฝ๐Ÿฝโ€โ™‚", "๐Ÿคฝ๐Ÿพโ€โ™‚", "๐Ÿคฝ๐Ÿฟโ€โ™‚", "๐Ÿง—โ€โ™‚", "๐Ÿง—๐Ÿปโ€โ™‚", "๐Ÿง—๐Ÿผโ€โ™‚", "๐Ÿง—๐Ÿฝโ€โ™‚", "๐Ÿง—๐Ÿพโ€โ™‚", "๐Ÿง—๐Ÿฟโ€โ™‚", - "๐Ÿคนโ€โ™‚", "๐Ÿคน๐Ÿปโ€โ™‚", "๐Ÿคน๐Ÿผโ€โ™‚", "๐Ÿคน๐Ÿฝโ€โ™‚", "๐Ÿคน๐Ÿพโ€โ™‚", "๐Ÿคน๐Ÿฟโ€โ™‚"}; + "๐Ÿคนโ€โ™‚", "๐Ÿคน๐Ÿปโ€โ™‚", "๐Ÿคน๐Ÿผโ€โ™‚", "๐Ÿคน๐Ÿฝโ€โ™‚", "๐Ÿคน๐Ÿพโ€โ™‚", "๐Ÿคน๐Ÿฟโ€โ™‚", + "๐Ÿ‘ฉโ€โคโ€๐Ÿ‘จ"}; public static final String[][] data = { new String[]{ diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java index a69befd7c..ddaf5104f 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocationController.java @@ -289,7 +289,11 @@ public class LocationController extends BaseController implements NotificationCe startFusedLocationRequest(true); break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: - AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.needShowPlayServicesAlert, status)); + Utilities.stageQueue.postRunnable(() -> { + if (lookingForPeopleNearby || !sharingLocations.isEmpty()) { + AndroidUtilities.runOnUIThread(() -> getNotificationCenter().postNotificationName(NotificationCenter.needShowPlayServicesAlert, status)); + } + }); break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: Utilities.stageQueue.postRunnable(() -> { @@ -468,7 +472,8 @@ public class LocationController extends BaseController implements NotificationCe protected void update() { UserConfig userConfig = getUserConfig(); - if (ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePaused && !shareMyCurrentLocation && userConfig.sharingMyLocationUntil != 0 && Math.abs(System.currentTimeMillis() / 1000 - userConfig.lastMyLocationShareTime) >= 60 * 60) { + if (ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePaused && !shareMyCurrentLocation && + userConfig.isClientActivated() && userConfig.isConfigLoaded() && userConfig.sharingMyLocationUntil != 0 && Math.abs(System.currentTimeMillis() / 1000 - userConfig.lastMyLocationShareTime) >= 60 * 60) { shareMyCurrentLocation = true; } if (!sharingLocations.isEmpty()) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java index 85068d96b..59df69568 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaDataController.java @@ -1829,6 +1829,9 @@ public class MediaDataController extends BaseController { public void loadMedia(final long uid, final int count, final int max_id, final int type, final int fromCache, final int classGuid) { final boolean isChannel = (int) uid < 0 && ChatObject.isChannel(-(int) uid, currentAccount); + if (BuildVars.DEBUG_VERSION) { + FileLog.d("load media did " + uid + " count = " + count + " max_id " + max_id + " type = " + type + " cache = " + fromCache + " classGuid = " + classGuid); + } int lower_part = (int)uid; if (fromCache != 0 || lower_part == 0) { loadMediaDatabase(uid, count, max_id, type, classGuid, isChannel, fromCache); @@ -2057,6 +2060,9 @@ public class MediaDataController extends BaseController { } private void processLoadedMedia(final TLRPC.messages_Messages res, final long uid, int count, int max_id, final int type, final int fromCache, final int classGuid, final boolean isChannel, final boolean topReached) { + if (BuildVars.DEBUG_VERSION) { + FileLog.d("process load media did " + uid + " count = " + count + " max_id " + max_id + " type = " + type + " cache = " + fromCache + " classGuid = " + classGuid); + } int lower_part = (int)uid; if (fromCache != 0 && res.messages.isEmpty() && lower_part != 0) { if (fromCache == 2) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java index 24767d54d..25577dbc6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java @@ -397,6 +397,10 @@ public class UserConfig extends BaseController { } } + public boolean isConfigLoaded() { + return configLoaded; + } + public void savePassword(byte[] hash, byte[] salted) { savedPasswordTime = SystemClock.elapsedRealtime(); savedPasswordHash = hash; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java index ff3d02a88..f6f6d0353 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java @@ -1116,12 +1116,14 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg pressedLinkOwnerView.invalidate(); } } else if (pressedLinkOwnerView != null && textSelectionHelper.isSelectable(pressedLinkOwnerView)) { - windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); if (pressedLinkOwnerView.getTag() != null && pressedLinkOwnerView.getTag() == BOTTOM_SHEET_VIEW_TAG && textSelectionHelperBottomSheet != null) { textSelectionHelperBottomSheet.trySelect(pressedLinkOwnerView); } else { textSelectionHelper.trySelect(pressedLinkOwnerView); } + if (textSelectionHelper.isSelectionMode()) { + windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } } else if (pressedLinkOwnerLayout != null && pressedLinkOwnerView != null) { windowView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); @@ -1634,7 +1636,9 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg } else { layoutManager[index].scrollToPositionWithOffset(0, 0); } - checkScrollAnimated(); + if (!previous) { + checkScrollAnimated(); + } } private boolean addPageToStack(TLRPC.WebPage webPage, String anchor, int order) { @@ -7744,6 +7748,14 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg return intercept; } + @Override + public boolean onTouchEvent(MotionEvent ev) { + if (tableLayout.getMeasuredWidth() <= getMeasuredWidth() - AndroidUtilities.dp(36)) { + return false; + } + return super.onTouchEvent(ev); + } + @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); @@ -8631,6 +8643,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg @Override public boolean onInterceptTouchEvent(MotionEvent ev) { windowView.requestDisallowInterceptTouchEvent(true); + cancelCheckLongPress(); return super.onInterceptTouchEvent(ev); } }; @@ -11232,8 +11245,6 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg for (int a = 0, count = textLayout.getLineCount(); a < count; a++) { width = Math.max((int) Math.ceil(textLayout.getLineWidth(a)), width); } - textLayout.x = (int) getX(); - textLayout.y = (int) getY(); } } else { height = 1; @@ -11243,7 +11254,7 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg @Override public boolean onTouchEvent(MotionEvent event) { - return checkLayoutForLinks(parentAdapter, event, this, textLayout, 0, 0) || super.onTouchEvent(event); + return checkLayoutForLinks(parentAdapter, event, BlockPreformattedCell.this, textLayout, 0, 0) || super.onTouchEvent(event); } @Override @@ -11253,6 +11264,8 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg drawTextSelection(canvas, BlockPreformattedCell.this); textLayout.draw(canvas); canvas.restore(); + textLayout.x = (int) getX(); + textLayout.y = (int) getY(); } } }; @@ -11261,6 +11274,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg layoutParams.topMargin = layoutParams.bottomMargin = AndroidUtilities.dp(12); scrollView.addView(textContainer, layoutParams); + scrollView.setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> { + if (textSelectionHelper != null && textSelectionHelper.isSelectionMode()) { + textSelectionHelper.invalidate(); + } + }); + setWillNotDraw(false); } @@ -11291,6 +11310,12 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg blocks.add(textLayout); } } + + @Override + public void invalidate() { + textContainer.invalidate(); + super.invalidate(); + } } private class BlockSubheaderCell extends View implements TextSelectionHelper.ArticleSelectableView{ diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 24910c0ed..f8f127262 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -7241,7 +7241,12 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate buttonState = -1; } else { if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF && currentMessageObject.gifState == 1) { - buttonState = 2; + if (photoImage.isAnimationRunning()) { + currentMessageObject.gifState = 0; + buttonState = -1; + } else { + buttonState = 2; + } } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_VIDEO) { buttonState = 3; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedAudioCell.java index bfe4e672b..4a50b4887 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedAudioCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedAudioCell.java @@ -117,7 +117,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F currentMessageObject = messageObject; TLRPC.Document document = messageObject.getDocument(); - TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90) : null; + TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 240) : null; if (thumb instanceof TLRPC.TL_photoSize) { radialProgress.setImageOverlay(thumb, document, messageObject); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GestureDetector2.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GestureDetector2.java index 24f21ac11..b9461a011 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GestureDetector2.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GestureDetector2.java @@ -34,108 +34,14 @@ public class GestureDetector2 { boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY); void onLongPress(MotionEvent e); boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY); - default int getDoubleTapTimeout(MotionEvent e) { - return DOUBLE_TAP_TIMEOUT; - } } - /** - * The listener that is used to notify when a double-tap or a confirmed - * single-tap occur. - */ public interface OnDoubleTapListener { - /** - * Notified when a single-tap occurs. - *

- * Unlike {@link OnGestureListener#onSingleTapUp(MotionEvent)}, this - * will only be called after the detector is confident that the user's - * first tap is not followed by a second tap leading to a double-tap - * gesture. - * - * @param e The down motion event of the single-tap. - * @return true if the event is consumed, else false - */ boolean onSingleTapConfirmed(MotionEvent e); - - /** - * Notified when a double-tap occurs. - * - * @param e The down motion event of the first tap of the double-tap. - * @return true if the event is consumed, else false - */ boolean onDoubleTap(MotionEvent e); - - /** - * Notified when an event within a double-tap gesture occurs, including - * the down, move, and up events. - * - * @param e The motion event that occurred during the double-tap gesture. - * @return true if the event is consumed, else false - */ boolean onDoubleTapEvent(MotionEvent e); - } - - public interface OnContextClickListener { - /** - * Notified when a context click occurs. - * - * @param e The motion event that occurred during the context click. - * @return true if the event is consumed, else false - */ - boolean onContextClick(MotionEvent e); - } - - /** - * A convenience class to extend when you only want to listen for a subset - * of all the gestures. This implements all methods in the - * {@link OnGestureListener}, {@link OnDoubleTapListener}, and {@link OnContextClickListener} - * but does nothing and return {@code false} for all applicable methods. - */ - public static class SimpleOnGestureListener implements OnGestureListener, OnDoubleTapListener, - OnContextClickListener { - - public boolean onSingleTapUp(MotionEvent e) { - return false; - } - - public void onLongPress(MotionEvent e) { - } - - public boolean onScroll(MotionEvent e1, MotionEvent e2, - float distanceX, float distanceY) { - return false; - } - - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, - float velocityY) { - return false; - } - - public void onShowPress(MotionEvent e) { - } - - public boolean onDown(MotionEvent e) { - return false; - } - - public void onUp(MotionEvent e) { - - } - - public boolean onDoubleTap(MotionEvent e) { - return false; - } - - public boolean onDoubleTapEvent(MotionEvent e) { - return false; - } - - public boolean onSingleTapConfirmed(MotionEvent e) { - return false; - } - - public boolean onContextClick(MotionEvent e) { - return false; + default boolean canDoubleTap(MotionEvent e) { + return true; } } @@ -304,7 +210,6 @@ public class GestureDetector2 { final boolean pointerUp = (action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP; final int skipIndex = pointerUp ? ev.getActionIndex() : -1; - // Determine focal point float sumX = 0, sumY = 0; final int count = ev.getPointerCount(); for (int i = 0; i < count; i++) { @@ -322,7 +227,6 @@ public class GestureDetector2 { case MotionEvent.ACTION_POINTER_DOWN: mDownFocusX = mLastFocusX = focusX; mDownFocusY = mLastFocusY = focusY; - // Cancel long press and taps cancelTaps(); break; @@ -330,8 +234,6 @@ public class GestureDetector2 { mDownFocusX = mLastFocusX = focusX; mDownFocusY = mLastFocusY = focusY; - // Check the dot product of current velocities. - // If the pointer that left was opposing another velocity vector, clear. mVelocityTracker.computeCurrentVelocity(1000, mMaximumFlingVelocity); final int upIndex = ev.getActionIndex(); final int id1 = ev.getPointerId(upIndex); @@ -353,21 +255,20 @@ public class GestureDetector2 { break; case MotionEvent.ACTION_DOWN: + mDeferConfirmSingleTap = false; if (mDoubleTapListener != null) { - boolean hadTapMessage = mHandler.hasMessages(TAP); - if (hadTapMessage) mHandler.removeMessages(TAP); - if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) - && hadTapMessage - && isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { - // This is a second tap - mIsDoubleTapping = true; - // Give a callback with the first tap of the double-tap - handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); - // Give a callback with down event of the double-tap - handled |= mDoubleTapListener.onDoubleTapEvent(ev); + if (mDoubleTapListener.canDoubleTap(ev)) { + boolean hadTapMessage = mHandler.hasMessages(TAP); + if (hadTapMessage) mHandler.removeMessages(TAP); + if ((mCurrentDownEvent != null) && (mPreviousUpEvent != null) && hadTapMessage && isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { + mIsDoubleTapping = true; + handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); + handled |= mDoubleTapListener.onDoubleTapEvent(ev); + } else { + mHandler.sendEmptyMessageDelayed(TAP, DOUBLE_TAP_TIMEOUT); + } } else { - // This is a first tap - mHandler.sendEmptyMessageDelayed(TAP, mListener.getDoubleTapTimeout(ev)); + mDeferConfirmSingleTap = true; } } @@ -381,16 +282,12 @@ public class GestureDetector2 { mAlwaysInBiggerTapRegion = true; mStillDown = true; mInLongPress = false; - mDeferConfirmSingleTap = false; if (mIsLongpressEnabled) { mHandler.removeMessages(LONG_PRESS); - mHandler.sendMessageAtTime( - mHandler.obtainMessage(LONG_PRESS, 0, 0), mCurrentDownEvent.getDownTime() - + ViewConfiguration.getLongPressTimeout()); + mHandler.sendMessageAtTime(mHandler.obtainMessage(LONG_PRESS, 0, 0), mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); } - mHandler.sendEmptyMessageAtTime(SHOW_PRESS, - mCurrentDownEvent.getDownTime() + TAP_TIMEOUT); + mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT); handled |= mListener.onDown(ev); break; @@ -472,8 +369,7 @@ public class GestureDetector2 { final float velocityY = velocityTracker.getYVelocity(pointerId); final float velocityX = velocityTracker.getXVelocity(pointerId); - if ((Math.abs(velocityY) > mMinimumFlingVelocity) - || (Math.abs(velocityX) > mMinimumFlingVelocity)) { + if ((Math.abs(velocityY) > mMinimumFlingVelocity) || (Math.abs(velocityX) > mMinimumFlingVelocity)) { handled = mListener.onFling(mCurrentDownEvent, ev, velocityX, velocityY); } } @@ -534,7 +430,7 @@ public class GestureDetector2 { } final long deltaTime = secondDown.getEventTime() - firstUp.getEventTime(); - if (deltaTime > mListener.getDoubleTapTimeout(firstDown) || deltaTime < DOUBLE_TAP_MIN_TIME) { + if (deltaTime > DOUBLE_TAP_TIMEOUT || deltaTime < DOUBLE_TAP_MIN_TIME) { return false; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java index 9614b1312..5de0fdfa9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java @@ -556,11 +556,13 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter messagesDict[0].remove(oldMid); messagesDict[0].put(newMid, obj); obj.messageOwner.id = newMid; + max_id[0] = Math.min(newMid, max_id[0]); } } } private SharedMediaData[] sharedMediaData = new SharedMediaData[5]; + private SharedMediaPreloader sharedMediaPreloader; private final static int forward = 100; private final static int delete = 101; @@ -577,9 +579,11 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter private boolean isActionModeShowed; - public SharedMediaLayout(Context context, long did, int[] mediaCount, SharedMediaData[] mediaData, int commonGroupsCount, ArrayList sortedUsers, TLRPC.ChatFull chatInfo, ProfileActivity parent) { + public SharedMediaLayout(Context context, long did, SharedMediaPreloader preloader, int commonGroupsCount, ArrayList sortedUsers, TLRPC.ChatFull chatInfo, ProfileActivity parent) { super(context); + sharedMediaPreloader = preloader; + int[] mediaCount = preloader.getLastMediaCount(); hasMedia = new int[]{mediaCount[0], mediaCount[1], mediaCount[2], mediaCount[3], mediaCount[4], commonGroupsCount}; if (chatInfo != null) { initialTab = 6; @@ -599,19 +603,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter for (int a = 0; a < sharedMediaData.length; a++) { sharedMediaData[a] = new SharedMediaData(); sharedMediaData[a].max_id[0] = ((int) dialog_id) == 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE; - if (mediaData != null) { - sharedMediaData[a].totalCount = mediaData[a].totalCount; - sharedMediaData[a].messages.addAll(mediaData[a].messages); - sharedMediaData[a].sections.addAll(mediaData[a].sections); - for (HashMap.Entry> entry : mediaData[a].sectionArrays.entrySet()) { - sharedMediaData[a].sectionArrays.put(entry.getKey(), new ArrayList<>(entry.getValue())); - } - for (int i = 0; i < 2; i++) { - sharedMediaData[a].messagesDict[i] = mediaData[a].messagesDict[i].clone(); - sharedMediaData[a].max_id[i] = mediaData[a].max_id[i]; - sharedMediaData[a].endReached[i] = mediaData[a].endReached[i]; - } - } + fillMediaData(a); if (mergeDialogId != 0 && info != null) { sharedMediaData[a].max_id[1] = info.migrated_from_max_id; sharedMediaData[a].endReached[1] = false; @@ -966,7 +958,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { checkLoadMoreScroll(mediaPage, recyclerView, layoutManager); - if (dy != 0 && mediaPages[0].selectedType == 0 && !mediaData[0].messages.isEmpty()) { + if (dy != 0 && mediaPages[0].selectedType == 0 && !sharedMediaData[0].messages.isEmpty()) { showFloatingDateView(); } } @@ -1069,6 +1061,25 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter switchToCurrentSelectedMode(false); } + private boolean fillMediaData(int type) { + SharedMediaData[] mediaData = sharedMediaPreloader.getSharedMediaData(); + if (mediaData == null) { + return false; + } + sharedMediaData[type].totalCount = mediaData[type].totalCount; + sharedMediaData[type].messages.addAll(mediaData[type].messages); + sharedMediaData[type].sections.addAll(mediaData[type].sections); + for (HashMap.Entry> entry : mediaData[type].sectionArrays.entrySet()) { + sharedMediaData[type].sectionArrays.put(entry.getKey(), new ArrayList<>(entry.getValue())); + } + for (int i = 0; i < 2; i++) { + sharedMediaData[type].messagesDict[i] = mediaData[type].messagesDict[i].clone(); + sharedMediaData[type].max_id[i] = mediaData[type].max_id[i]; + sharedMediaData[type].endReached[i] = mediaData[type].endReached[i]; + } + return !mediaData[type].messages.isEmpty(); + } + private void showFloatingDateView() { AndroidUtilities.cancelRunOnUIThread(hideFloatingDateRunnable); AndroidUtilities.runOnUIThread(hideFloatingDateRunnable, 650); @@ -1709,8 +1720,8 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter if (id == NotificationCenter.mediaDidLoad) { long uid = (Long) args[0]; int guid = (Integer) args[3]; + int type = (Integer) args[4]; if (guid == profileActivity.getClassGuid()) { - int type = (Integer) args[4]; sharedMediaData[type].loading = false; sharedMediaData[type].totalCount = (Integer) args[1]; ArrayList arr = (ArrayList) args[2]; @@ -1790,6 +1801,44 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter } } } + } else if (sharedMediaPreloader != null && sharedMediaData[type].messages.isEmpty()) { + if (fillMediaData(type)) { + RecyclerListView.Adapter adapter = null; + if (type == 0) { + adapter = photoVideoAdapter; + } else if (type == 1) { + adapter = documentsAdapter; + } else if (type == 2) { + adapter = voiceAdapter; + } else if (type == 3) { + adapter = linksAdapter; + } else if (type == 4) { + adapter = audioAdapter; + } + if (adapter != null) { + for (int a = 0; a < mediaPages.length; a++) { + if (mediaPages[a].listView.getAdapter() == adapter) { + mediaPages[a].listView.stopScroll(); + } + } + adapter.notifyDataSetChanged(); + } + scrolling = true; + for (int a = 0; a < mediaPages.length; a++) { + if (mediaPages[a].selectedType == type) { + if (!sharedMediaData[type].loading) { + if (mediaPages[a].progressView != null) { + mediaPages[a].progressView.setVisibility(View.GONE); + } + if (mediaPages[a].listView != null) { + if (mediaPages[a].listView.getEmptyView() == null) { + mediaPages[a].listView.setEmptyView(mediaPages[a].emptyView); + } + } + } + } + } + } } } else if (id == NotificationCenter.messagesDeleted) { boolean scheduled = (Boolean) args[2]; @@ -2589,7 +2638,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter @Override public boolean isEnabled(int section, int row) { - return row != 0; + return section == 0 || row != 0; } @Override @@ -2707,7 +2756,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter @Override public boolean isEnabled(int section, int row) { - return row != 0; + return section == 0 || row != 0; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PeopleNearbyActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PeopleNearbyActivity.java index f76311095..054cbdee6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PeopleNearbyActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PeopleNearbyActivity.java @@ -520,18 +520,24 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe showProgressRunnable = null; } showLoadingProgress(false); + boolean saveConfig = false; + UserConfig userConfig = getUserConfig(); + if (share == 1 && error != null) { + userConfig.sharingMyLocationUntil = 0; + saveConfig = true; + updateRows(); + } if (response != null && share != 2) { TLRPC.Updates updates = (TLRPC.TL_updates) response; getMessagesController().putUsers(updates.users, false); getMessagesController().putChats(updates.chats, false); users.clear(); chats.clear(); - UserConfig userConfig = getUserConfig(); - boolean saveConfig = false; if (userConfig.sharingMyLocationUntil != 0) { userConfig.lastMyLocationShareTime = (int) (System.currentTimeMillis() / 1000); saveConfig = true; } + boolean hasSelf = false; for (int a = 0, N = updates.updates.size(); a < N; a++) { TLRPC.Update baseUpdate = updates.updates.get(a); if (baseUpdate instanceof TLRPC.TL_updatePeerLocated) { @@ -546,6 +552,7 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe chats.add(peerLocated); } } else if (object instanceof TLRPC.TL_peerSelfLocated) { + hasSelf = true; TLRPC.TL_peerSelfLocated peerSelfLocated = (TLRPC.TL_peerSelfLocated) object; if (userConfig.sharingMyLocationUntil != peerSelfLocated.expires) { userConfig.sharingMyLocationUntil = peerSelfLocated.expires; @@ -555,12 +562,17 @@ public class PeopleNearbyActivity extends BaseFragment implements NotificationCe } } } - if (saveConfig) { - userConfig.saveConfig(false); + if (!hasSelf && userConfig.sharingMyLocationUntil != 0) { + userConfig.sharingMyLocationUntil = 0; + saveConfig = true; } + checkForExpiredLocations(true); updateRows(); } + if (saveConfig) { + userConfig.saveConfig(false); + } if (shortPollRunnable != null) { AndroidUtilities.cancelRunOnUIThread(shortPollRunnable); AndroidUtilities.runOnUIThread(shortPollRunnable, SHORT_POLL_TIMEOUT); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index f5153713b..3a917d69c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -74,6 +74,7 @@ import android.view.Surface; import android.view.TextureView; import android.view.VelocityTracker; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.WindowInsets; @@ -250,9 +251,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat private ImageReceiver sideImage; private boolean isCurrentVideo; + private long lastPhotoSetTime; + private GradientDrawable[] pressedDrawable = new GradientDrawable[2]; private boolean[] drawPressedDrawable = new boolean[2]; private float[] pressedDrawableAlpha = new float[2]; + private int touchSlop; private boolean useSmoothKeyboard; @@ -1898,6 +1902,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } parentActivity = activity; actvityContext = new ContextThemeWrapper(parentActivity, R.style.Theme_TMessages); + touchSlop = ViewConfiguration.get(parentActivity).getScaledTouchSlop(); if (progressDrawables == null) { progressDrawables = new Drawable[4]; @@ -6316,6 +6321,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat currentFileNames[1] = getFileName(index + 1); currentFileNames[2] = getFileName(index - 1); placeProvider.willSwitchFromPhoto(currentMessageObject, getFileLocation(currentFileLocation), currentIndex); + lastPhotoSetTime = SystemClock.elapsedRealtime(); int prevIndex = currentIndex; currentIndex = index; @@ -8153,7 +8159,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } float dx = Math.abs(ev.getX() - moveStartX); float dy = Math.abs(ev.getY() - dragY); - if (dx > AndroidUtilities.dp(3) || dy > AndroidUtilities.dp(3)) { + if (dx > touchSlop || dy > touchSlop) { discardTap = true; hidePressedDrawables(); if (qualityChooseView != null && qualityChooseView.getVisibility() == View.VISIBLE) { @@ -8806,7 +8812,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() / 5; + int side = containerView.getMeasuredWidth() / 6; if (x < side) { if (leftImage.hasImageSet()) { drawPressedDrawable[0] = true; @@ -8823,15 +8829,15 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } @Override - public int getDoubleTapTimeout(MotionEvent e) { + public boolean canDoubleTap(MotionEvent e) { if (checkImageView.getVisibility() != View.VISIBLE && !drawPressedDrawable[0] && !drawPressedDrawable[1]) { float x = e.getX(); - int side = containerView.getMeasuredWidth() / 5; + int side = containerView.getMeasuredWidth() / 6; if (x < side || x > containerView.getMeasuredWidth() - side) { - return 200; + return currentMessageObject == null || currentMessageObject.isVideo() && (SystemClock.elapsedRealtime() - lastPhotoSetTime) >= 500; } } - return GestureDetector2.DOUBLE_TAP_TIMEOUT; + return true; } private void hidePressedDrawables() { @@ -8884,7 +8890,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } float x = e.getX(); if (checkImageView.getVisibility() != View.VISIBLE) { - int side = containerView.getMeasuredWidth() / 5; + int side = containerView.getMeasuredWidth() / 6; if (x < side) { if (leftImage.hasImageSet()) { switchToNextIndex(-1, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index e35bf39e5..c5f2e241c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1314,7 +1314,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } ArrayList users = chatInfo != null && chatInfo.participants != null && chatInfo.participants.participants.size() > 5 ? sortedUsers : null; TLRPC.ChatFull chatFull = users != null ? chatInfo : null; - sharedMediaLayout = new SharedMediaLayout(context, did, sharedMediaPreloader.getLastMediaCount(), sharedMediaPreloader.getSharedMediaData(), userInfo != null ? userInfo.common_chats_count : 0, sortedUsers, chatFull, this) { + sharedMediaLayout = new SharedMediaLayout(context, did, sharedMediaPreloader, userInfo != null ? userInfo.common_chats_count : 0, sortedUsers, chatFull, this) { @Override protected void onSelectedTabChanged() { updateSelectedMediaTabText(); @@ -1512,6 +1512,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private VelocityTracker velocityTracker; + @Override + protected boolean allowSelectChildAtPosition(View child) { + return child != sharedMediaLayout; + } + @Override public boolean hasOverlappingRendering() { return false;