Sample Code

The Dolphin Garage Add-on SDK provides a number of Add-on samples that include source code and a compiled, working APK (Android application package file) to help you get started.

Installing sample Add-ons

To install any of the sample APK’s, you will first need to adjust the Android settings of your device by going into the main Application settings and selecting “Allow installation of non-Market applications”.  Then you can do one of these to install the APK:

  • Copy the APK to your phone using a USB cable, and “run” the APK with a launcher or file manager.
  • Or, put the APK on an accessible site and download it to the phone.  Typically, the phone will offer to install the APK after downloading it.
Uninstalling sample Add-ons

The easiest way to uninstall an Add-on is to go into the Dolphin browser, slide left to access the Add-on bar, click the gear icon at the top left of the Add-on bar, and select the Add-on you wish to uninstall.  The screen will display options including Disable and Uninstall.

HelloWorld
 
Synopsis
When installed, when clicked, displays a “Hello World!” dialog.
 
API’s used
Browser.AddonBarAction.*, Browser.Window.*
 
Description
This is the basic “Hello, World” app for Dolphin Add-ons.  It appears on the Add-on list (as seen below) and, when clicked, displays a simple “Hello World!” dialog.
 
Screenshots

             

Download links
Sample code
Package

Bookmark

Synopsis
Displays an icon in title bar; when the icon is clicked, Adds the current page to the bookmarks or remove it from the bookmarks.
 
API’s Used
Browser.Bookmarks.*, Browser.TitleBarAction.*
 
Description
If the Bookmark Add-on is installed, it displays a star in the title bar, just to the right of the URL.  If the current page is already bookmarked, the icon appears blue; otherwise it appears gray.  Clicking on the icon bookmarks the current page, paints the icon blue, and displays a toast.  If the page is already bookmarked, clicking on the icon removes the bookmark, paints the icon gray, and displays a toast.
 
Screenshots
 
 
    
 
Download links
Sample code

Package

Bookmarklet
 
Synopsis
When clicked, runs Pinterest bookmarklet in current page.  Appears in Add-on bar.
 
API’s used
Browser.AddonBarAction.*, Browser.Tabs.*  
 
Description
The icon for the Bookmarklet Add-on appears in the Add-on bar.  When clicked, it scans the current page for items that are capable of being “pinned” to Pinterest.  If it finds any, it displays them (first screenshot) and allows the user to make a selection before using the Pinterest API to “pin” the item.  The user may be asked to log in to the Pinterest website if necessary.  If it doesn’t find any items, or if there are other problems, it notifies the user with a dialog.
 
Screenshot

   

Download link
Sample code

Package

Dialog
 
Synopsis
Demonstrates a simple dialog and complex dialog.
 
API’s used
Browser.AddonBarAction.*, Browser.Window.*
 
Details
This Add-on simply demonstrates two kinds of dialogs and the setTitle() method.  It appears in the Add-on bar (first screenshot) and, when clicked, displays a simple dialog using showDialog().  If the user clicks the “Show Complex Dialog” button, it displays a view-based dialog that allows the user to change the title of the Dialog icon in the Add-on bar.  In the screenshots below, the user changes the title of this Add-on from “Dialog” to “Hmm…”.  Note that this change is not persistent; the next time the browser is loaded, the title will be “Dialog” again.
 
Screenshots
 

      

 

Download links
Sample code

Package

Download

Synopsis
Simply displays a toast whenever a download ends.
 
API’s used
Browser.Downloads.*
 
Details
The Download Add-on does not appear in the Add-on bar.  It creates a listener that notifies it when a download finishes.  When that occurs, the Add-on displays a toast to inform the user that the download is complete, and if successful, displays the path and filename.
 
Screenshots

Download links

Package

FontSize

Synopsis
Changes the font size of the web page.
 
API’s used
Browser.AddonBarAction.*, Browser.Window.*, Browser.Tabs.*, Browser.WebViews.*
 
Details
This Add-on is listed in the Add-on bar.  When clicked, it displays a simple dialog that allows the user to increase or decrease the font size of web text, or reset it back to the default.  Only affects the current tab, and does not affect the global setting (Settings, Web Content, Text Size) or the zoom.  Works best with webpages that use relative font sizes, rather than specific (numeric) font sizes.
 
Screenshots

Download links
Sample code

Package

History

Synopsis

Displays a badge that shows the number of visits to the current page.

API’s used
Browser.AddonBarAction.*, Browser.History.*, Browser.Tabs.*, Browser.TitleBarAction.*, Browser.WebViews.*
 
Details
When a webpage is loaded, a listener alerts this Add-on, which counts the number of times the current URL appears in the history tree.  As the page finishes loading, a small orange polygon appears at the bottom right of the view and displays the count.  In the Add-on bar, the count is displayed as a badge on the History icon (which has been retitled to “visits”).  The maximum is 99 because that is the highest number that the badge feature can display.
 
Screenshots

       

Download links
Sample code

Package