zulkic / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Stop using view animations for zoom in/out #453

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We currently use two different types of scaling for zooming:

 1. View animation - when zooming in or out by double-tapping or by tapping the zoom buttons the View itself uses a ScaleAnimation to scale up or down to the next zoom level.

 2. Canvas scaling - when we pinch-to-zoom we apply a scale to the canvas.

The problem with the View animation is that it scales *everything* including 
added views and all overlays regardless if they clear the canvas Matrix. So 
overlays like CompassOverlay still scale with the View animation, whereas they 
don't scale when using the canvas scaling since they can override that.

I think we can change the ScaleAnimation to be a ValueAnimator that animates 
the mMultiTouchScale value. That would make everything canvas scaling and would 
fix the problem.

Additionally we can probably set the mMultiTouchScalePoint value to be where we 
double-tapped and that should allow us to "fix" on the tap point rather than 
center on it (maybe?).

Original issue reported on code.google.com by kurtzm...@gmail.com on 25 Jul 2013 at 10:11

GoogleCodeExporter commented 9 years ago
Something along these lines...

Original comment by kurtzm...@gmail.com on 25 Jul 2013 at 10:15

Attachments:

GoogleCodeExporter commented 9 years ago
See issue 425.
See issue 248.

Original comment by kurtzm...@gmail.com on 25 Jul 2013 at 10:15

GoogleCodeExporter commented 9 years ago
Here is an updated and fully working patch. Please test and report back your 
results.

Original comment by kurtzm...@gmail.com on 6 Aug 2013 at 7:10

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by kurtzm...@gmail.com on 17 Aug 2013 at 10:06

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r1294.

Change the way we do zoom animations to use canvas scaling. This will keep zoom 
and pinch zoom operations consistent and will eliminate issues where overlay 
painting will scale when zooming regardless of trying to counteract it in the 
canvas.
Update issue 471
Updated MapController. Removed unsafe AbstractAnimationRunner code, moved all 
zoom animation code to MapController.

Original comment by kurtzm...@gmail.com on 30 Aug 2013 at 7:11

GoogleCodeExporter commented 9 years ago

Original comment by kurtzm...@gmail.com on 30 Aug 2013 at 7:14

GoogleCodeExporter commented 9 years ago
Hi,

Regarding the changed way of doing zoom animations using the canvas scaling.
Now I don't see any zoom animation at all when e.g. pressing the zoom buttons 
or double tap.
But an instant jump at new zoom level.
Is this the new behavior, the zoom animations are removed completely?

Regards.

Original comment by devemu...@gmail.com on 31 Aug 2013 at 10:01

GoogleCodeExporter commented 9 years ago
Hi,

I see that osmdroid does not run anymore at Android version < Honeycomb, 
because the introduced ValueAnimator class exists from API level 11.

Regards.

Original comment by devemu...@gmail.com on 31 Aug 2013 at 12:26

GoogleCodeExporter commented 9 years ago
I can confirm comment 8. We really need to continue to support API 10.  Perhaps 
the ones less than that are questionable now.

Original comment by neilboyd on 2 Sep 2013 at 5:17

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I agree - this was my mistake. "Officially" we support 8+ and I think we still 
work well on 8 but I doubt we'd want to put much work into supporting anything 
less than 9/10 moving forward.

Fixes for this issue coming up next!

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 3:24

GoogleCodeExporter commented 9 years ago
For reference:
http://en.wikipedia.org/wiki/Android_version_history

show up-to-date API adoption rates.

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 3:25

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r1299.

Fixes for < HONEYCOMB in MapController.

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 3:27

GoogleCodeExporter commented 9 years ago
This works for me in the emulator. Please test and report back any issues!

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 3:27

GoogleCodeExporter commented 9 years ago
Thanks for the update.

- Yes it works now at API 10, though not as smoothly as previous ScaleAnimation 
implementations.
At the end of the zoom animations it seems to exist a snap / flash of the map 
just before the final zoom level.

- Also if you can see my question at comment #7, about API 11+. Is the lack of 
zoom animation at these Android versions the final new behavior?
Because in that way the osmdroid has different zoom optical behaviors at pre / 
post Honeycomb versions.
Or it is related to the issue #460 and the float zoom levels?

Regards.

Original comment by devemu...@gmail.com on 2 Sep 2013 at 4:46

GoogleCodeExporter commented 9 years ago
The animations should work the same pre-honeycomb. I'll try to take a look at 
it, but it should be doing the exact same thing it's always been doing (same 
code, just different location).

I don't understand what issue you are encountering in comment #7. Are you 
saying that there are *no* zoom animations at all? That is obviously not 
correct and is not what I am seeing. (I assume hardware accel is turned off)

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 5:01

GoogleCodeExporter commented 9 years ago
Let me re-word that - Not seeing any zoom animations at all is incorrect 
behavior from the maps. It is working correctly for me and I'd like to know why 
you are seeing different results. You should see a normal zoom in/out 
animation. Check to see if pinch-to-zoom works correctly too.

Original comment by kurtzm...@gmail.com on 2 Sep 2013 at 5:24

GoogleCodeExporter commented 9 years ago
- About API 10: I understand that besides moving zoom functionality code to 
MapController, you also removed the AbstractAnimationRunner. Maybe this has a 
role at new odd behavior?

- About API 11+: Yes when pressing the zoom buttons or double tap at the map 
there is not any zoom animation, but an instant jump at new zoom level.
(Hardware acceleration if off)

Regards.

Original comment by devemu...@gmail.com on 2 Sep 2013 at 5:29

GoogleCodeExporter commented 9 years ago
I don't remember us increasing minSdk to 8, but if that's the case then we 
should update the manifest and other configuration files.

Original comment by neilboyd on 2 Sep 2013 at 8:44

GoogleCodeExporter commented 9 years ago
I just tried it in a 1.6 emulator and it still works. I think we should/can 
stick with minSDK 4.

My own app (MySpeed) has 231 active users of 1.6 (4) and 661 of 2.1 (7).

Original comment by neilboyd on 3 Sep 2013 at 4:53

GoogleCodeExporter commented 9 years ago
Hi,

About API 11+
and the lack of zoom animations, I found the cause of my problem.
I had at "Android System Settings / Developer Options" all three options 
"Window animation scale, Transition animation scale and Animator duration 
scale" at off state instead of default 1x (for some other tests). This was 
eliminating the new implemented zoom animations for me.

The other thing that I can notice now at 11+ is that at zoom out animation 
(from zoom buttons) the map zoom outs correctly, but the canvas seems to 
perform the scaling at left center of the screen instead of the absolute center.

Regards.

Original comment by devemu...@gmail.com on 3 Sep 2013 at 7:14

GoogleCodeExporter commented 9 years ago
Neil - yeah, I think I meant to say API 4. That's the proper minimum.

Devemux86 - Can you try it in an emulator? I am not seeing any issues using the 
zoom buttons. It zooms from the center-point for me.

Original comment by kurtzm...@gmail.com on 3 Sep 2013 at 1:31

GoogleCodeExporter commented 9 years ago
I tried on emulator of Android 4.2.2 and was able to capture the zoom out 
animation (I had to put at settings the 10x animation delay).

I attach 2 images, the 1st is the map prior the zoom out and the 2nd is the map 
at zoom out animation end (performed with zoom buttons).

There are moments where the zoom out happens at map center, but at most times 
it happens at left-top.

Regards.

Original comment by devemu...@gmail.com on 3 Sep 2013 at 4:37

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was updated by revision r1302.

Don't pinch-to-zoom while animating since it will throw your location off.

Original comment by kurtzm...@gmail.com on 3 Sep 2013 at 8:15

GoogleCodeExporter commented 9 years ago
Devemux86 - interesting to know that it sometimes works. And it sounds like 
it's only zooming out. Tapping on the zoom out button will trigger 
getController().zoomOut(). That will get the center of the screen and then fix 
to that point.

Some things to try:

- Give the OpenStreetMapViewer project a try to see if that exhibits the same 
behavior.

- Change MapController.zoomOut() line 221 to:

Projection proj = mMapView.getProjection();
Point coords = proj.toMapPixels(proj.getBoundingBox().getCenter(), null);

- Try mixing pinch-to-zoom in various screen locations before your zooms to see 
if that affects anything.

Original comment by kurtzm...@gmail.com on 3 Sep 2013 at 8:31

GoogleCodeExporter commented 9 years ago
Hi,

I tried with OpenStreetMapViewer and the proposed changes and still see the 
same behavior at zoom out.

Regards.

Original comment by devemu...@gmail.com on 4 Sep 2013 at 8:03

GoogleCodeExporter commented 9 years ago
Also with OpenStreetMapViewer at Android 10, at the end of the zoom in 
animation I see a flash of the map just before the final zoom level.
This is more visible if the future zoom level has already been cached, so the 
tiles are drawn instantly.

Regards.

Original comment by devemu...@gmail.com on 4 Sep 2013 at 8:16

GoogleCodeExporter commented 9 years ago
I am curious to know whether the testing with API 10 is affected by issue 474, 
and if so, whether this has any bearing on the test results. If so, it might be 
useful to repeat the tests after applying my patch to issue 474.

Original comment by msida...@gmail.com on 7 Sep 2013 at 5:55

GoogleCodeExporter commented 9 years ago
I am going to spin off the zoom-level "jumping" issue into its own ticket. I 
just fired up a clean API 16 emulator with the OpenStreetMapViewer and I am 
still unable to reproduce the corner-zooming issue.

Original comment by kurtzm...@gmail.com on 10 Sep 2013 at 12:13

GoogleCodeExporter commented 9 years ago
Hi guys!

Returning to #8. I still can't run osmdroid 4.1 on Android 2.3.7 powered device 
(not an emulator but real hardware), it gives me exception: 
"java.lang.ClassNotFoundException: android.animation.ValueAnimator in loader 
dalvik.system.PathClassLoader".

Original comment by demer...@gmail.com on 9 Mar 2014 at 7:16

GoogleCodeExporter commented 9 years ago
We added "Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB" checks to 
prevent devices less than Honeycomb from running the new ValueAnimator code. 
Can you report what value Build.VERSION.SDK_INT is returning for your 2.3.7 
device? It should report "10" and not pass that Honeycomb check which requires 
"11".

Original comment by kurtzm...@gmail.com on 10 Mar 2014 at 2:15

GoogleCodeExporter commented 9 years ago
It fails on 
https://code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/src/main
/java/org/osmdroid/views/MapView.java#143 where the MapController is 
constructed. So any breakpoints on MapController constructor don't trigger.
I guess problem is on 
https://code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/src/main
/java/org/osmdroid/views/MapController.java#12 (class import) or 
https://code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/src/main
/java/org/osmdroid/views/MapController.java#40 (ValueAnimator property).

Original comment by demer...@gmail.com on 10 Mar 2014 at 4:28

GoogleCodeExporter commented 9 years ago
So even a breakpoint on line 52 doesn't get hit? Can you set a breakpoint on 
MapView:143 and then step-into the constructor. Can you also post the full 
exception?

Original comment by kurtzm...@gmail.com on 10 Mar 2014 at 4:35

GoogleCodeExporter commented 9 years ago
No, it doesn't. I can't get into the contructor because of exception. 
Stacktrace is pretty long:
<1> main@830004126112, prio=5, in group 'main', status: 'RUNNING'
      at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
      at org.osmdroid.views.MapView.<init>(MapView.java:142)
      at org.osmdroid.views.MapView.<init>(MapView.java:200)
      at org.osmdroid.views.MapView.<init>(MapView.java:194)
      at com.micdm.transportlive.fragments.MapFragment.onCreateView(MapFragment.java:70)
      at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
      at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
      at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:472)
      at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:1068)
      at android.support.v4.view.ViewPager.populate(ViewPager.java:914)
      at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1436)
      at android.view.View.measure(View.java:8335)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
      at android.view.View.measure(View.java:8335)
      at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
      at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
      at android.view.View.measure(View.java:8335)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
      at android.view.View.measure(View.java:8335)
      at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
      at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
      at android.view.View.measure(View.java:8335)
      at android.view.ViewRoot.performTraversals(ViewRoot.java:843)
      at android.view.ViewRoot.handleMessage(ViewRoot.java:1892)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3835)
      at java.lang.reflect.Method.invokeNative(Method.java:-1)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
      at dalvik.system.NativeStart.main(NativeStart.java:-1)

Well, looks like it was a false alarm. On my IDE I have an option enabled to 
make breakpoint on any uncaught exception. Without that option everything is 
okay, and the map is showing correctly.

Original comment by demer...@gmail.com on 10 Mar 2014 at 7:59

GoogleCodeExporter commented 9 years ago
Okay, good to hear. It is probably an exception that is handled gracefully by 
android and non-fatal until you actually try to use the class.

Original comment by kurtzm...@gmail.com on 10 Mar 2014 at 8:14