danger.audio
Class ToneGallery

java.lang.Object
  extended by danger.app.Listener
      extended by danger.audio.ToneGallery


public class ToneGallery
extends Listener


Nested Class Summary
static interface ToneGallery.Errors
           
static interface ToneGallery.Type
           
 
Method Summary
static void add(int type, byte[] data, String name, int resourceID, Event successCallback, Event failureCallback, int origin, int rights, boolean showNotification)
          Main entry to add a ringtone into the tone gallery.
static void add(int type, byte[] data, String name, String productID, Event successCallback, Event failureCallback, int origin, int rights, boolean showNotification)
          Main entry to add a ringtone into the tone gallery.
static void add(int type, byte[] data, String name, String productID, int resourceID, Event successCallback, Event failureCallback, int origin, int rights, boolean showNotification)
          Main entry to add a ringtone into the tone gallery.
static void displayState()
           
static int generateResourceID()
           
static RingToneObject getDefaultCallRingTone()
          Get the default ringtone used for phone
static RingToneObject getDefaultVoicemailRingTone()
           
static int getFiltersFromID(int resourceID)
           
static String getGroupNameFromID(int resourceID)
           
static Vector getGroupNames(int klass, int rights)
           
static int getIDFromNameAndGroup(String name, String group)
           
static int getMaxInstallableTones()
          Return the max number of ringtones that can be installed
static int getMaxTonesInstalled()
          Return the number of ringtones installed in the gallery
static String getNameFromID(int resourceID)
           
static Vector getNamesFromGroup(String group, int klass, int rights)
          Return names from a specific group as String object stored as a Vector object
static Vector getProductIDs()
          Return all installed Tones ProductIDs as a Vector of String objects
static Vector getProductIDs(int originFilter)
          Return all installed Tones ProductIDs as a Vector of String objects with a ToneOrigin.* as passed in as originFilter.
static int getToneClassFromID(int resourceID)
           
static Tone getToneFromID(int resourceID)
           
static Tone getToneFromProductID(String productID)
           
static boolean hasBuzzer(int resourceID)
           
static boolean hasFlasher(int resourceID)
           
static boolean hasSound(int resourceID)
           
static void initialize()
           
static void initializeFromSysApp()
           
static boolean isChanged()
           
static boolean isInstalled(String productID)
          returns true/false if a particular Tone is installed into the ToneGallery, based upon productID or/and resourceID.
static boolean isInstalled(String productID, int resourceID)
           
static boolean isNameInGroup(String name, String group)
           
static boolean isStoreSpaceAvailable()
           
static void listTones(int klass)
           
static void playAllTones()
           
static void playTonesByClass(int klass)
           
 boolean receiveEvent(Event e)
          Entry point for event processing.
static int register(ResourceDatabase rdb, int toneArrayResourceID, int toneClass)
          Register a set of Tones used for an application.
static int register(Tone tone)
           
static int register(Tone[] toneList, int toneClass)
          Register a set of Tones used for an application.
static int register(danger.audio.ToneRecordStore.Getter toneStore)
           
static int register(danger.audio.ToneRecordStore toneStore)
          Register a set of Tones.
static void remove(int resourceID)
           
static void remove(String productID)
           
static void remove(Tone tone)
           
static void removeAllStored()
          This will remove all stored ringtones in the ToneGallery and update the service.
static void setDefaultCallRingTone(RingToneObject ringtone)
          Set the default ringtone use for the phone
static void setDefaultVoicemailRingTone(RingToneObject ringtone)
           
static void setNameFromID(int resourceID, String newName)
           
static int setVolumeFromID(int resourceID, int newVolume)
           
static void showDeleteRingToneDialog(String replaceTone, Event successCallback, Event failureCallback)
          Will bring up a system wide dialog to allow the user to delete a ringtone.
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, receiveEventInternal, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public static void initialize()

initializeFromSysApp

public static void initializeFromSysApp()

setDefaultCallRingTone

public static void setDefaultCallRingTone(RingToneObject ringtone)
Set the default ringtone use for the phone


getDefaultCallRingTone

public static RingToneObject getDefaultCallRingTone()
Get the default ringtone used for phone


setDefaultVoicemailRingTone

public static void setDefaultVoicemailRingTone(RingToneObject ringtone)

getDefaultVoicemailRingTone

public static RingToneObject getDefaultVoicemailRingTone()

register

public static int register(danger.audio.ToneRecordStore toneStore)
Register a set of Tones. This is used to include a individul Tone, or a list of Tones in the ToneGallery. This doesn't limit the number of tones added. The ToneGalleryStore uses these methods to include a ringtone brought down from the serivce Returns: Errors.OK Errors.NOT_SETUP Errors.DUPLICATE_ID


register

public static int register(danger.audio.ToneRecordStore.Getter toneStore)

register

public static int register(ResourceDatabase rdb,
                           int toneArrayResourceID,
                           int toneClass)
Register a set of Tones used for an application. The klass is or'd bitwise to the resourceID's of each individual tone. For example if the toneClass is 1<<8, and the Tone's resource ID is 0x5012, then the resourceID registered is 0x5268. This value is used for reference, which can be stored to the service. Pass in ToneClass.NONE if you don't want this behavior. Returns: Errors.OK Errors.NOT_SETUP Errors.DUPLICATE_ID


register

public static int register(Tone tone)

register

public static int register(Tone[] toneList,
                           int toneClass)
Register a set of Tones used for an application. The klass is or'd bitwise to the resourceID's of each individual tone. For example if the toneClass is 1<<8, and the Tone's resource ID is 0x5012, then the resourceID registered is 0x5268. This value is used for reference, which can be stored to the service. Pass in ToneClass.NONE if you don't want this behavior. The array, toneList, is null terminated Returns: Errors.OK Errors.NOT_SETUP Errors.DUPLICATE_ID


generateResourceID

public static int generateResourceID()

isChanged

public static boolean isChanged()

getMaxTonesInstalled

public static int getMaxTonesInstalled()
Return the number of ringtones installed in the gallery


getMaxInstallableTones

public static int getMaxInstallableTones()
Return the max number of ringtones that can be installed


isStoreSpaceAvailable

public static boolean isStoreSpaceAvailable()

showDeleteRingToneDialog

public static void showDeleteRingToneDialog(String replaceTone,
                                            Event successCallback,
                                            Event failureCallback)
Will bring up a system wide dialog to allow the user to delete a ringtone. The successCallback and failureCallback events will be called, and the Event.what field will contain a ToneGallery.Errors.* code with details.


isInstalled

public static boolean isInstalled(String productID)
returns true/false if a particular Tone is installed into the ToneGallery, based upon productID or/and resourceID. Either can be 0, if not known.


isInstalled

public static boolean isInstalled(String productID,
                                  int resourceID)

add

public static void add(int type,
                       byte[] data,
                       String name,
                       String productID,
                       Event successCallback,
                       Event failureCallback,
                       int origin,
                       int rights,
                       boolean showNotification)
Main entry to add a ringtone into the tone gallery. Add() will add a ringtone and queue up any multiple adds. This will also open a delete ringtone dialog if the gallery becomes full. INPUT: type ToneGallery.Type.*. If type is UNKNOWN, this will try and determine what type of data it is and continue. data byte data. name optional name, if not provided, then data will be parsed to determine if one is available, if not, then one will be assigned. productID unique id. Use null to generate one. successCallback Event object to call after successfull install. failureCallback Event object to call after failed install. The Event.what field will contain an ToneGallery.Errors.* code. origin ToneOrigin.*. Location of where data comes from which determines how its stored in the gallery. ToneOrigin.GALLERY - Added to the gallery but not saved to the service ToneOrigin.USER - Added to service store. Full access. ToneOrigin.PREMIUM - Added only to local store. Controlled access. ToneOrigin.PREMIUM_BACKUP - Added to service store. Controlled access. rights ToneRights.FULL - complete access ToneRights.COPY_PROHIBIT - can't forward off of device showNotification If true, a notification will be started after install.


add

public static void add(int type,
                       byte[] data,
                       String name,
                       int resourceID,
                       Event successCallback,
                       Event failureCallback,
                       int origin,
                       int rights,
                       boolean showNotification)
Main entry to add a ringtone into the tone gallery. Add() will add a ringtone and queue up any multiple adds. This will also open a delete ringtone dialog if the gallery becomes full. INPUT: type ToneGallery.Type.*. If type is UNKNOWN, this will try and determine what type of data it is and continue. data byte data. name optional name, if not provided, then data will be parsed to determine if one is available, if not, then one will be assigned. resourceID unique id. Use 0 to generate one. successCallback Event object to call after successfull install. failureCallback Event object to call after failed install. The Event.what field will contain an ToneGallery.Errors.* code. origin ToneOrigin.*. Location of where data comes from which determines how its stored in the gallery. ToneOrigin.GALLERY - Added to the gallery but not saved to the service ToneOrigin.USER - Added to service store. Full access. ToneOrigin.PREMIUM - Added only to local store. Controlled access. ToneOrigin.PREMIUM_BACKUP - Added to service store. Controlled access. rights ToneRights.FULL - complete access ToneRights.COPY_PROHIBIT - can't forward off of device showNotification If true, a notification will be started after install.


add

public static void add(int type,
                       byte[] data,
                       String name,
                       String productID,
                       int resourceID,
                       Event successCallback,
                       Event failureCallback,
                       int origin,
                       int rights,
                       boolean showNotification)
Main entry to add a ringtone into the tone gallery. Add() will add a ringtone and queue up any multiple adds. This will also open a delete ringtone dialog if the gallery becomes full. INPUT: type ToneGallery.Type.*. If type is UNKNOWN, this will try and determine what type of data it is and continue. data byte data. name optional name, if not provided, then data will be parsed to determine if one is available, if not, then one will be assigned. productID unique id. Use null to generate one. resourceID unique id. Use 0 to generate one. successCallback Event object to call after successfull install. failureCallback Event object to call after failed install. The Event.what field will contain an ToneGallery.Errors.* code. origin ToneOrigin.*. Location of where data comes from which determines how its stored in the gallery. ToneOrigin.GALLERY - Added to the gallery but not saved to the service ToneOrigin.USER - Added to service store. Full access. ToneOrigin.PREMIUM - Added only to local store. Controlled access. ToneOrigin.PREMIUM_BACKUP - Added to service store. Controlled access. rights ToneRights.FULL - complete access ToneRights.COPY_PROHIBIT - can't forward off of device showNotification If true, a notification will be started after install.


receiveEvent

public boolean receiveEvent(Event e)
Description copied from class: Listener
Entry point for event processing. This method is called from a Dispatcher when it reads an Event in its queue that is targetted at this instance. The default behavior is to do nothing and return false. Subclasses are expected to override this method to do something more useful.

Overrides:
receiveEvent in class Listener
Parameters:
e - non-null; the event to process
Returns:
whether (true) or not (false) this method actually handled the event to completion

remove

public static void remove(String productID)

remove

public static void remove(int resourceID)

remove

public static void remove(Tone tone)

removeAllStored

public static void removeAllStored()
This will remove all stored ringtones in the ToneGallery and update the service. Only use if you want to clear everything.


getToneClassFromID

public static int getToneClassFromID(int resourceID)

getFiltersFromID

public static int getFiltersFromID(int resourceID)

hasSound

public static boolean hasSound(int resourceID)

hasBuzzer

public static boolean hasBuzzer(int resourceID)

hasFlasher

public static boolean hasFlasher(int resourceID)

setVolumeFromID

public static int setVolumeFromID(int resourceID,
                                  int newVolume)

setNameFromID

public static void setNameFromID(int resourceID,
                                 String newName)

getNameFromID

public static String getNameFromID(int resourceID)

getGroupNameFromID

public static String getGroupNameFromID(int resourceID)

getToneFromID

public static Tone getToneFromID(int resourceID)

getToneFromProductID

public static Tone getToneFromProductID(String productID)

getGroupNames

public static Vector getGroupNames(int klass,
                                   int rights)

getProductIDs

public static Vector getProductIDs(int originFilter)
Return all installed Tones ProductIDs as a Vector of String objects with a ToneOrigin.* as passed in as originFilter.


getProductIDs

public static Vector getProductIDs()
Return all installed Tones ProductIDs as a Vector of String objects


getNamesFromGroup

public static Vector getNamesFromGroup(String group,
                                       int klass,
                                       int rights)
Return names from a specific group as String object stored as a Vector object


isNameInGroup

public static boolean isNameInGroup(String name,
                                    String group)

getIDFromNameAndGroup

public static int getIDFromNameAndGroup(String name,
                                        String group)

playAllTones

public static void playAllTones()

playTonesByClass

public static void playTonesByClass(int klass)

listTones

public static void listTones(int klass)

displayState

public static void displayState()