-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(android): Ti.App wrongly fires pause/resume events when opening/closing child windows #10634
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74398ba
[TIMOB-26746] Android: Fixed bug where Ti.App wrongly fires pause/res…
jquick-axway ea03901
Merge branch 'master' into TIMOB-26746
garymathews a8cb7fb
Merge branch 'master' into TIMOB-26746
garymathews 443c15c
Android: Modified [TIMOB-26746] to only fire a "resume" event after a…
jquick-axway ade67f7
Android: Code cleanup of [TIMOB-26746]
jquick-axway 64c01be
Merge branch 'master' into TIMOB-26746
ec7c4dc
Merge branch 'master' into TIMOB-26746
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Appcelerator Titanium Mobile | ||
* Copyright (c) 2011-Present by Appcelerator, Inc. All Rights Reserved. | ||
* Licensed under the terms of the Apache Public License | ||
* Please see the LICENSE included with this distribution for details. | ||
*/ | ||
/* eslint-env mocha */ | ||
/* global Ti */ | ||
/* eslint no-unused-expressions: "off" */ | ||
'use strict'; | ||
var should = require('./utilities/assertions'); | ||
|
||
describe('Titanium.App', function () { | ||
it.android('pause/resume events', function (finish) { | ||
this.timeout(5000); | ||
let wasPauseEventReceived = false; | ||
let wasResumeEventReceived = false; | ||
|
||
// Handle Ti.App pause/resume events. They happen when app is sent to background/foreground. | ||
// - "pause" event must be received before "paused" event. | ||
// - "resume" event must be received before "resumed" event. | ||
Ti.App.addEventListener('pause', function pauseEventHandler(e) { | ||
Ti.API.info('Received event: ' + e.type); | ||
Ti.App.removeEventListener(e.type, pauseEventHandler); | ||
wasPauseEventReceived = true; | ||
}); | ||
Ti.App.addEventListener('paused', function pausedEventHandler(e) { | ||
Ti.API.info('Received event: ' + e.type); | ||
Ti.App.removeEventListener(e.type, pausedEventHandler); | ||
should(wasPauseEventReceived).be.true; | ||
Ti.Android.currentActivity.startActivity(Ti.App.Android.launchIntent); // Resume this app. | ||
}); | ||
Ti.App.addEventListener('resume', function resumeEventHandler(e) { | ||
Ti.API.info('Received event: ' + e.type); | ||
Ti.App.removeEventListener(e.type, resumeEventHandler); | ||
wasResumeEventReceived = true; | ||
}); | ||
Ti.App.addEventListener('resumed', function resumedEventHandler(e) { | ||
Ti.API.info('Received event: ' + e.type); | ||
Ti.App.removeEventListener(e.type, resumedEventHandler); | ||
should(wasResumeEventReceived).be.true; | ||
finish(); | ||
}); | ||
|
||
// Navigate to the device's home screen. Equivalent to pressing the "home" button. | ||
// This should fire this app's "pause" and "paused" events. | ||
const homeIntent = Ti.Android.createIntent({ | ||
action: Ti.Android.ACTION_MAIN, | ||
}); | ||
homeIntent.addCategory(Ti.Android.CATEGORY_HOME); | ||
homeIntent.setFlags(Ti.Android.FLAG_ACTIVITY_NEW_TASK); | ||
Ti.Android.currentActivity.startActivity(homeIntent); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also put
appModule
inTiApplicationLifecycle
, so we don't have to grab it each time?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we add a new "App" module instance every time a new JavaScript runtime gets created (ie: back-out of the app and relaunch).