webOS - Displaying Dashboard Notifications

I'm looking for something to help me display dashboard notifications on webOS and later on LuneOS. I've looked at fxspec06's webOS-System-Extension, and it looks the most promising so far, but it does not play nicely with webOS-Lib, and webOS-Lib itself only has support for Banner Messages.

It looks like my other option is to roll my own, using new window() and 'attributes={"window": "dashboard"}', but in that case, I'm not sure now to catch a tap on the dashboard item and have my app respond to it.

Does anyone know if there is any other library for handling dashboard notifications, or if there is a way to catch tap events that would be raised by a Dashboard item opened with new window()?

Comments

  • Forgot to respond to this. I eventually managed to crib something together. I built a webOS Index Page and run the following when I launch:
    enyo.ready(function () {
    	var launcher = new FeedSpider2.webOSWindowManager();
    	launcher.launch();
    });
    This window manager runs headless, and depending on the parameters passed to the app pops up the actual app window, or a dashboard.
    enyo.kind({
    	name: "FeedSpider2.webOSWindowManager",
    	kind: "enyo.Component",
    	components: [	
    		// Application events handlers
    		{kind: "enyo.ApplicationEvents", onrelaunch: "launch"}
    	],
    	handlers: {
    		onUnreadCountUpdated: "notifyUnreadCount"
    	},
    
    	constructor: function() {
    		// These track our currently open windows
    		this.appWindow = null;
    		this.dashboardWindow = null;
    		this.inherited(arguments);
    	},
    
    	launch: function () {
    		var params = webos.launchParams();
    		if (params.action) {
    			switch (params.action) {
    				case "update":
    					var updateApp = new FeedSpider2.Application({name: "notificationfeedspider", action: "update"});
    					updateApp.checkForUpdates(this.notifyUnreadCount);
    					updateApp.setInterval(false);
    					updateApp.destroy();
    					break;
    			}
    		}
    		else {
    			if (this.appWindow == null || this.appWindow == undefined)
    			{
    				this.appWindow = window.open(webos.fetchAppRootPath() + 'index.html', 'feedspiderAppWindow', 'attributes={"window": "card"}');	
    			}
    			else
    			{
    				webos.activate(this.appWindow);
    			}
    		}
    	},
    
    	notifyUnreadCount: function(count) {
    		if (this.dashboardWindow != null && this.dashboardWindow != undefined)
    		{
    			this.dashboardWindow.close();
    		}
    		this.dashboardWindow = window.open(webos.fetchAppRootPath() + "webos-dashboard.html?count=" + count, "feedspiderDashboardWindow", 'attributes={"window": "dashboard"}');
    		}
    	});
    The dashboard is just a simple kind that has been styled to match the design and layout of a webOS dashboard notification.

    webos-dashboard.html:
    enyo.ready(function () {
    	if (window.location.search) {
    		var fields = window.location.search.slice(1).split('&');
    		for (var i = 0, field; field = fields[i]; i++) {
    			fields[i] = field.split('=');
    		}
    		for (var i = 0, field; field = fields[i]; i++) {
    			if (field[0] === "count") {
    				var unreadCount = field[1];
    			}
    		}
    	}
    	new FeedSpider2.DashboardNotification({count: unreadCount}).renderInto(document.body);
    });
    dashboard kind:
    enyo.kind({
    	name: "FeedSpider2.DashboardNotification",
    	style: "color:white;",
    	handlers: {
    		ontap: "handleTap"
    	},
    	components:[
    		{kind: "enyo.FittableColumns", components: [
    			{style: "width: 50px; margin-right: 4px; margin-left: 6px; margin-top: 2px; position: relative;", components: [
    				{style: "width: 48px; height: 48px; background: url(assets/dashboard-icon-feedspider.png) center center no-repeat;" },
    			]},
    			{kind: "enyo.FittableRows", style: "color: #FFF;margin-top: -1px;margin-left: 10px;border: none;overflow: hidden;font-size: 16px;width: 270px;min-height: 53px;", components: [
    				{name: "notificationTitle", style: "white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-weight: bold;padding-top:6px"},
    				{name: "notificationMessage", style: "white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; margin-top: -2px;"}
    			]}
    		]}
    	],
    
    	create: function() {
    		this.inherited(arguments);
    		this.$.notificationTitle.setContent($L("New Articles"));
    		if (arguments[0].count)
    		{
    			this.$.notificationMessage.setContent($L("You have {unread} articles to read", {unread: arguments[0].count}));
    		}
    		else
    		{
    			this.$.notificationMessage.setContent($L("You have {unread} articles to read", {unread: 0}));
    		}
    	},
    
    	rendered: function() {
    		this.inherited(arguments);
    	},
    
    	handleTap: function() {
    		var request = new enyo.ServiceRequest({
    			service: "palm://com.palm.applicationManager",
    			method: "open"
    		});
    		request.go({id: webos.identifier().appID});
    		window.close();	
    	},
    });
    And that's all that there is to it!
Sign In or Register to comment.