[TIMOB-11264] Android: Event "closeFromActivity" cannot be fired on Android
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-11-26T23:26:50.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 21 API, 2012 Sprint 21 |
Components | Android |
Labels | api, module_android, qe-and100112, qe-testadded, regression, tabgroup |
Reporter | Tamila Smolich |
Assignee | Hieu Pham |
Created | 2012-10-04T23:16:00.000+0000 |
Updated | 2013-04-03T22:57:06.000+0000 |
Description
Description:
While testing Android I noticed, that clicking on Android "back" button, which should return user to the red (previous) window, returns to the apps menue.
In the console getting a warning:
[WARN][V8Object( 334)] Runtime disposed, cannot fire event 'closeFromActivity'
This is a regression, does not occur on 2.1.3.
Steps:
1. Run the following code:
Titanium.UI.setBackgroundColor('#000');
gt = { ui:{} };
gt.ui.createNavigationGroup = function(options)
{
var navGroup =
{
stack: [],
window: options.window,
to_root:options.to_root || false
};
navGroup.open = function(win, options)
{
Ti.API.info('pre open stack length: ' + navGroup.stack.length);
if (navGroup.stack.length == 0)
{
navGroup.window.addEventListener('android:back', navGroup.go_back);
Ti.API.info('addEventListener android:back');
}
navGroup.stack.push(win);
win.open(options);
Ti.API.info('after open stack length: ' + navGroup.stack.length);
};
navGroup.close = function(win, options)
{
var idx = navGroup.stack.indexOf(win);
Ti.API.info('idx: ' + idx);
if (idx != -1) navGroup.stack.splice(idx, 1);
win.close(options);
win = null;
};
navGroup.go_back = function(options)
{
var win = navGroup.stack.pop();
if (win)
{
win.close(options);
win = null;
}
if (navGroup.stack.length == 0)
{
Ti.API.info('removeEventListener android:back');
navGroup.window.removeEventListener('android:back', navGroup.go_back);
Ti.API.info('navGroup window close');
}
};
navGroup.go_home = function()
{
while (navGroup.stack.length)
{
navGroup.go_back();
}
};
return navGroup;
}
var tabGroup = Titanium.UI.createTabGroup();
var navWindow = Ti.UI.createWindow(
{
backgroundColor:'#ccc',
navBarHidden:false
});
var tabWindow = Ti.UI.createWindow(
{
backgroundColor:'#ccc'
});
tabWindow.addEventListener('click', function()
{
navTab.open(navWindow);
});
var navBtn = Ti.UI.createButton(
{
title:'open red win',
color:'#f00',
width:200,
height:40
});
navWindow.add(navBtn);
var nav = gt.ui.createNavigationGroup(
{
window:navWindow
});
navBtn.addEventListener('click', function()
{
var win = Ti.UI.createWindow(
{
backgroundColor:'#fcc'
});
var navBtn2 = Ti.UI.createButton(
{
title:'open yellow win',
color:'#ff0',
width:200,
height:40
});
win.add(navBtn2);
navBtn2.addEventListener('click', function()
{
var win2 = Ti.UI.createWindow(
{
backgroundColor:'#ffc'
});
var navBtn3 = Ti.UI.createButton(
{
title:'close red win',
color:'#000',
width:200,
height:40,
top:50
});
navBtn3.addEventListener('click', function()
{
nav.close(win);
});
win2.add(navBtn3);
var navBtn4 = Ti.UI.createButton(
{
title:'go home',
color:'#0f0',
width:200,
height:40,
top:150
});
navBtn4.addEventListener('click', function()
{
nav.go_home(win);
});
win2.add(navBtn4);
nav.open(win2);
})
nav.open(win);
})
var navTab = Ti.UI.createTab(
{
id: 'navTab',
title:'navGroup',
window:navWindow
});
tabGroup.addTab(navTab);
tabGroup.open();
2. Click "open red win" button
3. Click "open yellow" button
4. Press Android "back" button
Expected:
You should return to the red (previous) window
Actual:
Returning to the apps menue
There's another problem that may or may not be related: In 2.1.3, when you open the red window it opens within the confines of the tab. In 3.0.0 it opens above (larger than) the tab. Investigating. Interestingly, this problem actually brings us _into_ parity with iOS.
And another problem: In 2.1.3, when you open a tabgroup from app.js, that tabgroup becomes the screen, so to speak. No title is above it. In 3.0.0, you get a title bar above the tab (showing the title of the App.)
Creating separate tickets for those.
This is a tabgroup related ticket. Used git bisect to narrow down to commit a7e5694. Re-assigning to api.
master PR: https://github.com/appcelerator/titanium_mobile/pull/3237
Closing as fixed. Verified and tested on: Titanium Studio, build: 3.0.0.201210151149 Titanium SDK, builds: 3.0.0.v20121018140140; 3.1.0.v20121017102121 Device: Nexus 7 (4.1.1)
3_0_X PR: https://github.com/appcelerator/titanium_mobile/pull/3282
This pull request created a regression. if you have multiple textfield, using the next button of the soft keyboard, you could automatically focus the next textfield. That pull request broke that feature.