Allow plugins to add panes to mobile nav drawer

This commit is contained in:
fkloft 2013-12-02 23:18:55 +01:00
parent 40d25ad8ef
commit ad6a447bde
4 changed files with 22 additions and 4 deletions

View File

@ -50,6 +50,10 @@
// iitcLoaded: called after IITC and all plugins loaded
// portalDetailLoaded: called when a request to load full portal detail
// completes. guid, success, details parameters
// paneChanged called when the current pane has changed. On desktop,
// this only selects the current chat pane; on mobile, it
// also switches between map, info and other panes defined
// by plugins
window._hooks = {}
window.VALID_HOOKS = [
@ -60,7 +64,7 @@ window.VALID_HOOKS = [
'publicChatDataAvailable', 'factionChatDataAvailable',
'requestFinished', 'nicknameClicked',
'geoSearch', 'iitcLoaded',
'portalDetailLoaded'];
'portalDetailLoaded', 'paneChanged'];
window.runHooks = function(event, data) {
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);

View File

@ -3,6 +3,8 @@
window.show = function(id) {
window.hideall();
runHooks("paneChanged", id);
switch(id) {
case 'full':
window.chat.show('full');
@ -27,9 +29,6 @@ window.show = function(id) {
case 'info':
window.smartphone.sideButton.click();
break;
default:
window.smartphone.mapButton.click();
break;
}
if (typeof android !== 'undefined' && android && android.switchToPane) {

View File

@ -168,4 +168,14 @@ public class IITC_JSInterface {
}
});
}
@JavascriptInterface
public void addPane(final String name, final String label, final String icon) {
mIitc.runOnUiThread(new Runnable() {
@Override
public void run() {
mIitc.getNavigationHelper().addPane(name, label, icon);
}
});
}
}

View File

@ -168,6 +168,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt
}
}
public void addPane(String name, String label, String icon) {
// TODO handle icon
mNavigationAdapter.add(new Pane(name, label, 0));
}
public void closeDrawers() {
mDrawerLayout.closeDrawers();
}