Skip to content

Commit

Permalink
Some hopefully helpful and not excessive pinch-resize restrictions in
Browse files Browse the repository at this point in the history
BlockSchedule for #370.
  • Loading branch information
Wilm0r committed Dec 15, 2024
1 parent 5631264 commit 95f6bb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions app/src/main/java/net/gaast/giggity/BlockSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ public void onResizeEvent(NestedScroller src, float scaleX, float scaleY, int sc
TentHeight *= scaleY;
HourWidth = Math.max(60, Math.min(HourWidth, 1000));
TentHeight = Math.max(30, Math.min(TentHeight, 400));
if (HourWidth / TentHeight < 2) {
HourWidth = TentHeight * 2;
}
Log.d("ratio:", "" + ((float) HourWidth / (float) TentHeight));

draw();

Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/net/gaast/giggity/NestedScroller.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,14 @@ public boolean onTouchEventInt(MotionEvent event) {
scaleX = Math.abs(x0 - x1) / distStartX;
scaleY = Math.abs(y0 - y1) / distStartY;

/* Crappy multitouch support can result in really high/low numbers.
* ×10 seems unlikely already IMHO, so just don't resize in that axis. */
if (scaleX > 10 || scaleX < 0.1)
scaleX = 1;
if (scaleY > 10 || scaleY < 0.1)
scaleY = 1;
// https://github.com/Wilm0r/giggity/issues/370
// Previously this code would reset scale factors to 1 if they were <.1 or >10,
// but probably this approach here is better. It'll take more dedication now to
// sabotage one's BlockSchedule.
// BlockSchedule itself will additionally prevent an overly narrow HW/TH ratio
// in the onResizeEvent handler.
scaleX = (float) Math.max(.4, Math.min(4, scaleX));
scaleY = (float) Math.max(.4, Math.min(4, scaleY));

try {
c.setScaleX(scaleX);
Expand Down Expand Up @@ -248,5 +250,6 @@ public void onLayout(boolean changed, int left, int top, int right, int bottom)
public interface Listener {
void onScrollEvent(NestedScroller src, int scrollX, int scrollY);
void onResizeEvent(NestedScroller src, float scaleX, float scaleY, int scrollX, int scrollY);

}
}

0 comments on commit 95f6bb2

Please sign in to comment.