Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-18956] Android: Implement orientation change detection in all … #6899

Merged
merged 1 commit into from Jun 11, 2015

Conversation

ashcoding
Copy link
Contributor

…orientation

Jira: https://jira.appcelerator.org/browse/TIMOB-18956

Please test using an Android table and an Android phone to see the difference. I was testing with a Nexus 9 and Nexus 6. In Nexus 6, the app would not rotate upside down, hence UPSIDE_PORTRAIT is not available.

App.js

var win = Titanium.UI.createWindow({  
    title:'Window',
    backgroundColor:'#fff'
});

win.orientationModes = [ 
    Titanium.UI.PORTRAIT, 
    Titanium.UI.UPSIDE_PORTRAIT,
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT
];

Ti.Gesture.addEventListener('orientationchange', function(e){
    switch(e.orientation) {
    case Ti.UI.LANDSCAPE_RIGHT:
        Ti.API.info("LANDSCAPE_RIGHT");
        Ti.UI.createNotification({
            message:"LANDSCAPE_RIGHT",
            duration: Ti.UI.NOTIFICATION_DURATION_SHORT
        }).show();
        break;
    case Ti.UI.LANDSCAPE_LEFT:
        Ti.API.info("LANDSCAPE_LEFT");
        Ti.UI.createNotification({
            message:"LANDSCAPE_LEFT",
            duration: Ti.UI.NOTIFICATION_DURATION_SHORT
        }).show();
        break;
    case Ti.UI.UPSIDE_PORTRAIT:
        Ti.API.info("UPSIDE_PORTRAIT");
        Ti.UI.createNotification({
            message:"UPSIDE_PORTRAIT",
            duration: Ti.UI.NOTIFICATION_DURATION_SHORT
        }).show();
        break;
    case Ti.UI.PORTRAIT:
        Ti.API.info("PORTRAIT");
        Ti.UI.createNotification({
            message:"PORTRAIT",
            duration: Ti.UI.NOTIFICATION_DURATION_SHORT
        }).show();
        break;
    default:
        Ti.API.info("Unknown!!");
    } 
});

win.open();

@hieupham007
Copy link
Contributor

Code reviewed and functionally tested. Request accepted

hieupham007 added a commit that referenced this pull request Jun 11, 2015
[TIMOB-18956] Android: Implement orientation change detection in all …
@hieupham007 hieupham007 merged commit db498ec into tidev:master Jun 11, 2015
@ashcoding ashcoding deleted the TIMOB-18956-A branch July 8, 2015 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants