diff --git a/Alloy/commands/compile/parsers/Ti.Android.ActionBar.js b/Alloy/commands/compile/parsers/Ti.Android.ActionBar.js index 29de1c9e4..f8840837c 100644 --- a/Alloy/commands/compile/parsers/Ti.Android.ActionBar.js +++ b/Alloy/commands/compile/parsers/Ti.Android.ActionBar.js @@ -12,7 +12,7 @@ function parse(node, state, args) { var eventObject = 'e', code = '', xmlStyles = {}, - actionBarProperties = ['title', 'subtitle', 'backgroundImage', 'displayHomeAsUp', 'homeButtonEnabled', 'icon', 'logo', 'navigationMode', 'onHomeIconItemSelected']; + actionBarProperties = ['title', 'subtitle', CONST.BACKGROUND_IMAGE, CONST.DISPLAY_HOME_AS_UP, CONST.HOME_BUTTON_ENABLED, 'icon', 'logo', CONST.NAVIGATION_MODE, CONST.ON_HOME_ICON_ITEM_SELECTED]; // if this isn't android, generate no code, but show a warning var config = CU.getCompilerConfig(), diff --git a/Alloy/commands/compile/parsers/Ti.UI.Toolbar.js b/Alloy/commands/compile/parsers/Ti.UI.Toolbar.js index 8cb96e00d..c130e1175 100644 --- a/Alloy/commands/compile/parsers/Ti.UI.Toolbar.js +++ b/Alloy/commands/compile/parsers/Ti.UI.Toolbar.js @@ -1,6 +1,7 @@ var _ = require('../../../lib/alloy/underscore')._, tiapp = require('../../../tiapp'), U = require('../../../utils'), + CONST = require('../../../common/constants'), CU = require('../compilerUtils'); exports.parse = function(node, state) { @@ -16,7 +17,7 @@ exports.parse = function(node, state) { code = '', xmlStyles = {}; // Properties inherited from ActionBar when Toolbar is passed to the Activity - var inheritedProperties = ['backgroundImage', 'displayHomeAsUp', 'homeButtonEnabled', 'navigationMode', 'onHomeItemSelected']; + var inheritedProperties = [CONST.BACKGROUND_IMAGE, CONST.DISPLAY_HOME_AS_UP, CONST.HOME_BUTTON_ENABLED, CONST.NAVIGATION_MODE, CONST.ON_HOME_ICON_ITEM_SELECTED]; state = _.extend(state, { itemContainerDefinition: { diff --git a/Alloy/common/constants.js b/Alloy/common/constants.js index 1e1aef718..79e7007f8 100755 --- a/Alloy/common/constants.js +++ b/Alloy/common/constants.js @@ -68,6 +68,13 @@ exports.MODEL_ELEMENTS = ['Alloy.Collection', 'Alloy.Model']; exports.MODEL_BINDING_EVENTS = 'fetch change destroy'; exports.COLLECTION_BINDING_EVENTS = 'fetch destroy change add remove reset'; +// Constants for properties shared between ActionBar and Toolbar on Android +exports.BACKGROUND_IMAGE = 'backgroundImage'; +exports.DISPLAY_HOME_AS_UP = 'displayHomeAsUp'; +exports.HOME_BUTTON_ENABLED = 'homeButtonEnabled'; +exports.NAVIGATION_MODE = 'navigationMode'; +exports.ON_HOME_ICON_ITEM_SELECTED = 'onHomeIconItemSelected'; + // Listings for supported platforms and commands exports.INSTALL_TYPES = ['plugin']; exports.GENERATE_TARGETS = ['controller', 'jmk', 'model', 'migration', 'view', 'widget', 'style']; diff --git a/test/apps/testing/ALOY-1584/_generated/android/alloy/controllers/index.js b/test/apps/testing/ALOY-1584/_generated/android/alloy/controllers/index.js new file mode 100644 index 000000000..6a9b83016 --- /dev/null +++ b/test/apps/testing/ALOY-1584/_generated/android/alloy/controllers/index.js @@ -0,0 +1,62 @@ +function __processArg(obj, key) { + var arg = null; + if (obj) { + arg = obj[key] || null; + delete obj[key]; + } + return arg; +} + +function Controller() { + function __alloyId0() { + $.__views.index.removeEventListener("open", __alloyId0); + if ($.__views.index.activity) { + $.__views.index.activity.setSupportActionBar($.__views.toolBarID); + $.__views.index.activity.actionBar.displayHomeAsUp = true; + $.__views.index.activity.actionBar.homeButtonEnabled = true; + } else { + Ti.API.warn("You attempted to access an Activity on a lightweight Window or other"); + Ti.API.warn("UI component which does not have an Android activity. Android Activities"); + Ti.API.warn("are valid with only windows in TabGroups or heavyweight Windows."); + } + } + require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); + this.__controllerPath = "index"; + this.args = arguments[0] || {}; + if (arguments[0]) { + __processArg(arguments[0], "__parentSymbol"); + __processArg(arguments[0], "$model"); + __processArg(arguments[0], "__itemTemplate"); + } + var $ = this; + var exports = {}; + $.__views.index = Ti.UI.createWindow({ + title: "My Test App", + backgroundColor: "gray", + customToolbar: "toolBarID", + theme: "Theme.AppCompat.NoTitleBar", + id: "index" + }); + $.__views.index && $.addTopLevelView($.__views.index); + $.__views.toolBarID = Ti.UI.createToolbar({ + id: "toolBarID", + title: "MyMenu", + subtitle: "Subtitle", + width: Ti.UI.FILL, + top: 0, + homeButtonEnabled: true, + displayHomeAsUp: true, + onHomeIconItemSelected: "clickAlert", + barColor: "#639851" + }); + $.__views.index.add($.__views.toolBarID); + $.__views.index.addEventListener("open", __alloyId0); + exports.destroy = function() {}; + _.extend($, $.__views); + $.index.open(); + _.extend($, exports); +} + +var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._; + +module.exports = Controller; \ No newline at end of file diff --git a/test/apps/testing/ALOY-1584/_generated/ios/alloy/controllers/index.js b/test/apps/testing/ALOY-1584/_generated/ios/alloy/controllers/index.js new file mode 100644 index 000000000..6a9b83016 --- /dev/null +++ b/test/apps/testing/ALOY-1584/_generated/ios/alloy/controllers/index.js @@ -0,0 +1,62 @@ +function __processArg(obj, key) { + var arg = null; + if (obj) { + arg = obj[key] || null; + delete obj[key]; + } + return arg; +} + +function Controller() { + function __alloyId0() { + $.__views.index.removeEventListener("open", __alloyId0); + if ($.__views.index.activity) { + $.__views.index.activity.setSupportActionBar($.__views.toolBarID); + $.__views.index.activity.actionBar.displayHomeAsUp = true; + $.__views.index.activity.actionBar.homeButtonEnabled = true; + } else { + Ti.API.warn("You attempted to access an Activity on a lightweight Window or other"); + Ti.API.warn("UI component which does not have an Android activity. Android Activities"); + Ti.API.warn("are valid with only windows in TabGroups or heavyweight Windows."); + } + } + require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); + this.__controllerPath = "index"; + this.args = arguments[0] || {}; + if (arguments[0]) { + __processArg(arguments[0], "__parentSymbol"); + __processArg(arguments[0], "$model"); + __processArg(arguments[0], "__itemTemplate"); + } + var $ = this; + var exports = {}; + $.__views.index = Ti.UI.createWindow({ + title: "My Test App", + backgroundColor: "gray", + customToolbar: "toolBarID", + theme: "Theme.AppCompat.NoTitleBar", + id: "index" + }); + $.__views.index && $.addTopLevelView($.__views.index); + $.__views.toolBarID = Ti.UI.createToolbar({ + id: "toolBarID", + title: "MyMenu", + subtitle: "Subtitle", + width: Ti.UI.FILL, + top: 0, + homeButtonEnabled: true, + displayHomeAsUp: true, + onHomeIconItemSelected: "clickAlert", + barColor: "#639851" + }); + $.__views.index.add($.__views.toolBarID); + $.__views.index.addEventListener("open", __alloyId0); + exports.destroy = function() {}; + _.extend($, $.__views); + $.index.open(); + _.extend($, exports); +} + +var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._; + +module.exports = Controller; \ No newline at end of file diff --git a/test/apps/testing/ALOY-1584/_generated/mobileweb/alloy/controllers/index.js b/test/apps/testing/ALOY-1584/_generated/mobileweb/alloy/controllers/index.js new file mode 100644 index 000000000..6a9b83016 --- /dev/null +++ b/test/apps/testing/ALOY-1584/_generated/mobileweb/alloy/controllers/index.js @@ -0,0 +1,62 @@ +function __processArg(obj, key) { + var arg = null; + if (obj) { + arg = obj[key] || null; + delete obj[key]; + } + return arg; +} + +function Controller() { + function __alloyId0() { + $.__views.index.removeEventListener("open", __alloyId0); + if ($.__views.index.activity) { + $.__views.index.activity.setSupportActionBar($.__views.toolBarID); + $.__views.index.activity.actionBar.displayHomeAsUp = true; + $.__views.index.activity.actionBar.homeButtonEnabled = true; + } else { + Ti.API.warn("You attempted to access an Activity on a lightweight Window or other"); + Ti.API.warn("UI component which does not have an Android activity. Android Activities"); + Ti.API.warn("are valid with only windows in TabGroups or heavyweight Windows."); + } + } + require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); + this.__controllerPath = "index"; + this.args = arguments[0] || {}; + if (arguments[0]) { + __processArg(arguments[0], "__parentSymbol"); + __processArg(arguments[0], "$model"); + __processArg(arguments[0], "__itemTemplate"); + } + var $ = this; + var exports = {}; + $.__views.index = Ti.UI.createWindow({ + title: "My Test App", + backgroundColor: "gray", + customToolbar: "toolBarID", + theme: "Theme.AppCompat.NoTitleBar", + id: "index" + }); + $.__views.index && $.addTopLevelView($.__views.index); + $.__views.toolBarID = Ti.UI.createToolbar({ + id: "toolBarID", + title: "MyMenu", + subtitle: "Subtitle", + width: Ti.UI.FILL, + top: 0, + homeButtonEnabled: true, + displayHomeAsUp: true, + onHomeIconItemSelected: "clickAlert", + barColor: "#639851" + }); + $.__views.index.add($.__views.toolBarID); + $.__views.index.addEventListener("open", __alloyId0); + exports.destroy = function() {}; + _.extend($, $.__views); + $.index.open(); + _.extend($, exports); +} + +var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._; + +module.exports = Controller; \ No newline at end of file diff --git a/test/apps/testing/ALOY-1584/_generated/windows/alloy/controllers/index.js b/test/apps/testing/ALOY-1584/_generated/windows/alloy/controllers/index.js new file mode 100644 index 000000000..6a9b83016 --- /dev/null +++ b/test/apps/testing/ALOY-1584/_generated/windows/alloy/controllers/index.js @@ -0,0 +1,62 @@ +function __processArg(obj, key) { + var arg = null; + if (obj) { + arg = obj[key] || null; + delete obj[key]; + } + return arg; +} + +function Controller() { + function __alloyId0() { + $.__views.index.removeEventListener("open", __alloyId0); + if ($.__views.index.activity) { + $.__views.index.activity.setSupportActionBar($.__views.toolBarID); + $.__views.index.activity.actionBar.displayHomeAsUp = true; + $.__views.index.activity.actionBar.homeButtonEnabled = true; + } else { + Ti.API.warn("You attempted to access an Activity on a lightweight Window or other"); + Ti.API.warn("UI component which does not have an Android activity. Android Activities"); + Ti.API.warn("are valid with only windows in TabGroups or heavyweight Windows."); + } + } + require("/alloy/controllers/BaseController").apply(this, Array.prototype.slice.call(arguments)); + this.__controllerPath = "index"; + this.args = arguments[0] || {}; + if (arguments[0]) { + __processArg(arguments[0], "__parentSymbol"); + __processArg(arguments[0], "$model"); + __processArg(arguments[0], "__itemTemplate"); + } + var $ = this; + var exports = {}; + $.__views.index = Ti.UI.createWindow({ + title: "My Test App", + backgroundColor: "gray", + customToolbar: "toolBarID", + theme: "Theme.AppCompat.NoTitleBar", + id: "index" + }); + $.__views.index && $.addTopLevelView($.__views.index); + $.__views.toolBarID = Ti.UI.createToolbar({ + id: "toolBarID", + title: "MyMenu", + subtitle: "Subtitle", + width: Ti.UI.FILL, + top: 0, + homeButtonEnabled: true, + displayHomeAsUp: true, + onHomeIconItemSelected: "clickAlert", + barColor: "#639851" + }); + $.__views.index.add($.__views.toolBarID); + $.__views.index.addEventListener("open", __alloyId0); + exports.destroy = function() {}; + _.extend($, $.__views); + $.index.open(); + _.extend($, exports); +} + +var Alloy = require("/alloy"), Backbone = Alloy.Backbone, _ = Alloy._; + +module.exports = Controller; \ No newline at end of file diff --git a/test/apps/testing/ALOY-1584/controllers/index.js b/test/apps/testing/ALOY-1584/controllers/index.js new file mode 100644 index 000000000..4fe1fa894 --- /dev/null +++ b/test/apps/testing/ALOY-1584/controllers/index.js @@ -0,0 +1,5 @@ +function clickAlert() { + alert('Alert!'); +} + +$.index.open(); \ No newline at end of file diff --git a/test/apps/testing/ALOY-1584/views/index.xml b/test/apps/testing/ALOY-1584/views/index.xml new file mode 100644 index 000000000..84912c04f --- /dev/null +++ b/test/apps/testing/ALOY-1584/views/index.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file