06-04-2012, 08:24 AM | #1 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
WAFs: useful hints and problems
Hi there!!
I'm opening this thread to sum up hints and problems related to WAFs. I'd wish it become a place where to share info and help each other solving problems... First of all, here's a link to Aditya3098's website with a guide and some WAFs. Here's a small list of what I discovered: click Now, a small list of problems I encountered: - update from 5.0.4 to 5.1.0: pinch-to-zoom stopped working. I can make it working creating a new content window but then I get a big mess from the rest of the page!! It can't be turned on even with Code:
kindle.viewport.setPinchZoomState(true); And, finally, a question: Besides HTML standard events (onClick etc...), does the Kindle has a set of built-in events to handle long tap, double tap or similar? |
06-10-2012, 10:11 AM | #2 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
Nice: 153 views, 11 downloads but nobody shared anything...
|
06-10-2012, 10:15 AM | #3 |
Going Viral
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
|
06-10-2012, 10:22 AM | #4 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
|
06-10-2012, 10:38 AM | #5 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
It would be nice if others collaborate to get your University homework finished on time.
It seems to take quite awhile before others start contributing to things that you started. For example, in the Tools Index, there is a "Newbies Guide to Kindle Development" that I started a LONG time ago, and still no new contributors. It seems that you need to get above a minimum USEFUL content that you add yourself, before others start adding stuff, which I did not achieve in that (mostly empty) guide, apparently. Last edited by geekmaster; 06-10-2012 at 10:43 AM. |
06-10-2012, 10:54 AM | #6 | |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
Quote:
I hope to improve myself, but, till then, this is what I have! |
|
06-10-2012, 11:48 AM | #7 |
Addict
Posts: 396
Karma: 33660
Join Date: Jul 2011
Device: Kindle 3, Kindle 4, Kindle PW, Nexus7 3G
|
You are useful to others, be sure. At least for me!
|
09-27-2012, 08:02 AM | #8 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
New update...
Here is what I discovered last time. How to catch menu and back button: Code:
kindle.messaging.receiveMessage('searchBarButtonSelected', YOUR_FUNCTION HERE); function YOUR_FUNCTION HERE (property, json){ if ((property == 'searchBarButtonSelected') && (json == 'menu')){ do something when menu button is choosed } if ((property == 'searchBarButtonSelected') && (json == 'back')){ do something when back button is choosed } } Code:
<kindle:messaging> <kindle:app name="com.lab126.pillow" value="yes"/> </kindle:messaging> This could be used to read any other message...you just need to find the message (showlog -f) and duplicate the system used by pillow. Example: place this in config.xml: Code:
<kindle:app name="com.lab126.adManager" value="yes" /> Code:
kindle.messaging.receiveMessage('adViewerMsgCallback', YOUR_FUNCTION_HERE); How to increase the available memory for WAFs: Code:
sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('YOUR_APP_HERE','memUnloadLevel','150000')" sqlite3 /var/local/appreg.db "INSERT INTO properties (handlerId, name, value) VALUES ('YOUR_APP_HERE','memWarnLevel','71680')" Content window & CO: You can use the index.html page of your WAF as a landing page. Then you can use Code:
kindle.chrome.createContentWindow(YOUR_PAGE_HERE); Code:
YOUR_PAGE_HERE = "/mnt/us/hello.html" Code:
kindle.chrome.setContentWinDisplay('foreground'); kindle.chrome.setContentWinDisplay('background'); EDIT: I forgot to mention that content windows have PINCH-TO-ZOOM (I still don't understand why WAFs can't have it). Search in wikipedia from a WAF: You can launch a wiki search this way: Code:
search = YOUR_SEARCH_HERE remoteUri = "http://en.wikipedia.org/wiki/"+search; kindle.appmgr.start('com.lab126.browser?view=' + remoteUri ); This can obviously used to search everything on the internet using the browser. You can return to your WAF using the back button. Miscellaneous: These should be self explanatory... Code:
kindle.gestures.ontap = function () { } kindle.appmgr.onback = function () { } kindle.gestures.onswipe = function () { } kindle.appmgr.back() kindle.appmgr.onforward = function () { } kindle.dev.clearApplicationCache() kindle.dev.clearCookies() kindle.dev.clearCache() Now....anyone knows how to create a menu like the one used by the browser? I tried to study the browser WAF but the menu thing is just...beyond my knowledge... Last edited by silver18; 09-27-2012 at 08:07 AM. |
09-27-2012, 10:36 AM | #9 |
but forgot what it's like
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
|
I've tried to look at how menu is populated in browser app and found something useful.
Here is patch for enabling orientation menu item in browser (tested on 5.1.2): Code:
--- /var/local/waf/browser/js/menuItems.js.orig +++ /var/local/waf/browser/js/menuItems.js @@ -89,7 +89,13 @@ // add dynamic items - TODO: Add lock rotation if ever re-implemented items.splice(0, 0, createWireless()); items.splice(2, 0, createArticle()); + items.splice(2, 0, createRotation()); + var orientationItem = createOrientation(); + if (orientationItem) { + items.splice(2, 0, orientationItem); + } + return items; }; @@ -124,6 +130,32 @@ bapp.dialog.hide(); } }; + }; + + var createOrientation = function () { + if (settings && settings.orientation && settings.orientation == 'auto') { + return null; + } + + var label, + state = bapp.getOrient(); + + if (state == 'portrait') { + label = 'Landscape Mode'; + state = 'landscape'; + } + else if (state == 'landscape') { + label = 'Portrait Mode'; + state = 'portrait'; + } + + return { + label: label, + action: function () { + bapp.setOrientation(state); + bapp.dialog.hide(); + } + }; }; /**
bapp.setOrientation function (which in fact calls kindle.dev.setOrientation) supports following argument values:
I'm not providing detailed instruction on how to make needed changes, because it's a bit "dangerous". It will not crash or brick KT, but could stop future firmware updates to proceed. But, I believe, other forum users willl provide user-friendly instructions. Anyway, make backups of changed files before applying of changes! (Also these new menu items aren't localized. It could be easily done, though: add new strings at /var/local/waf/browser/locales/<locale>/js/strings.js and then use bapp.strings.<your string> in place of menu label value.) UPD: oh, credits for discovering kindle.dev.setOrientation and all of it's argument values should go to silver18. UPD2: on boot (i.e. after reboot) all changes made in files of /var/local/waf and it's sub-direcories will be lost, because upstart job /etc/init/appmgrd.conf will uncoditionally copy there files from /opt/var/local/waf. So, it means that (as simple, but not only solution) changes must be applied to file in /opt/var/local/waf too. Last edited by eureka; 09-27-2012 at 04:05 PM. Reason: changes to stock WAF app will be lost on reboot |
10-08-2012, 07:39 AM | #10 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
While still trying to figure out how to create a menu, I'm here to share a new idea...
Some WAFs use kindle.messaging.sendMessage to send messages to lipc. Here's how the adviewer does it: Code:
kindle.messaging.sendMessage('com.lab126.adManager', 'adViewerMessage', buildMsgReq(START_BROWSE, params)); If we could bind our WAFs lipcId to some properties, we could use lipc to run a script from inside a WAF by sending the corresponding message. The point is I can't find where all services and all properties are declared. NB We can already do the opposite by reading messages in a WAF from lipc. This works, for example, for getting interactions with the search bar |
10-19-2012, 11:39 AM | #11 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
This is used to update the titlebar according to the contentWindow title (and when the contentWindow title changes):
Code:
kindle.chrome.onContentTitleChanged = function (title) { kindle.chrome.setTitleBar('', title); } And this is used to take control on the searchbar buttons (store, back and menu). As described before, we can use those buttons to trigger any function but we need first to take control on them (i.e setting the button to "notifyApp"). We can also disable buttons (they become grayed). Code:
function setupSearchBar(){
var json = {
"appId": "YOUR APP ID HERE",
"searchBar": {
"clientParams": {
"profile": {
"name": "default",
"buttons": [
{
"id": "menu",
"state": "enabled",
"handling":"notifyApp"
},
{
"id": "back",
"state": "disabled",
"handling":"notifyApp" },
{
"id": "store",
"state": "enabled",
"handling":"system"
}
]
}
}
}
};
kindle.messaging.sendMessage('com.lab126.pillow', 'configureChrome', json);
}
|
10-19-2012, 11:48 AM | #12 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
And again...
Here's how to display the forward button (add this to the json variable shown before) Code:
{ "id": 'forward', "state": "enabled", "handling": "notifyApp", } Code:
{ "id": 'refresh', "state": "enabled", "handling": "notifyApp", } |
10-19-2012, 12:04 PM | #13 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
This is a screenshot showing the searchbar modded: back & forward buttons + search + menu button.
Back & forward buttons are enabled/disabled dinamically. I'm studying about the menu thing... |
11-16-2012, 09:18 AM | #14 |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
Some more information... This time we're talking about
KINDLE MENU I packed all relevant files in a zip file. Feel free to modify them! 1) First of all you need to add a menu template in your html page: Code:
<script id="menuTemplate" type="text/x-jquery-tmpl"> <div class='temp-dialog'> <div class='header'> <div class='close'/> <div class='title'> ${titleText} </div> </div> <ul class='overlaylist'> <li id='orientation' class='action'></li> <li id='bookmarks' class='action'></li> <li id='deletions' class='action'></li> <li id='options' class='action'></li> <li id='lastread'></li> </ul> </div> </script> - header with title and close button - overlaylist with all menu entry you need. You must use an unambiguous id for every entry (here we have orientation, bookmarks, deletions, options and lastread). If you need to make one entry non-clickable, just remove the action class. 2) Then you need to link jquery.js, jquery.tmpl.js and some other js and css files (menu.js, windowing.js and menu.css): Code:
<script type="text/javascript" src="resource/Lib/jquery.js"></script> <script type="text/javascript" src="resource/Lib/jquery.tmpl.js"></script> <script language="Javascript" src="resource/Javascripts/MenuDialog/menu.js"></script> <script language="Javascript" src="resource/Javascripts/MenuDialog/windowing.js"></script> <link rel="stylesheet" type="text/css" href="resource/CSS/MenuDialog/menu.css" /> 3) And then you need to bind the onClick event to something in order to display the menu when tapping a button/image/div: Code:
onClick="new KomicMenu().showMenu();"/> 4) Once you set up everything, you can now enjoy yourself altering the code in menu.js to suit your needings. You can also play with menu.css! 5) Now you just need to change the path to every file according to where you placed the those files. Download the package here!!! EDIT: I forgot a nice screenshot!!! Last edited by silver18; 11-16-2012 at 09:21 AM. |
11-19-2012, 07:48 AM | #15 | |
THE NOOB
Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
Quote:
While I still think the solution posted above is the real solution to this problem, one could also act this way: 1) use inside JavaScript Code:
kindle.messaging.sendMessage(YOUR_WAF_HERE, YOUR_PROPERTY_HERE, YOUR_MESSAGE_HERE); Code:
<kindle:app name="YOUR_WAF_HERE" value="yes" /> Code:
121119:133711 wafapp[1882]: W lipc:pnr:prop=YOUR_PROPERTY:Property not registered 121119:133711 wafapp[1882]: E com.silver18.komic001:LipcAdapter::setProperty:Failed to set string property YOUR_PROPERTY: This means, on the other hand, having something running in background (I don't like this!!) |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Classic Nook on screen hints? | Hellmark | Barnes & Noble NOOK | 4 | 08-12-2011 08:54 AM |
Tips, Tricks, and Hints | Nate the great | Amazon Kindle | 44 | 03-22-2011 04:15 AM |
The Times hints at release of new Kindle | Grumpyreader | News | 0 | 06-04-2010 12:36 PM |
Q7 - v3.0 firmware - Hints and Tricks | rogue_ronin | Alternative Devices | 8 | 06-30-2009 02:59 PM |
Any hints on first software update? | Leaping Gnome | Sony Reader | 32 | 12-07-2006 10:22 AM |