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

Android: overrideUserInterfaceStyle makes issues changing it multiple times #13825

Open
1 task done
m1ga opened this issue May 4, 2023 · 0 comments
Open
1 task done
Labels
android bug needs triage This issue hasn't been reviewed by maintainers

Comments

@m1ga
Copy link
Contributor

m1ga commented May 4, 2023

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

When running the code below on Android and clicking the button multiple times you can see that around the 4th change it will restart the activity with this method.

After that it can be that is losing the content.

simplescreenrecorder-2023-05-04_13.50.30.mp4

If I remove that recreate part it will keep the content but doesn't update the mode all the time:

simplescreenrecorder-2023-05-04_13.53.13.mp4

There is a comment in the code

// Note: Works-around a Google bug where it doesn't always call the activity's onNightModeChanged() method.

Which might be referring to this behavior.

Looking at the logs I can see that it is showing

[INFO]  ActivityThread: Schedule relaunch activity: com.miga.testfirebase.TestappActivity
[INFO]  ActivityThread: Schedule relaunch activity: org.appcelerator.titanium.TiActivity

the first time and after a while it is

[INFO]  ActivityThread: Schedule relaunch activity: org.appcelerator.titanium.TiActivity
[INFO]  ActivityThread: Schedule relaunch activity: com.miga.testfirebase.TestappActivity
[INFO]  ActivityThread: Schedule relaunch activity: org.appcelerator.titanium.TiActivity

So the order is different and TiActivity is there twice. So perhaps there is something wrong with the Activity stack that is causing this issue.

Reproducible sample

const win = Titanium.UI.createWindow({backgroundColor: "red"});
const btn = Ti.UI.createButton({title: "change"});
win.add(btn);
var change = false;
btn.addEventListener("click", function() {
	if (change) {
		Ti.UI.overrideUserInterfaceStyle = Ti.UI.USER_INTERFACE_STYLE_LIGHT
	} else {
		Ti.UI.overrideUserInterfaceStyle = Ti.UI.USER_INTERFACE_STYLE_DARK
	}
	change = !change;
})

win.open();

Steps to reproduce

  • run the code
  • click the button mutliple times

Platform

Android

SDK version you are using

12.2.0

Alloy version you are using

No response

@m1ga m1ga added bug needs triage This issue hasn't been reviewed by maintainers labels May 4, 2023
@m1ga m1ga added the android label Oct 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android bug needs triage This issue hasn't been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant