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

fix(android): prevent BaseActivity to stay with exitOnClose:false #14159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Dec 18, 2024

Fixes #13889

A better attempt to fix the isse where the splashscreens stays open when you close two windows quickly and the root window has exitOnClose:false.

var win1 = Ti.UI.createWindow({
	backgroundColor: "green",
	exitOnClose: false
})

Ti.App.addEventListener("pause", function(){console.log("---pause---");})
Ti.App.addEventListener("resume", function(){console.log("---resume---");})
win1.addEventListener("close", function(){console.log("---close---");})
win1.addEventListener("open", function(){console.log("---open---");})

win1.activity.onCreate = () => { console.log("activity create"); }
win1.activity.onPause = () => { console.log("activity pause"); }
win1.activity.onDestroy = () => { console.log("activity destroy"); }

win1.addEventListener("click", function() {
	var win2 = Ti.UI.createWindow({
		backgroundColor: "red"
	})
	win2.open();
})
win1.open();

The TiActivityWindows.getWindowCount() check is already used in TiBaseActivity to check if the app should be put into the background (search for onBackPressed: suspend to background). In this case we actually need to finish it otherwise it will be in a non resumable state.

12.6.0

Bildschirmaufnahme_20241219_095358.webm

this PR

Bildschirmaufnahme_20241219_095239.webm

Different approach:
The Back button event is already fired before the first "remove from stack" is finished and that is why it still has 2 windows instead of 1 and runs another "remove from stack" instead of putting it to the background.
I can also block the "back event" until https://github.com/tidev/titanium-sdk/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java#L1662 is done and then enable it again. This will stay at the green window when you close both quickly.

Bildschirmaufnahme_20241218_221941.webm

But to me it looks more like a bug if I want to close two windows quickly I want to be closed and not stop at the parent window.

@prashantsaini1: would love to get your feedback on this approach

@prashantsaini1
Copy link
Contributor

@m1ga I assume the changes in this commit are not for the Different approach: you shared, but for the above description. For this change also, can you check if all of window's events close, blur, focus + activity's onPause, onStop, onDestroy are triggered correctly because I feel this change might skip a few of them?

@m1ga
Copy link
Contributor Author

m1ga commented Dec 19, 2024

Yes, this is only the first "close app" case as I think it is more useful instead of blocking the back event.

All events are fired the same way as they are in 12.6.0, I've added some in the example above. Only difference: 12.6.0 will say "activity destroy, --close--" but will stay at the splashscreen. With my PR it still says the same but will actually close the app.

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.

2 participants