Android-Week-View icon indicating copy to clipboard operation
Android-Week-View copied to clipboard

Zoom on weekView

Open sylvaindd opened this issue 12 years ago • 35 comments

Hi,

I'd like to know if there is a way to zoom/pinch on a week view ? And is it possible to display only days from Monday to Friday ?

Thank you

sylvaindd avatar Sep 30 '14 09:09 sylvaindd

I don't think it has this feature implemented, but it should be not that hard. You will need to modify it to grab the pinch gesture and changes the "noOfVisibleDays" variable. Also, to set the days to just display monday to friday u set "noOfVisibleDays" to 5 and "firstDayOfWeek" to 1 (I think).

caioketo avatar Sep 30 '14 10:09 caioketo

Thanks @caioketo for your answer. But it's not possible to not show the days Saturday and Sunday. The calendar was not built to omit some of the days. This calendar covers only the most common scenarios (i.e. it behaves like a normal week view calendars. e.g. google calendar). I don't think its possible to cover all special case scenarios.

Also can you provide an example app where its possible to zoom/pinch in the week view.

alamkanak avatar Sep 30 '14 11:09 alamkanak

@alamkanak my bad, I thought as the variables, it should be able, but didnt test it out. And for the example, I didnt make it, as for my needs its not usefull, but, if u wants I can try that out.

caioketo avatar Sep 30 '14 11:09 caioketo

Thank you to you both. Google Calendar as a pinch vertical zoom in week view. S planner has both axes zoom.

I succeeded in hiding Saturday and Sunday but it causes some day shifting on Monday.

Thank you in advance

sylvaindd avatar Sep 30 '14 11:09 sylvaindd

Thanks @sylvaindd. I think it's a good idea to implement the vertical zoom. The horizontal one may cause some issues here. I'll surely look into it.

alamkanak avatar Sep 30 '14 11:09 alamkanak

Yes I think the vertical zoom is enough. Thank you for your answers.

sylvaindd avatar Sep 30 '14 11:09 sylvaindd

@alamkanak the vertical would be changing the "height" of the hours dont?

caioketo avatar Sep 30 '14 12:09 caioketo

@caioketo yes that's it I guess, I think it just needs the multi touch implementation.

sylvaindd avatar Sep 30 '14 12:09 sylvaindd

@alamkanak I see, right now im at work, so I can't really try it out, but if you want, I can make some tests after I get home.

caioketo avatar Sep 30 '14 12:09 caioketo

@caioketo did you try it out ?

sylvaindd avatar Oct 02 '14 12:10 sylvaindd

@sylvaindd I havent got time yet, since its not nescessary for what I'm using it, it will take a little long for me to try that.. sorry.

caioketo avatar Oct 02 '14 12:10 caioketo

I created a method to handle the zoom which is :

    mScaleDetector = new ScaleGestureDetector(mContext, new OnScaleGestureListener() {
        public void onScaleEnd(ScaleGestureDetector detector) {
        }

        public boolean onScaleBegin(ScaleGestureDetector detector) {
            return true;
        }

        public boolean onScale(ScaleGestureDetector detector) {
            System.out.println(mHourHeight);
            if (detector.getScaleFactor() > 1 && mHourHeight < 200) {
                mHourHeight += 4 * detector.getScaleFactor();
                // Zoom
                // mHourHeight += 5;
            }
            else if (detector.getScaleFactor() < 1 && mHourHeight > 80) {
                mHourHeight -= 4 * (detector.getScaleFactor() + 1);
                // deZoom
                // mHourHeight -= 5;
            }
            return false;
        }
    });

And called it in onTouchEvent():

    mScaleDetector.onTouchEvent(event);

It's working but it doesn't center the calendar to the position I'm zooming. I'd like to know if there was a way to center the calendar with X and Y axes ?

Than you

sylvaindd avatar Oct 09 '14 17:10 sylvaindd

Up ! I wanted to know if you started implementing this feature ? I will realease an application using your library soon and my zoom feature is working but not really smoothly.

Thank you in advance,

sylvaindd avatar Oct 20 '14 15:10 sylvaindd

I've been working on implementing this. Just some slight problems left, but expect a PR soon.

entropitor avatar Feb 08 '15 20:02 entropitor

HI, That would be very nice. I kinda upgraded my implementation but it's still not smooth. Anyway, if you could keep me informed about your implementation, that would be nice.

sylvaindd avatar Feb 08 '15 20:02 sylvaindd

I got it working so it follows the current position in the view.

The two problems I currently still have is that

  • [x] it sometimes still starts scrolling while zooming (especially annoying when it comes to horizontal scrolling)
  • [x] there should be a dynamic minium hourHeight (that depends on the screenHeight, otherwise the view is sometimes smaller than the available height).

(You'll be able to set the min and max hourHeight manually too btw)

entropitor avatar Feb 08 '15 20:02 entropitor

I actually managed to resolve this problem : "otherwise the view is sometimes smaller than the available height" If you used a ScaleGestureDetector did you return true in onScale and onScaleBegin ? I had a problem with the scroll and zoom not working correctly together by returning false.

sylvaindd avatar Feb 08 '15 20:02 sylvaindd

I do return true, but I'm not sure what I should do in the onTouch handler. Right now I do return mScaleDetector.onTouchEvent(event) && mGestureDetector.onTouchEvent(event); instead of return mGestureDetector.onTouchEvent(event);

entropitor avatar Feb 08 '15 20:02 entropitor

I currently do this : mScaleDetector.onTouchEvent(event); return mGestureDetector.onTouchEvent(event); Which I guess is pretty much the same as what you're doing

sylvaindd avatar Feb 08 '15 20:02 sylvaindd

I think your implementation is even better. (in case the first one ever returns false)

entropitor avatar Feb 08 '15 21:02 entropitor