forked from TGX-Android/Telegram-X
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reactions: full implementation. PR: TGX-Android#154 (TGX-Android#185)
* Telegram X Android Competition: Round 1 - main commit * Smallest Fix) * add vkryl changes * Update submodule * Adding modified vkryl files to the repository * Rejecting changes in vkryl android submodule * fix color in reaction badge * Revert gitmodules file * Quick reactions update + Premium features * Reactions preloading on starting app * Haptic feedbacks * Disable Reactions to a Sponsored Post * Fixes - Animate reaction button bubble * Support TextSize settings + flat mode reactions mockup * Fix GifThread crashes? * Fix design + fix crashes * Quick reaction fixes * Reactions bottom sheet Improvements * Reactions bottom sheet Improvements * Disable message list animator * Quick gesture improvements * Fix bottom sheet jumping * Reaction Bubble Improvements * Reaction button improvements * Improving mockup compliance * Change toast to tooltip * some fixes * Improving the fidelity of animations * Bottom sheet improvements + bugfixes * Round video reaction fix? * - * fix quick buttons * - * Round video fix * Unread reactions fixes * Update app/src/main/java/org/thunderdog/challegram/unsorted/Settings.java Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> * 1 * Fix phantom buttons * Fixes * Bottom sheet fix? + overlay translation fix * fix for fix * Remove log output * Color fixes * improving the accuracy of full-screen animation * canGetAddedReactions fix * Update app/src/main/java/org/thunderdog/challegram/navigation/ViewPagerTopView.java Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> * Update app/src/main/java/org/thunderdog/challegram/unsorted/Settings.java Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> * Update app/src/main/java/org/thunderdog/challegram/unsorted/Settings.java Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com> * Thread safety fix * Update Paints.java * archive fix * Theme fix * Update TGReactions.java * Update MessageOptionsPagerController.java * Update MessageOptionsPagerController.java * bugfixes * Bottom shit fix * Bottom sheet fixes 2 * Bottom sheet fixes 3 * Bottomsheet fixes 3 * Update PopupLayout.java * scroll fix? * Add visibleIfZero option to Counter class * Layout accuracy improvement * Fix width if bubble is stretched * Update TGMessage.java * Update ReactionsSelectorRecyclerView.java * Update TGMessage.java * Scroll fix 2 * Start animation position fix * Fixes * Scroll fixes * - * Update MessageView.java * Update MessagesManager.java * Update MessageView.java * Scroll fix? * Update ComplexReceiver.java * Update MessagesManager.java * Update MessagesManager.java * Fixes * Fixes * Update MessagesManager.java * Update TGMessage.java * fixes * Optimizations * Add timeExpandAnimation * Update TGMessage.java * Update TGMessage.java Co-authored-by: Vyacheslav <6242627+vkryl@users.noreply.github.com>
- Loading branch information
Showing
71 changed files
with
8,298 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
...src/main/java/org/thunderdog/challegram/component/chat/MessageQuickActionSwipeHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package org.thunderdog.challegram.component.chat; | ||
|
||
import android.util.Log; | ||
|
||
import org.thunderdog.challegram.data.TGMessage; | ||
import org.thunderdog.challegram.tool.Screen; | ||
|
||
import me.vkryl.core.MathUtils; | ||
|
||
public class MessageQuickActionSwipeHelper { | ||
public static final float SWIPE_BUBBLE_MOVE_MAX = 64f; | ||
public static final float SWIPE_THRESHOLD_WIDTH = 124f; | ||
public static final float SWIPE_VERTICAL_HEIGHT = 80f; | ||
public static final float SWIPE_VERTICAL_LOCK_WIDTH = Screen.px(Screen.smallestSide() * 0.75f); | ||
|
||
private final TGMessage message; | ||
private final boolean useBubbles; | ||
|
||
private float currentDx; | ||
private float currentDy; | ||
private float actualDx; | ||
private float actualDy; | ||
|
||
private boolean lockedBecauseSmallDy; | ||
private boolean lockedBecauseNotReadyInBubbleMode; | ||
private boolean lockedBecauseSwipeStarted; | ||
|
||
private float moveFactor; | ||
private int quickActionNumber; | ||
|
||
public MessageQuickActionSwipeHelper (TGMessage message) { | ||
this.message = message; | ||
this.useBubbles = message.useBubbles(); | ||
} | ||
|
||
public void translate (float dx, float dy, boolean bySwipe) { | ||
final boolean lockedVerticalSwipe = isLockedVerticalSwipe(); | ||
final boolean isLeft = dx > 0; | ||
final float ddx = dx - currentDx; | ||
final float ddy = lockedVerticalSwipe ? 0f: dy - currentDy; | ||
currentDx = dx; actualDx += ddx; | ||
currentDy = dy; actualDy += ddy; | ||
actualDy = clampActualDy(isLeft, actualDy); | ||
|
||
if (dx != 0f) { | ||
lockedBecauseNotReadyInBubbleMode &= useBubbles && Math.abs(actualDx) < Screen.dp(SWIPE_BUBBLE_MOVE_MAX); | ||
lockedBecauseSmallDy &= Math.abs(currentDy) < Screen.dp(SWIPE_VERTICAL_HEIGHT) / 2f; | ||
moveFactor = Math.min(1f, Math.abs(dx) / Screen.dp(SWIPE_THRESHOLD_WIDTH)); | ||
} else { | ||
reset(); | ||
} | ||
|
||
|
||
|
||
final float verticalPosition = actualDy / Screen.dp(SWIPE_VERTICAL_HEIGHT); | ||
updateVerticalPosition(verticalPosition); | ||
|
||
message.translate(dx, verticalPosition, true); | ||
message.invalidate(true); | ||
} | ||
|
||
public void onBeforeSwipe () { | ||
lockedBecauseSwipeStarted = true; | ||
} | ||
|
||
public void reset () { | ||
currentDx = 0f; | ||
currentDy = 0f; | ||
actualDx = 0f; | ||
actualDy = 0f; | ||
lockedBecauseSmallDy = true; | ||
lockedBecauseNotReadyInBubbleMode = useBubbles; | ||
lockedBecauseSwipeStarted = false; | ||
moveFactor = 0f; | ||
quickActionNumber = 0; | ||
} | ||
|
||
public float getMoveFactor () { | ||
return moveFactor; | ||
} | ||
|
||
public TGMessage.SwipeQuickAction getChosenQuickAction () { | ||
final boolean isLeft = actualDx > 0; | ||
final int realActionQuickNumber = quickActionNumber + message.getQuickDefaultPosition(isLeft); | ||
|
||
return message.getQuickAction(isLeft, realActionQuickNumber); | ||
} | ||
|
||
private void updateVerticalPosition (float verticalPosition) { | ||
final int newQuickActionNumber = Math.round(verticalPosition); | ||
if (quickActionNumber != newQuickActionNumber) { | ||
quickActionNumber = newQuickActionNumber; | ||
|
||
} | ||
} | ||
|
||
private float clampActualDy (boolean isLeft, float dy) { | ||
final int minPosition = -message.getQuickDefaultPosition(isLeft); | ||
final int maxPosition = minPosition + Math.max(message.getQuickActionsCount(isLeft) - 1, 0); | ||
return MathUtils.clamp(dy, minPosition * Screen.dp(SWIPE_VERTICAL_HEIGHT), maxPosition * Screen.dp(SWIPE_VERTICAL_HEIGHT)); | ||
} | ||
|
||
private boolean isLockedVerticalSwipe () { | ||
boolean lockedBecauseReadyInFlatMode = !useBubbles && Math.abs(actualDx) > Screen.dp(SWIPE_VERTICAL_LOCK_WIDTH); | ||
return lockedBecauseNotReadyInBubbleMode || lockedBecauseReadyInFlatMode || lockedBecauseSmallDy || lockedBecauseSwipeStarted; | ||
} | ||
} |
Oops, something went wrong.