I was wondering if within Phonegap it was possible to disable orientation changes using JavaScript alone. So not using an external plugin, or modifying the config.xml for example. I could not find any definitive answers to this question. The reason for this is we have an application that we package up and have customers download, which allows them to run their own mobile applications using a software product we offer. Since we want customers to have all the options available for their applications, this packaged application has both orientations enabled (this application was built using Phonegap obviously).
I was thinking perhaps there is an event I can listen for and disable its propagation. Another hack I was thinking of was if I could detect an orientation event, I can rotate the page in the opposite direction of the movement that triggered the orientation event, if its not possible to disable its propagation or stop the rotation in the first place.
Related
I was messing around with libvlcsharp on Xamarin and the (fairly) new MediaPlayerElement UI on Android. For devices such as Android TV, there is no touch interface so you have to use something like a remote control.
For this case, I end up capturing keypresses in DispatchKeyEvent and send them to my app via MessagingCenter. I was wondering whether MediaPlayerElement can support non-touch devices automatically OR if not, what the best approach would be to handling keypresses in the app. I would have to "highlight" various controls of the MediaPlayerElement and then be able to select them when "DpadCenter" is pressed.
My questions are:
Does MediaPlayerElement already support non touch gestures? This site here seems to suggest it might with the comment that you can turn them off.
If it doesn't support them (and you have to roll your own), is there a programmatic way to highlight (e.g. change the background color) of the individual controls/buttons (such as pause or play) and invoke them?
Does MediaPlayerElement already support non touch gestures? This site here seems to suggest it might with the comment that you can turn them off.
If it doesn't support them (and you have to roll your own), is there a programmatic way to highlight (e.g. change the background color) of the individual controls/buttons (such as pause or play) and invoke them
You can override functionality for any control, so you should be able to hook your DpadCenter event and modify the behavior you expect of the player element.
It is on the roadmap to provide better docs for this https://code.videolan.org/videolan/LibVLCSharp/-/issues/309
For customization of the control, a similar answer was created a while ago: How to create LibVLCSharp custom playback controls in Xamarin Forms?
Do share what you build with it :-) We don't have any Android TV sample for this.
Background
I am building an Optical Character Recognition (OCR) tool that makes sense of photographed Forms.
Arguably the most complicated part of the pipeline is to get the target Document into perspective; basically what is attempted in this Tutorial.
Due to the fact that the data is acquired often in very poor conditions, i.e.:
Uncontrolled Brightness
Covered or removed corners
Background containing more texture than the Target Document
Shades
Overlapped Documents
I have "solved" the Problem using Instance + Semantic Segmentation.
Situation
The images are uploaded by Users via an App that captures images as is. There are versions for the App in both Android and IOS.
Question
Would it be possible to force the App to use the Users' mobile phone Documents mode (if present) prior to acquiring the photo?
The objective is to simplify the pipeline.
In end effect, at a description level, the App would have to do three things:
1 - Activate the Documents mode
2 - Outline the Target Document; if possible even showing the yellow frame.
3 - Upload the processed file to the server. Orientation and extension are not important.
iOS
This isn't a "mode" for the native camera app.
Android
There isn't a way to have the the "documents mode" automatically selected. This isn't available for all Android devices, either. So even if you could, it wouldn't be reliable.
Best bet is following the documentation for Building a camera app, rather than using the native camera if special document scanning is essential. This won't come out of the box on either platform for you.
What is the best way to get the device orientation with cocos2d-x (c++)?
My Android/iOS application does support all 4 device orientations, and more important than knowing if it is landscape or portrait, I would like to know if it is upside down or not.
I will have to know from within a CCLayer.
UPDATE
I am trying to get events for right tilt and left tilt. To do so, I am calculating the angle at which the device is held. However, I need to know what orientation the device has, to be able to know if I am actually tilting left or right.
Though cocos2d-x is cross platform, few things are still very much platform dependent, for example, if you see the CCFileUtils, we have separate implementation files for iOS, Android etc, the cross platform is maintained with a single header,
Keeping that in mind,
In Android, you can get the device orientation by using the constants,
Surface.ROTATION_0 (no rotation)
Surface.ROTATION_90
Surface.ROTATION_180
Surface.ROTATION_270.
which you can get by calling Display.getRotation()
(It only rotate in all these directions if, android:screenOrientation:fullSensor is set)
And in iOS,
You can get the values with
UIDeviceOrientationPortrait
UIDeviceOrientationPortraitUpsideDown
UIDeviceOrientationLandscapeLeft
UIDeviceOrientationLandscapeRight
(It only rotates in all these directions if, supportedInterfaceOrientations method returns UIInterfaceOrientationMaskAll)
Note:
Its not a good practice to rotate a phone upside down in portrait mode, only on tablets its accepted.. (Apple might even reject your app for this reason)
Let me know if you want to know how to use it, but googling the keywords will give you the usage..
After a quick google search :
http://www.cocos2d-x.org/wiki/Device_Orientation
http://www.cocos2d-x.org/forums/6/topics/36414
UDPDATE:
I don't think you can determine the orientation the way you want to from cocos2d-x.
Then the only solution that I'm thinking of is to go into java through jni and use android's methods to determine the current orientation. Here's a
link
on how to determine all 4 orientations.
As for how to call java methods from c++, that's another ball game.
I am looking for a better way to respond to orientation changes using native AS (non-flex) Air for mobile. The current implementation using stage.autoOrients = true is pretty crappy and doesn't look polished the way a native orientation change looks in professional apps.
How are you dealing with orientation change and smooth re-layout on mobile for android (I haven't yet tested on iOS)? Do you live with the automatic re-orientation animation, with its truncated display and the delay before you re-layout your view? Is there a funky workaround that allows you to draw stuff off-screen or in some other way make that user experience feel less broken and more like a native app behaves?
You may set autoOrients to false and listen to Accelerometer Events.
This way you can guess device orientation and, if needed, perform your own stage rotation with your own transitions and animations.
I want to develop an application with some advance features like shake feature, orientation of images, zoom in/out, scrolling, etc. For instance, the
user can shake the phone in order to erase an entered text. Also, by rotating the phone
clockwise or anti-clockwise, the orientation of the underlying images will change.
How would I do that?
For shaking:
You will need to use the phone's accelerometer sensor. You can find many examples of this if you Google (for example: Android: I want to shake it)
For rotations:
When the phone detects an orientation change, Android will destroy and recreate your application. There are lifecycle methods (see http://developer.android.com/reference/android/app/Activity.html) that are called that allow you to save and restore your application's current state. Again, if you Google:
http://developer.android.com/guide/topics/resources/runtime-changes.html
http://www.androidguys.com/2008/10/14/rotational-forceson-your-android-app/