0

I am stuck at the following problem and need your help to resolve it. Any guidance would be highly appreciated.

Scenario: I have an overlay view on top of a surface view and this overlay view has couple of images and a button. I have set the "orientation" flag to 'Landscape' in the manifest file for this activity and written an orientation listener also to identify the Landscape left and Landscape right orientations.

Problem: When I turned on the accessibility mode with content description correctly set to the widgets, in the initial mode(whether landscape left or right) when I press any image, I hear the accessibility talkback correctly. Problem happens when i rotate the device orientation from left to right or vice-versa, even though overlay view is rotated correctly the accessibility controls are not rotated. When I touch the icons in new orientation with Accessibility still on, I do not hear the TalkBalk text. When I touch the image location on the overlay where it was drawn in the last orientation mode, I hear the talkback text.

Looks like the Accessibility area on the display/view is locked and is not getting rotated with the rotation of the overlay view on rotating the screen orientation from left to right.

Any idea of why this is happening and way to rectify it? Is the only open to destroy the activity and create it again? I can't destroy the surface view as it would affect the user experience. How can I rotate the accessibility TalkBack text associated with the images along with the screen rotation?

Spent days on this problem. Tried view rotation by rotating it but that is not the problem as view is already rotating. Please help.

Thanks a lot for your help in advance.

ASingal
  • 121
  • 1
  • 5
  • How are you implementing rotation? Also, on what version of Android are you testing? – alanv Aug 20 '14 at 22:29
  • I have registered an OrientationEventListener using a Sensor Manager and every time there is an change in orientation callback is called. Then I check for the right angle and handle only left and right orientation int tempOrientation = (10 < angle && angle < 176) ? RIGHT : LEFT; I am using Android 4.4.2 OS but I have tried on all OS versions. Same issue. – ASingal Aug 20 '14 at 22:33
  • How are you applying rotation to your overlay? View.setRotation() or something else? – alanv Aug 20 '14 at 23:03
  • I tried both by calling setRotation() method and by creating the overlay view again. In both cases, all UI widgets are rotated correctly, but the Talkback area is somehow locked to the display area where views were created first time. – ASingal Aug 20 '14 at 23:10

1 Answers1

0

I fixed the issue by using Android's native functionality rather than overriding the sensor orientation handler and calculating the angles to figure out the LEFT or RIGHT landscape orientation. Just use the following code in the onCreate() function of your activity

    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    }

with this solution, you could restrict the orientation in Landscape mode only and between LEFT and RIGHT directions. There solution works for surfaces and overlays on them as well.

ASingal
  • 121
  • 1
  • 5
  • I figured out above code rotates the underlying SurfaceView as well, which is not the desired behavior. So, I ma back to the square one and having the same issue. Can anyone please help in how to rotate the overlay view while keeping the surface view fixed in Landscape mode? – ASingal Sep 08 '14 at 23:27