-
-
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): override user interface style #14113
fix(android): override user interface style #14113
Conversation
The last changes make the app restart correctly now 👍 Which makes me wonder: are the other changes needed at all? Do we need a default At some point we'll need to find the source why it is behaving like this after 4-5 clicks but at least it will show the app again. Would love to have some community members to test this as there are some |
I'll explain why it's happening when I get on my laptop |
@m1ga titanium-sdk/android/titanium/src/java/org/appcelerator/titanium/TiRootActivity.java Line 171 in abbd387
At some point while clicking, the activity gets duplicated, which is the root activity of the app, when going inside this condition, we lose the state of the activity. |
@m1ga Here's what's happening. I assumed that since you keep clicking on the button and internally the activity is being recreated which in turn starts the while life cycle of the activity which is the root activity, at some point, the root activity gets duplicated. which leads us to the following titanium-sdk/android/titanium/src/java/org/appcelerator/titanium/TiRootActivity.java Lines 154 to 174 in 50d8604
if you go over the comments, you'll see at the very last line before calling See below: titanium-sdk/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java Lines 685 to 696 in 50d8604
By bypassing the We ara stepping over this as well titanium-sdk/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java Lines 722 to 725 in 50d8604
And I believe many other things that would cause the window/activity to lose it's state. I don't know if all of this makes since to you!, let me know |
@m1ga any updates on this one? |
@AbdullahFaqeir as mentioned on Slack: I'll take a look at it again at the weekend. And I think we should just use the one line from the last commit as that was fixing the issue, not the other default parts. But I'll test all at the weekend again and give more feedback |
Ok, I'll tested it again and I think we can reduce this PR to just one line: fixes the issue already. That would reduces the possible site effects as we don't change the XML or anything else in the BaseActivity besides the part inside the if condition (which is only triggered when you change the interface style) |
@m1ga |
I saw that but it didn't go into that method so it wasn't needed there in my tests. It was only needed in the one place. |
@m1ga it would in other cases, I'm not only fixing your case, I'm doing something to handle all cases in a proper way. |
I totally understand that 👍 Just want to make sure that the setTheme parts or the default transition will not introduce any change will make a default app behave different with 12.6.0 compared to 12.5.0.GA. E.g. in the onCreate you set The |
@m1ga Can we conclude this? like do a final review showing me what you want and don't want |
I think for this issue the two switches from ActivityCompat.recreate(this); getTiApp().setRootActivity(null);
ActivityCompat.recreate(this); should be enough (so your Keep the other layout/style/transition changes for another PR so we can test that with another example. As it doesn't change anything for the issue I'm a bit concerned that it might add changes to existing apps and that is not what we want. I just can't test it to see what it will fix. |
@AbdullahFaqeir just a quick bump to see if you could update the PR as describe in the comment above (just keep the It's a big one again (even if it's just a few lines of code 😄 ) and improves the SDK a lot 👍 |
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.
added the places that should be in a different PR
android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
Outdated
Show resolved
Hide resolved
android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
Outdated
Show resolved
Hide resolved
android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
Outdated
Show resolved
Hide resolved
android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
Outdated
Show resolved
Hide resolved
android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
Outdated
Show resolved
Hide resolved
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.
LGTM 👍
Example code in #13825 works fine. Kitchensink and Hyperloop-example still works without an issue
@m1ga @AbdullahFaqeir I doubt that setting the |
@m1ga @AbdullahFaqeir As I mentioned in last comment too, today I found a scenario where it's breaking the app (almost badly). The most common use case is to let an app remain in some fixed light/dark mode irrespective of the system mode. Very common case with many Android apps which allow users to opt among alloy.js
However, if we alter the sequence of above code, alloy.js
So this PR actually makes |
Hi @prashantsaini1 as you can see in the initial issue: #13825 (comment) |
@m1ga Actually this is not related to Fact is that apps do not break by setting I even figured out a more general use case without even setting Run this app and change theme from system settings:
I believe we need to reassess this PR with mentioned use cases that some apps may want to provide user specific light/dark modes, or may be relying on |
I think we should continue this in the old issue (i can reopen it) or create a new issue for it 😄 I was digging through some old Slack logs: 2023/06/11: 2024/05/03: and I had some private chats like this one:
I'm more than happy if you find a way without resetting the rootActivity and making it work as expected! It looks like more people are using this and not |
@m1ga Just a quick update - I did lots of testing on weekend to get the proper fixes to following problems:
Solution for # 1:
Notes for # 2:
I'd appreciate other suggestions! |
@prashantsaini1 that sounds great! Thanks for putting so much effort in it. I know there was some theme setting in this PR in the first commits. As they didn't make any difference in my testes I've requested to removed those but it looks like I was wrong about this. Looking forward to do some tests here with your solutions |
@m1ga Thanks for the hint on theme settings earlier in this PR. I will review them as well to cover up more scenarios! |
Fixes an unexpected behaviour when trying to change the dark/light mode multiple times which causes the screen to go blank and made the change between both animated.