[TIMOB-14913] Android: SDK 3.1.2 heavyweight/lightweight window confusion
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-08-22T18:22:51.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 18, 2013 Sprint 18 API, Release 3.1.3, Release 3.2.0 |
Components | Android |
Labels | 3.1.2, actionbar, activity, android, qe-testadded, regression, window |
Reporter | Mark Mokryn |
Assignee | Ping Wang |
Created | 2013-08-18T22:17:02.000+0000 |
Updated | 2013-09-04T10:23:06.000+0000 |
Description
Apparently with SDK 3.1.2.GA, Titanium thinks a lightweight window has an associated activity and action bar. In SDK 3.1.1.GA, window.getActivity() returns null for lightweight windows, but not in 3.1.2.GA
index.xml:
<Alloy>
<!-- if we add navBarHidden="false" to Window element it becomes heavyweight,
but if we leave it out 3.1.2 *thinks* it's heavyweight, and crashes. 3.1.1 treats it as lightweight
-->
<Window class="container" id="win1">
<Label id="label1">Just a label</Label>
</Window>
</Alloy>
index.js:
function homeIconClicked() {
alert('clicked');
}
$.win1.addEventListener('open', function() {
if (OS_ANDROID) {
var activity = $.win1.getActivity();
if (!activity){
alert('no activity for this window');
return;
}
var actionBar = activity.actionBar;
if (actionBar){
actionBar.title = 'Window 1';
actionBar.displayHomeAsUp = true;
actionBar.onHomeIconItemSelected = homeIconClicked;
} else {
alert('no action bar');
}
}
});
$.win1.open();
snippet from tiapp.xml:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<tool-api-level>17</tool-api-level>
<manifest android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16"/>
</manifest>
</android>
According to the release notes, TIMOB-13796 was addressed in 3.1.2, which is supposed to have made all Android windows heavyweight. However, I can reproduce your crash using your sample. I can solve the crash by forcing the window to be heavyweight (with navBarHidden or similar set as a window property)
Looking through the code, 3.1.2 does not make all windows heavyweight: Look at postOnCreate in TiApplication.java - USE_LEGACY_WINDOW = true;
For 3.1.2, lightweight windows are still there. We will deprecate LW windows in 3.2.0.
Test case:
For FR, please add
to the tiapp.xml and run the above test case. Should see an alert and the window background color changes from yellow to red. Please also test KS->Base UI->Menu(Android).
PR: https://github.com/appcelerator/titanium_mobile/pull/4590
3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4597
Verified Environment: Studio: 3.1.3.201308201707 Sdk: 3.1.3.v20130822140128 acs:1.0.6 alloy:1.2.1-cr titanium:3.1.2 OS: OSX 10.8.4 Devices:Android Nexus 7(4.3),Samsung Duos(2.3.6),Nexus 7(4.2.1) Used the code given above for alloy project it was reproducible on 3.1.2.GA but now it is resolved. window.getActivity() returns null for lightweight windows in 3.1.3.v20130822140128. but in 3.1.2.GA window.getActivity() returns null for lightweight windows "I/TiAPI(15727): ***********{"bubbleParent":true,"actionBar":{"bubbleParent":true,"title":null}}". Issue is resolved now as window.getActivity() returns null for lightweight windows using 3.1.3.v20130822140128 sdk. Thus closing as fixed.