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 · 1 comment · May be fixed by #14113
Open
1 task done

Android: overrideUserInterfaceStyle makes issues changing it multiple times #13825

m1ga opened this issue May 4, 2023 · 1 comment · May be fixed by #14113
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
@m1ga
Copy link
Contributor Author

m1ga commented Sep 14, 2024

More test code in #13266 (comment) , the App sample in the initial post. When you change the style multiple times it will show an empty app.

@AbdullahFaqeir AbdullahFaqeir linked a pull request Sep 15, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant