-
-
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): problems with "userinterfacestyle" event #13265
Conversation
use TiApplication.onConfigurationChanged instead of BroadcastReceiver fix tidev#13264
Does this potentially fix https://jira.appcelerator.org/browse/TIMOB-28563?? |
This patch fixes only issues with With the patch, applied I can reproduce these two:
Extended app samplelet eventCounter = 0;
let changeCounter = 0;
let lastStyle = getUiStyleName(Ti.UI.userInterfaceStyle)
const win = Ti.UI.createWindow({
backgroundColor: 'primaryBackground'
});
const wrapper = Ti.UI.createView({
layout: 'vertical',
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
center: {
x: '50%',
y: '50%'
}
})
const eventLabel = Ti.UI.createLabel({
text: `style after start: ${lastStyle}`,
color: 'label',
font: {
fontSize: 20
}
});
const eventCounterLabel = Ti.UI.createLabel({
text: `userinterfacestyle events: ${eventCounter}`,
color: 'label',
font: {
fontSize: 20
}
});
const changeCounterLabel = Ti.UI.createLabel({
text: `style changes: ${changeCounter}`,
color: 'label',
font: {
fontSize: 20
}
});
const intervalLabel = Ti.UI.createLabel({
text: ` Ti.UI.userInterfaceStyle: ${lastStyle}`,
color: 'label',
font: {
fontSize: 20
}
});
const overrideDarkButton = Ti.UI.createButton({
title: 'Force dark'
});
overrideDarkButton.addEventListener('click', function() {
Ti.UI.overrideUserInterfaceStyle = Ti.UI.USER_INTERFACE_STYLE_DARK
})
const overrideLightButton = Ti.UI.createButton({
title: 'Force light'
});
overrideLightButton.addEventListener('click', function() {
Ti.UI.overrideUserInterfaceStyle = Ti.UI.USER_INTERFACE_STYLE_LIGHT
})
const overrideRemoveButton = Ti.UI.createButton({
title: 'Remove override '
});
overrideRemoveButton.addEventListener('click', function() {
Ti.UI.overrideUserInterfaceStyle = Ti.UI.USER_INTERFACE_STYLE_UNSPECIFIED
})
wrapper.add(eventLabel);
wrapper.add(intervalLabel);
wrapper.add(eventCounterLabel);
wrapper.add(changeCounterLabel)
wrapper.add(overrideDarkButton);
wrapper.add(overrideLightButton);
wrapper.add(overrideRemoveButton);
win.add(wrapper);
win.open();
Ti.UI.addEventListener('userinterfacestyle', function onUiStyle(event) {
eventLabel.text = `style from event: ${getUiStyleName(event.value)}`;
eventCounterLabel.text = `userinterfacestyle events: ${++eventCounter}`;
});
setInterval(function() {
const current = getUiStyleName(Ti.UI.userInterfaceStyle);
if (current !== lastStyle) {
intervalLabel.text = ` Ti.UI.userInterfaceStyle: ${current}`;
lastStyle = current;
changeCounterLabel.text = `style changes: ${++changeCounter}`
}
}, 500);
function getUiStyleName(mode) {
if (mode === Ti.UI.USER_INTERFACE_STYLE_DARK) {
return 'Dark';
} else if (mode === Ti.UI.USER_INTERFACE_STYLE_LIGHT) {
return 'Light';
} else {
return 'Undefined';
}
} P.S. I stopped creating/checking ticket in the JIRA. |
…_in_props changes from tidev#13265
with the artifact
screencapture-2022-03-26_20.49.32.mp4I'll build from source tomorrow and test it again |
@m1ga fix for I've merged |
Yeah, the "out of date - merge" button was really handy! I'll test the new build later, didn't check the merge times before 👍 |
Don't see any difference between master and this PR. Both change the actionbar and all colors. Tested it on Android 12 (device) and 13 (emulator). |
As the title states, problem is with the
I can reproduce it every time:
Screenshot are made on Android Emulator API 32. master videomaster.mp4 |
Ok, it will go out of sync at one point. Sometime after 3 switches sometimes quicker. I've managed to record a video where it happend at the second time: without PR (master 10.2.0): screencapture-2022-03-27_11.18.57.mp4with PR: screencapture-2022-03-27_11.20.53.mp4Tested the PR with my app and saw no issues. Looks fine to me 👍 @hansemannn |
Thx! Btw, you can use the "Approve" functionality in GitHub to give emphasis to the approval. |
@drauggres You rock! |
use
TiApplication.onConfigurationChanged
instead ofBroadcastReceiver