http://wiki.webos-internals.org/api.php?action=feedcontributions&user=Ansky26&feedformat=atomWebOS Internals - User contributions [en]2024-03-29T15:18:45ZUser contributionsMediaWiki 1.35.1http://wiki.webos-internals.org/index.php?title=Portal:Patches_to_webOS&diff=3325Portal:Patches to webOS2009-08-01T02:35:12Z<p>Ansky26: </p>
<hr />
<div>__notoc__<br />
{{portal-header<br />
|This page lists patches to webOS existing apps which modify the behavior as shipped. '''Note''' that these patches may be version specific and may be broken by future webOS updates. Proceed with caution. If you get one that works please move it under the correct column, alphabetically, and title the page:<br />
'''"Patch [application] [description]"'''<br />
}}<br />
This page is undergoing structuring please contribute moving or adding new entries under the appropriate headings. For now put pages in alphabetical order. Each page should contain at least the basic headings<br />
*1. '''Introduction''': A brief description to introduce people to the patch.<br />
**1.1 '''Usage''':An explanation if it is needed on how to use the modification see Add/Delete Pages in the Launcher as an example.<br />
*2. '''Editing Process''': Step by step instructions to manually edit. <br />
*3. '''Patching Process''': Details for making the edits with a patch file and pointing people to the [[Applying Patches]] page if the patch is also provided in the webos-internals gitorious repository.<br />
<br />
{{portal-three-columns<br />
|column1= <br />
===webOS Update Information===<br />
* [[Update 1.1.0|Update 1.1]]<br />
* [[Update 1.0.4|Update 1.0.4]] <br />
* [[Update 1.0.3|Update 1.0.3]]<br />
<br />
===Patches that Need Work===<br />
* [[Bugs]]<br />
<br />
|column2=<br />
===Patch Ideas to be Created or in Progress===<br />
<br />
* [[Add_Ability_To_Choose_Snooze_Length|Add Ability to Choose Snooze Length]]<br />
* [[Changing_clipboard_data_from_the_shell|Changing Clipboard Data from the Shell]]<br />
* [[Development_%26_Tweak_Ideas | Development & Tweaking Ideas]]<br />
* [[Longer Vibrate|Longer Vibrate]]<br />
* [[More_Calculator_Functions|Accessing additional built-in calculator functions]]<br />
<br />
|column3=<br />
===Notes===<br />
These modifications lack a patch process, please add one to the details to the page and have it added to the webOS-internals gitorious repository. Info for the repository is on [[Applying Patches]].<br />
<br />
*Empty<br />
}}<br />
{{portal-three-columns<br />
|column1= <br />
==Patches to webOS apps==<br />
===webOS 1.1 OK===<br />
<br />
* [[Always_Show_Details_of_New_Tasks|Always Show Details of New Tasks]]<br />
* [[Patch Browser Global Search Addons|Browser: Global Search Addons]]<br />
* [[Bookmarking_MediaPlayer|Bookmarking MediaPlayer]]<br />
* [[Camera Mod Shutter Sound On-Off Button]]<br />
* [[Camera Mod 10 Second Countdown Timer]]<br />
* [[Patch Clock Enabling the Hidden Theme|Clock: Enabling the Hidden Theme]]<br />
* [[Confirm Deletion on Email|Confirm Deletion on Email]]<br />
* [[Patch Email Change Default Font for Replies-Forwards from Navy to Black|Email: Change Default Font for Replies/Forwards from Navy to Black]]<br />
* [[GPS Tracking|GPS Tracking]]<br />
* [[Patch Launcher Add or Delete Pages|Launcher: Add/Delete Pages]]<br />
* [[Patch Launcher Hide-Delete The NASCAR App|Launcher: Hide/Delete The NASCAR App]]<br />
* [[Patch Launcher Unhide the DeveloperMode App|Launcher: Unhide the DeveloperMode App]]<br />
* [[Patch Messaging Character Counter|Messaging: Character Counter]]<br />
* [[Patch Messaging Forward Messages|Messaging: Forward Messages]]<br />
* [[Patch Messaging New Cards For Each Conversation|Messaging: New Cards For Each Conversation]]<br />
* [[Patch MCraig Enabling Personals Category|mCraig: Enabling Personals Category]]<br />
* [[Patch Phone Disable Missed-Dropped Call Sound|Phone: Disable Missed-Dropped Call Sound]]<br />
* [[Patch Phone Edit Dialer Theme|Phone: Edit Dialer Theme]]<br />
* [[Patch Phone Editing the Lock Screen|Phone: Editing the Lock Screen]]<br />
* [[Using Volume Buttons to Take a Picture|Using Volume Buttons to Take a Picture]]<br />
* [[Changing Alarm Clock Button Order and Snooze Duration]]<br />
* [[Download Amazon Music over EVDO]]<br />
* [[Change_Running_Late_Email|Change "Running Late" Email]]<br />
* [[Patch PDF Viewer|PDF Viewer]]<br />
<br />
===Fixed in 1.1 - No longer needed===<br />
* [[Patch Email Fix Broken Formatting|Email: Fix Broken Formatting for E-mails]]<br />
<br />
===Not 1.1 compatible===<br />
* [[Camera_Remote_View|Camera Remote View]]<br />
* [[Downloading From The Browser|Downloading From The Browser]] <br />
* [[Enable Landscape Viewing in Email|Enable Landscape Viewing in Email]] <br />
* [[Fix Email Attachments|Fix Email Attachments]] <br />
<br />
|column2=<br />
==Patches not part of a specific app==<br />
===webOS 1.1 OK===<br />
* [[Boot_Themes|Boot Themes]]<br />
* [[Brightness]]<br />
* [[Bypassing_Activation|Bypassing Activation]]<br />
* [[Change_Carrier_String|Change Carrier String]]<br />
* [[Changing_the_%22Turn_off_after_X%22_time|Changing the "Turn off after X" Time]]<br />
* [[CPU Frequency or Voltage Scaling|CPU Frequency or Voltage Scaling]]<br />
* [[Disable Charging Event Alerts Sounds|Disable Charging Event Alerts Sounds]]<br />
* [[Graphics]]<br />
* [[Keep Phone From Entering Standby While in Remote Session]]<br />
* [[Logging information from within scripts|Logging information from within scripts]]<br />
* [[Message Sound|Message Sound]]<br />
* [[Modifying a Stock App While Keeping the Original|Modifying a Stock App While Keeping the Original]] <br />
* [[Add_Words_to_AutoCorrect_Dictionary|Modify AutoCorrect Dictionary]]<br />
* [[Radio_Power_Switch|Phone On/Off Switch]]<br />
* [[Random Wallpaper Switching|Random Wallpaper Switching]]<br />
* [[Reverse Tunnel|Reverse Tunnel]] <br />
* [[Roam Control|Roam Control]]<br />
* [[Show_Actual_Battery_Percent | Show Actual Battery Percentage]]<br />
<br />
===Fixed in 1.1 - No longer needed===<br />
* Empty<br />
<br />
===Not 1.1 compatible===<br />
* [[Email App Patch to Prompt for IPK Installation|Email App Patch to Prompt for IPK Installation]] <br />
<br />
|column3=<br />
==== The following have not been checked for compatibility with webOS 1.1. ====<br />
<br />
* [[Adding Timestamps to All Received Messages]]<br />
* [[Browser_Plugins|Browser Plugins]]<br />
* [[Camera Mod Alternate Sound Disable]]<br />
* [[Change_Enter_To_Create_Newline_Instead_of_Send_Message|Change Enter to Create Newline Instead of Send Message]]<br />
* [[Change_the_default_notification.wav_Sound|Change the Default notification.wav Sound]]<br />
* [[Changes_Alert/Notification_Sounds|Changes Alert/Notification Sounds]]<br />
* [[Display_Full_Status_Messages(Messenger)|Display Full Status Messages(Messenger)]] <br />
* [[Hourly Chime|Hourly Chime]] <br />
* [[Ignore 'A', 'An', and 'The' In Artist and Album names|Ignore 'A', 'An', and 'The' In Artist and Album names]] <br />
* [[Installing Homebrew Apps With A Rooted Pre|Installing Homebrew Apps With A Linux Accessed Pre]] <br />
* [[Messaging Mod Force Offline Send Without Dialog]]<br />
* [[Modifying Stock Applications|Modifying Stock Applications]] <br />
* [[My notification|My notification]] <br />
* [[Myavatar In Messaging App|Myavatar In Messaging App]] <br />
* [[Packaging Homebrew Apps for Stock Pre without Rooting|Packaging Homebrew Apps for Stock Pre without Accessing Linux]] <br />
* [[Photos Slideshow|Photos Slideshow]] <br />
* [[Screenlock On When Connected|Stay On While Connected]]<br />
* [[Show allday events in calendar month view]] <br />
* [[Show Call Duration in the Call Log]] <br />
* [[Patch Sudoku Disable Zooming|Sudoku: Disable Zooming]]<br />
* [[Turning Off Dialpad Noise]]<br />
<br />
<br />
}}</div>Ansky26http://wiki.webos-internals.org/index.php?title=Patch_PDF_Viewer_Change_Orientation&diff=3324Patch PDF Viewer Change Orientation2009-08-01T02:19:28Z<p>Ansky26: Provide a patch of the modifications for webOS v1.1.0.</p>
<hr />
<div>== Orientation Changes==<br />
=== Introduction===<br />
The PDF viewer on the Palm Pre is capable of displaying documents in landscape mode as well as in portrait mode, however it seems that only portrait mode is enabled by default. I took this as an opportunity to figure out how the Pre handles orientation changes, and also how it interacts with native-code objects embedded in Mojo applications.<br />
<br />
While the official SDK docs have not been released yet, we can make some inferences about the behavior of screen rotation and embedded objects by examining code in the existing applications found in the recovery image. Since the PDF viewer does not have rotation support by default, I examined a program that does: the web browser. I started by grepping for "rotation" and "orientation" within the code, and found that there is a function called "orientationChanged" in the page-assistant controller for the application. However, I found nowhere in the code where this function was defined.<br />
<br />
This leads one to believe that orientationChanged is a function defined as part of the base controller object of Mojo. This is easily confirmed by digging around in /usr/palm/frameworks/mojo and doing a few greps.<br />
<br />
=== Step 1: Allow the PDF viewer to respond to orientation changes.===<br />
<br />
When we're viewing the document, the scene is being controlled by document-assistant.js, which is by default located in:<br />
<br />
/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js.<br />
<br />
Looking at this file, we see that a DocumentAssistant object is created to handle this. Following the model of the Browser example, I simply override the orientationChanged function of the DocumentAssistant object that's created. It doesn't seem to explicitly derive from mojo controllers, but JavaScript uses non-conventional models for extension and inheritance, and mojo also does some magic in the background, so I figure I'll give it a try to see what happens.<br />
<br />
Since the dosetup function creates the embedded PDF viewer object and inserts it, I figure I can simply call that again. However, the dosetup function depends on an element called "install_object_here", which it replaces with the PDF viewer object. Since we'll be subsequently replacing the PDF viewer object on new rotations, we need to make sure that the object still has an ID so it can be located and replaced. The current setup creates the PDF element with no HTML element ID. <br />
<br />
Add a new object attribute line to the dosetup function. You can put it right after the new_obj height attribute (line 718).<br />
<br />
<pre><nowiki><br />
new_obj.setAttribute('id',"install_object_here");<br />
</nowiki></pre><br />
<br />
=== Step 2: Allow the PDF viewer to respond to orientation changes.===<br />
<br />
We now have to create the orientation change handler.<br />
<br />
Add this code to the very end of the file after the "});" (approx. line 1248) . <br />
<br />
The comments explain what is happening.<br />
<pre><nowiki><br />
DocumentAssistant.prototype.orientationChanged = function(orientation) {<br />
//Prevent infinite loops<br />
if(this._orientation === orientation) {<br />
return;<br />
}<br />
this._orientation = orientation;<br />
<br />
//Replace the PDF viewer with an empty div to prevent glitching during the rotate.<br />
var el = this.controller.get('install_object_here');<br />
var em = this.controller.document.createElement('div');<br />
em.id = 'install_object_here'; //Make sure to preserve the element ID<br />
el.parentNode.replaceChild(em, el); //Replace the PDF viewer with an empty div<br />
<br />
//Signal to the windowing system to do the rotate<br />
this.controller.window.PalmSystem.setWindowOrientation(orientation);<br />
<br />
//Re-render the PDF object<br />
this.dosetup();<br />
}<br />
</nowiki></pre><br />
<br />
Before doing the rotation, we replace the PDF rendering object with an empty div. This is because rotating the screen while a PDF rendering object is visible causes weird glitchy appearances. It still works, but it's ugly. Remove the object just before rotating looks much cleaner.<br />
<br />
=== Step 3: Preserve the page state.===<br />
<br />
Now, we just have one other important problem to clean up. When you rotate, the view jumps back to page one, instead of staying on the page you were viewing. To do this, we use a hook that the object establishes. From what I can see, it looks like native code objects can define controller function names that it can call back to. Two that are used by the PDF Viewer are "DocumentOpened" and "FirstDrawComplete". We'll use DocumentOpened here: we don't want to jump through pages until the Document has been parsed and is available. So, in the DocumentOpened function <br />
<br />
We then add this code below the show page count function (line 433).<br />
<br />
<pre><nowiki><br />
this.jumppages = this.currentpage - 1;<br />
this.executeJump();<br />
</nowiki></pre><br />
<br />
<font color='red'>Edit By Matt Clark:<br />
I think you want to becareful with the two prior lines of code. I followed this mod and then when I used a hyperlink inside a pdf to go to a page it just got stuck in a infinite loop and I had to take the battery out to get the palm to restart.</font><br />
<br />
jumppages is a controller-available variable that's used to pass the number of pages to jump to the execute command. It looks like this was done because executeJump is often called within a timer context. I'm not sure, but I'm guessing that they're using this method to avoid creating unnecessary closures.<br />
<br />
The reasoning for the math is: executeJump calls a PDF event that jumps a relative number of pages. Since you're already on page 1, you want to jump forward 1 page to get to page 2, 2 pages to get to page 3, etc. Or, in general, currentpage - 1.<br />
<br />
Once you've added these two lines, the view will jump immediately to the page you were last viewing, when you rotate.<br />
<br />
Now you've got rotatable PDFs!<br />
<br />
=== In Closing===<br />
<br />
In doing this mod, you can get a feel for how Mojo apps handle screen orientation changes. There's also a short example of getting events from native code objects embedded in your Mojo app.<br />
<br />
There's one remaining TODO: it would be nice to correctly preserve the zoom level through rotates. To do this, I'll need to understand how the gestureStart, gestureChange, and gestureEnd events work. This will come soon!<br />
<br />
=== Acknowledgements===<br />
<br />
Thanks to jblebrun for the mod and writeup.<br />
<br />
=== Patch ===<br />
<br />
(Added by ansky26.) Here is a patch encompassing all the above for post v1.1.0. I took the diff after verifying that everything still works, and it does. v1.1.0 just offset the changes by a few lines.<br />
<pre><nowiki><br />
--- a/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js.orig Fri Jul 31 22:07:25 2009<br />
+++ b/usr/palm/applications/com.palm.app.pdfviewer/app/controllers/document-assistant.js Fri Jul 31 22:06:53 2009<br />
@@ -444,6 +444,9 @@<br />
this.controller.setMenuVisible(Mojo.Menu.commandMenu, true);<br />
<br />
this.showPageCnt();<br />
+<br />
+ this.jumppages = this.currentpage - 1;<br />
+ this.executeJump();<br />
},<br />
<br />
doRender: function () {<br />
@@ -739,6 +742,7 @@<br />
var height = this.controller.window.innerHeight - headerHeight;<br />
new_obj.setAttribute('width', width);<br />
new_obj.setAttribute('height', height);<br />
+ new_obj.setAttribute('id',"install_object_here");<br />
<br />
<br />
new_obj.setAttribute('file', this.filename);<br />
@@ -1269,3 +1273,24 @@<br />
},<br />
<br />
});<br />
+<br />
+DocumentAssistant.prototype.orientationChanged = function(orientation) {<br />
+ //Prevent infinite loops<br />
+ if(this._orientation === orientation) {<br />
+ return;<br />
+ }<br />
+ this._orientation = orientation;<br />
+<br />
+ //Replace the PDF viewer with an empty div to prevent glitching during the rotate.<br />
+ var el = this.controller.get('install_object_here');<br />
+ var em = this.controller.document.createElement('div');<br />
+ em.id = 'install_object_here'; //Make sure to preserve the element ID<br />
+ el.parentNode.replaceChild(em, el); //Replace the PDF viewer with an empty div<br />
+<br />
+ //Signal to the windowing system to do the rotate<br />
+ this.controller.window.PalmSystem.setWindowOrientation(orientation);<br />
+<br />
+ //Re-render the PDF object<br />
+ this.dosetup();<br />
+}<br />
+<br />
</nowiki></pre></div>Ansky26