[TIMOB-25756] Android: Restart app on system locale change
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-11-09T21:06:26.000+0000 |
Affected Version/s | Release 7.1.0 |
Fix Version/s | Release 7.5.0 |
Components | Android |
Labels | android, android:configChanges, locale |
Reporter | Jorge Macias Garcia |
Assignee | Gary Mathews |
Created | 2017-12-19T11:53:17.000+0000 |
Updated | 2018-11-15T07:31:08.000+0000 |
Description
Apps in Titanium doesn't restart the activities when locale config has changed and the broadcast event is fired.
From the documentation:
https://developer.android.com/guide/topics/manifest/activity-element.html#config
"Locale" The locale has changed; the user selected a new text language.
As you can see in the documentation page. If android:configChanges are added to the manifest in an activity block is the app who should handle this changes. If not, the app is restarted by default (as expected).
I found this broadcast handler in the titanium source code but the behaviour isn't as expected.
Adding 'locale' to android:configChange doesn't works.
Generated and modified manifest (adding locale to android:configChanges):
<activity android:name=".AppTestActivity" android:label="@string/app_name" android:theme="@style/Theme.Titanium" android:configChanges="keyboardHidden|orientation|fontScale|screenSize|smallestScreenSize|screenLayout|density|locale">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
I've tried removing android:configChanges attribute in my custom manifest to get the default behaviour but it is added again.
By default the generated manifest by Titanium has the android:configChanges flag enabled with custom properties. It's Titanium who handles this changes.
TEST APP:
Languages: en, es
Expected behaviour: Settings > Languages > Change language > Come back to app > Activity has been restarted with new language
Current behaviour: Settings > Languages > Change language > Come back to app > Activity hasn't been restarted with new language
Attachments
File | Date | Size |
---|---|---|
android-lang-behaviour.gif | 2018-01-02T09:57:13.000+0000 | 1030671 |
android-restart-app-when-language-changed.gif | 2018-02-05T07:29:29.000+0000 | 1817156 |
app.zip | 2018-01-02T09:57:49.000+0000 | 7124503 |
locale_8.1.gif | 2018-11-09T21:03:44.000+0000 | 552702 |
Hello, Please provide a full reproducible code for us to test. Thanks.
Hello [~jormagar], Are you able to sorted this out? If not ,please provide a sample test code to reproduce the issue on our end? Best
@Mostafizur Rahman, @Sharif AbuDarna, sorry for the delay. Just updated the ticket.
Hello, With the sample code you provided I wasn't able to reproduce the issue with Android 8.0.0. In SDK 7.0.1.GA. With language change, activity has been restarted with new language. Thanks.
!android-restart-app-when-language-changed.gif! I recompiled the test app with latest sdk 7.0.1 with Android 8 sim and it's not working. As you can see in the attached gif, you need to kill the app and open it again to get working the changed language. On iOS platform it is done on the air and not need to kill / restart the app to see the new language. The right behaviour on Android would be: - Open app and leave the app on background - Go to settings and change language - Come back to your running app from recent tasks. - App should be restarted by system.
master: https://github.com/appcelerator/titanium_mobile/pull/9937
I think given that the PR is still marked a work in progress that this won't make the cut for 7.2.0. Bumping to 7.3.0 for now.
FR Passed.
PR Merged.
Verified the fix on SDK 7.5.0.v20181015122219 .Works fine. Closing
It doesn't works fine... test app crashes on Android 8.1 simulator. Steps: 1. Open test app and send it to background pressing on home button. 2. Open language settings and set spanish to main language 3. Open recent apps and select test app, it is restarted as expected. It could work or not. See attached new GIF
[Locale changed not solved](http://personales.upv.es/jormagar/gif/locale_changed_still_fail.gif)
[~jormagar], App will soft restart only when there is no locale change event listener. This is by design. I tried but not able to repro the crash. !locale_8.1.gif!
Had reopened to add a gif.
You are not trying what I'm reporting. Follow the steps to get the crash please.
[~lchoudhary] Can you check what the value of
run-on-main-thread
in tiapp.xml is in the application you ran? I was able to reproduce the crash with it when the property is set to false.[~ybanev], I have it set to
true
@lchoudhary set it to false and see what happens with the app testing again the use case. You will check how it crashes.