Difference between revisions of "Patch Browser Downloading Files"
Jump to navigation
Jump to search
Fritos1406 (talk | contribs) |
Fritos1406 (talk | contribs) |
||
| Line 4: | Line 4: | ||
8/15/09 -1.1 Working Patch Up And Ready | 8/15/09 -1.1 Working Patch Up And Ready | ||
| + | |||
Edit: Anything can be downloaded in this patch, but must download directly from the download link/url. | Edit: Anything can be downloaded in this patch, but must download directly from the download link/url. | ||
Revision as of 07:57, 16 August 2009
NOTE -- This is newly 1.1 compatible
8/15/09 -1.1 Working Patch Up And Ready
Edit: Anything can be downloaded in this patch, but must download directly from the download link/url.
Must Be In [root@castle:/#] not [username@castle] to work !
cd /opt/src/modifications git pull quilt import /opt/src/modifications/browser/enable-browser-downloads.patch cd / quilt push reboot
-All Done Patch Applied!
NOTE- Swipe to remove finished downloads widget at the bottom of the page, Must not be zoomed in to view
PATCH CODE
Index: /usr/palm/applications/com.palm.app.browser/app/controllers/downloaddialog-assistant.js
===================================================================
--- /dev/null
+++ /usr/palm/applications/com.palm.app.browser/app/controllers/downloaddialog-assistant.js
@@ -0,0 +1,45 @@
+/**
+ * A dialog assistant for display of yes/no box.
+ */
+DownloadDialogAssistant = Class.create({
+
+ initialize: function(params) {
+ this.onDismiss = params.onDismiss;
+ this.onAccept = params.onAccept;
+ this.controller= params.sceneAssistant.controller;
+
+ // Button handlers.
+ this.onDismissHandler = this.handleDismiss.bindAsEventListener(this);
+ this.onAcceptHandler = this.handleAccept.bindAsEventListener(this);
+ },
+
+ setup: function(widget) {
+ this.widget = widget;
+ this.controller.get('acceptButton').addEventListener(Mojo.Event.tap, this.onAcceptHandler);
+ this.controller.get('acceptButton').focus();
+ this.controller.get('dismissButton').addEventListener(Mojo.Event.tap, this.onDismissHandler);
+ this.controller.get('dismissButton').focus();
+ },
+
+ handleDismiss: function() {
+ this.onDismiss();
+ delete this.onDismiss;
+ this.widget.mojo.close();
+ },
+ handleAccept: function() {
+ this.onAccept();
+ delete this.onAccept;
+ this.widget.mojo.close();
+ },
+
+ cleanup: function() {
+ Mojo.Log.info("NetworkDialogAssistant#cleanup()");
+ Mojo.Event.stopListening(this.controller.get('dismissButton'), Mojo.Event.tap, this.onDismissHandler);
+ Mojo.Event.stopListening(this.controller.get('acceptButton'), Mojo.Event.tap, this.onAcceptHandler);
+
+ // Send a dismiss if NOT already sent a response
+ if (this.onDismiss) {
+ this.onDismiss();
+ }
+ }
+});
Index: /usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
===================================================================
--- .orig/usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
+++ /usr/palm/applications/com.palm.app.browser/app/controllers/global_code.js
@@ -1449,6 +1449,8 @@ PageAssistant.prototype.setup = function
this._webView.addEventListener(Mojo.Event.webViewUrlRedirect, this._onUrlRedirect.bind(this), false);
this._webView.addEventListener(Mojo.Event.webViewModifierTap, this._onModifierTapHandler, false);
this._webView.addEventListener(Mojo.Event.webViewUpdateHistory, this._onUpdateHistoryHandler, false);
+ this._downloadController = new DownloadController(this.controller);
+ this._downloadController.setup();
}
catch (e) {
Mojo.Log.logException(e, 'PageAssistant#setup');
@@ -2287,28 +2289,39 @@ PageAssistant.prototype._newBrowserPage
*/
PageAssistant.prototype._streamResource = function(uri, appid, mimeType){
- Mojo.Log.info("Streaming: '%s' with '%s' (%s)", uri, appid, mimeType);
+ Mojo.Log.error("Streaming: '%s' with '%s' (%s)", uri, appid, mimeType);
- // Only a few select applications can be
- crossAppScene = {
- 'com.palm.app.videoplayer': 'nowplaying',
- 'com.palm.app.streamingmusicplayer': 'nowplaying'
- };
- var params = {target: uri, mimeType: mimeType};
- if (crossAppScene[appid]) {
+ this._downloadWidgetElement = this.controller.showDialog({
+ uri: uri,
+ mimeType: mimeType,
+ appid: appid,
+ template: 'download/download-stream-popup',
+ assistant: new DownloadDialogAssistant({
+ sceneAssistant: this,
+ onDismiss: function(cParams) { // DOWNLOAD
+ //this._onPopupHandler('close');
+ this._downloadController.downloadResource(uri);
+ }.bind(this),
+ onAccept: function(cParams) { // STREAM
+ var params = {target: uri, mimeType: mimeType, appid: appid};
+ // Only a few select applications can be
+ var crossAppScene = {
+ 'com.palm.app.videoplayer': 'nowplaying',
+ 'com.palm.app.streamingmusicplayer': 'nowplaying'
+ };
+ //this._onPopupHandler('close');
+ if (crossAppScene[appid]) {
+ var args = { appId: appid, name: crossAppScene[appid] };
+ this.controller.stageController.pushScene(args, params);
+ }
+ else {
+ this._downloadController.downloadResource(uri);
+ }
+ }.bind(this)})
+ });
+ // Record we have a popup
+ //this._onPopupHandler('open');
- var args = { appId: appid, name: crossAppScene[appid] };
- this.controller.stageController.pushScene(args, params);
- }
- else {
- this.controller.serviceRequest('palm://com.palm.applicationManager', {
- method: 'open',
- parameters: {
- 'id': appid,
- 'params': params
- }
- });
- }
};
/**
@@ -2318,16 +2331,29 @@ PageAssistant.prototype._streamResource
*/
PageAssistant.prototype._downloadResource = function(uri) {
- Mojo.Log.info("Downloading: " + uri);
+ Mojo.Log.info("Downloading: " + uri);
- try {
- // We should no longer download a resource but inform the user
- // we are unable to perform the download.
- this.controller.showAlertDialog({
- onChoose: function(value) { /* Do Nothing */},
- message: $L('Cannot find an application which can open this file.'),
- choices:[{label:$L('OK'), value:'1', type:'dismiss'}]
- });
+ try {
+ // We should no longer download a resource but inform the user
+ // we are unable to perform the download.
+ if (!this._downloadWidgetElement) {
+ this._downloadWidgetElement = this.controller.showDialog({
+ template: 'download/download-popup',
+ assistant: new DownloadDialogAssistant({
+ sceneAssistant: this,
+ onDismiss: function() {
+ //this._onPopupHandler('close');
+ delete this._downloadWidgetElement;
+ }.bind(this),
+ onAccept: function() {
+ //this._onPopupHandler('close');
+ this._downloadController.downloadResource(uri);
+ }.bind(this)})
+ });
+
+ // Record we have a popup
+ //this._onPopupHandler('open');
+ }
} catch (e) {
Mojo.Log.logException(e, "#_downloadResource");
}
Index: /usr/palm/applications/com.palm.app.browser/app/views/download/download-container.html
===================================================================
--- .orig/usr/palm/applications/com.palm.app.browser/app/views/download/download-container.html
+++ /usr/palm/applications/com.palm.app.browser/app/views/download/download-container.html
@@ -1,3 +1,3 @@
<div x-mojo-elements="List" class="palm-list no-lines">
- #{listElements}
+ #{-listElements}
</div>
\ No newline at end of file
Index: /usr/palm/applications/com.palm.app.browser/app/views/download/download-popup.html
===================================================================
--- /dev/null
+++ /usr/palm/applications/com.palm.app.browser/app/views/download/download-popup.html
@@ -0,0 +1,8 @@
+<div id="palm-dialog-content" class="palm-dialog-content">
+ <div class="dialog-message" x-mojo-loc=""> Cannot find an application which can open this file. Would you like to download it to /media/internal/downloads?</div>
+</div>
+
+<div class="palm-dialog-buttons">
+ <div class="dismiss palm-button" id="acceptButton" x-mojo-loc="" x-mojo-tap-highlight="momentary">Yes</div>
+ <div class="dismiss palm-button" id="dismissButton" x-mojo-loc="" x-mojo-tap-highlight="momentary">No</div>
+</div>
Index: /usr/palm/applications/com.palm.app.browser/app/views/download/download-stream-popup.html
===================================================================
--- /dev/null
+++ /usr/palm/applications/com.palm.app.browser/app/views/download/download-stream-popup.html
@@ -0,0 +1,8 @@
+<div id="palm-dialog-content" class="palm-dialog-content">
+ <div class="dialog-message" x-mojo-loc="">This file type has been registered as a streaming media file. Would you like to download it to /media/internal/downloads instead?</div>
+</div>
+
+<div class="palm-dialog-buttons">
+ <div class="dismiss palm-button" id="acceptButton" x-mojo-loc="" x-mojo-tap-highlight="momentary">Stream</div>
+ <div class="dismiss palm-button" id="dismissButton" x-mojo-loc="" x-mojo-tap-highlight="momentary">Download</div>
+</div>
Index: /usr/palm/applications/com.palm.app.browser/app/views/page/page-scene.html
===================================================================
--- .orig/usr/palm/applications/com.palm.app.browser/app/views/page/page-scene.html
+++ /usr/palm/applications/com.palm.app.browser/app/views/page/page-scene.html
@@ -16,5 +16,9 @@
<div id="server-disconnected" class="palm-scrim">
<div id="server-disconnected-spinner" x-mojo-element="Spinner"></div>
</div>
+<div id="downloadListScroller" class="browser-download" x-mojo-element="Scroller">
+ <div id="downloadList" class="palm-list" x-mojo-element="List"></div>
+</div>
+
Index: /usr/palm/applications/com.palm.app.browser/sources.json
===================================================================
--- .orig/usr/palm/applications/com.palm.app.browser/sources.json
+++ /usr/palm/applications/com.palm.app.browser/sources.json
@@ -1,5 +1,17 @@
-[
+[
{
- "source": "app\/controllers\/global_code.js"
+ "source":"app\/models\/download-model.js"
+ },
+ {
+ "source":"app\/controllers\/download-request.js"
+ },
+ {
+ "source":"app\/controllers\/download-controller.js"
+ },
+ {
+ "source":"app\/controllers\/downloaddialog-assistant.js"
+ },
+ {
+ "source": "app\/controllers\/global_code.js"
}
]