AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.FirebaseDB Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.FirebaseDB:
com.google.appinventor.components.runtime.AndroidNonvisibleComponent com.google.appinventor.components.runtime.Component com.google.appinventor.components.runtime.Component

Public Member Functions

 FirebaseDB (ComponentContainer container)
 
void Initialize ()
 
String FirebaseURL ()
 
void FirebaseURL (String url)
 
void DeveloperBucket (String bucket)
 
String DeveloperBucket ()
 
void ProjectBucket (String bucket)
 
String ProjectBucket ()
 
void FirebaseToken (String JWT)
 
String FirebaseToken ()
 
void Persist (boolean value)
 
void ClearTag (final String tag)
 
void StoreValue (final String tag, Object valueToStore)
 
void GetValue (final String tag, final Object valueIfTagNotThere)
 
void GotValue (String tag, Object value)
 
void DataChanged (String tag, Object value)
 
void FirebaseError (String message)
 
void Unauthenticate ()
 
void DefaultURL (String url)
 
void RemoveFirst (final String tag)
 
void GetTagList ()
 
void TagList (List value)
 
void FirstRemoved (Object value)
 
void AppendValue (final String tag, final Object valueToAdd)
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
HandlesEventDispatching getDispatchDelegate ()
 

Additional Inherited Members

- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
 AndroidNonvisibleComponent (Form form)
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidNonvisibleComponent
final Form form
 

Detailed Description

The Firebase component communicates with a Web service to store and retrieve information. The component has methods to store a value under a tag and to retrieve the value associated with the tag. It also possesses a listener to fire events when stored values are changed.

Additional Information

Author
kasmu.nosp@m.s@mi.nosp@m.t.edu (Kristin Asmus)
will2.nosp@m.596@.nosp@m.gmail.nosp@m..com (William Byrne) (default Firebase partitioning and user authentication)
jis@m.nosp@m.it.e.nosp@m.du (Jeffrey I. Schiller) (defaultURL setup at runtime, other cleanup)

Definition at line 74 of file FirebaseDB.java.

Constructor & Destructor Documentation

◆ FirebaseDB()

com.google.appinventor.components.runtime.FirebaseDB.FirebaseDB ( ComponentContainer  container)

Creates a new Firebase component.

Parameters
containerthe Form that this component is contained in.

Definition at line 132 of file FirebaseDB.java.

Member Function Documentation

◆ AppendValue()

void com.google.appinventor.components.runtime.FirebaseDB.AppendValue ( final String  tag,
final Object  valueToAdd 
)

Definition at line 748 of file FirebaseDB.java.

◆ ClearTag()

void com.google.appinventor.components.runtime.FirebaseDB.ClearTag ( final String  tag)

Asks Firebase to forget (delete or set to "null") a given tag.

Parameters
tagThe tag to remove

Definition at line 449 of file FirebaseDB.java.

◆ DataChanged()

void com.google.appinventor.components.runtime.FirebaseDB.DataChanged ( String  tag,
Object  value 
)

Indicates that the data in the Firebase has changed. Launches an event with the tag and value that have been updated.

Parameters
tagthe tag that has changed.
valuethe value that has changed.

Definition at line 554 of file FirebaseDB.java.

◆ DefaultURL()

void com.google.appinventor.components.runtime.FirebaseDB.DefaultURL ( String  url)

Definition at line 643 of file FirebaseDB.java.

◆ DeveloperBucket() [1/2]

String com.google.appinventor.components.runtime.FirebaseDB.DeveloperBucket ( )

Getter for the DeveloperBucket.

Returns
the DeveloperBucket for this Firebase

Definition at line 318 of file FirebaseDB.java.

◆ DeveloperBucket() [2/2]

void com.google.appinventor.components.runtime.FirebaseDB.DeveloperBucket ( String  bucket)

Specifies the unique developer path of the Firebase.

@internaldoc This is set programmatically in com.google.appinventor.client.editor.simple.components.MockFirebaseDB and consists of the current App Inventor user's email.

Parameters
bucketthe name of the developer's bucket

Definition at line 307 of file FirebaseDB.java.

◆ FirebaseError()

void com.google.appinventor.components.runtime.FirebaseDB.FirebaseError ( String  message)

Indicates that the communication with the Firebase signaled an error.

Parameters
messagethe error message

Definition at line 573 of file FirebaseDB.java.

◆ FirebaseToken() [1/2]

String com.google.appinventor.components.runtime.FirebaseDB.FirebaseToken ( )

Getter for the FirebaseToken.

Returns
the JWT used to authenticate users on the default Firebase

Definition at line 367 of file FirebaseDB.java.

◆ FirebaseToken() [2/2]

void com.google.appinventor.components.runtime.FirebaseDB.FirebaseToken ( String  JWT)

Specifies the token for the default Firebase.

Parameters
JWTthe JSON Web Token (JWT) used to authenticate on the default Firebase

Definition at line 356 of file FirebaseDB.java.

◆ FirebaseURL() [1/2]

String com.google.appinventor.components.runtime.FirebaseDB.FirebaseURL ( )

Getter for the Firebase URL.

Returns
the URL for this Firebase

Definition at line 249 of file FirebaseDB.java.

◆ FirebaseURL() [2/2]

void com.google.appinventor.components.runtime.FirebaseDB.FirebaseURL ( String  url)

Specifies the URL for the Firebase.

The default value is currently my private Firebase URL, but this will eventually changed once the App Inventor Candle plan is activated.

Parameters
urlthe URL for the Firebase

Definition at line 268 of file FirebaseDB.java.

◆ FirstRemoved()

void com.google.appinventor.components.runtime.FirebaseDB.FirstRemoved ( Object  value)

Definition at line 741 of file FirebaseDB.java.

◆ GetTagList()

void com.google.appinventor.components.runtime.FirebaseDB.GetTagList ( )

Definition at line 708 of file FirebaseDB.java.

◆ GetValue()

void com.google.appinventor.components.runtime.FirebaseDB.GetValue ( final String  tag,
final Object  valueIfTagNotThere 
)

GetValue asks Firebase to get the value stored under the given tag. It will pass valueIfTagNotThere to GotValue if there is no value stored under the tag.

Parameters
tagThe tag whose value is to be retrieved.
valueIfTagNotThereThe value to pass to the event if the tag does not exist.

Definition at line 484 of file FirebaseDB.java.

◆ GotValue()

void com.google.appinventor.components.runtime.FirebaseDB.GotValue ( String  tag,
Object  value 
)

Indicates that a GetValue request has succeeded.

Parameters
valuethe value that was returned. Can be any type of value (e.g. number, text, boolean or list).

Definition at line 533 of file FirebaseDB.java.

◆ Initialize()

void com.google.appinventor.components.runtime.FirebaseDB.Initialize ( )

Initialize: Do runtime intiailization of FirebaseDB We cannot make a connection to Firebase in the component Constructor because we do not yet know the value of the Persist property. The Persist property is used to set the persistance flag in the Firebase static config. It must be set prior to any connection happening and cannot be changed after a Firebase connection (or reference) is made. So we defer making a connection until we initialize. Initialize is called from runtime.scm (via Form.java) after all components and properties have been setup.

Definition at line 235 of file FirebaseDB.java.

◆ Persist()

void com.google.appinventor.components.runtime.FirebaseDB.Persist ( boolean  value)

Definition at line 385 of file FirebaseDB.java.

◆ ProjectBucket() [1/2]

String com.google.appinventor.components.runtime.FirebaseDB.ProjectBucket ( )

Getter for the ProjectBucket.

Returns
the ProjectBucket for this Firebase

Definition at line 344 of file FirebaseDB.java.

◆ ProjectBucket() [2/2]

void com.google.appinventor.components.runtime.FirebaseDB.ProjectBucket ( String  bucket)

Specifies the path for the project bucket of the Firebase.

Parameters
bucketthe name of the project's bucket

Definition at line 330 of file FirebaseDB.java.

◆ RemoveFirst()

void com.google.appinventor.components.runtime.FirebaseDB.RemoveFirst ( final String  tag)

Definition at line 655 of file FirebaseDB.java.

◆ StoreValue()

void com.google.appinventor.components.runtime.FirebaseDB.StoreValue ( final String  tag,
Object  valueToStore 
)

Asks Firebase to store the given value under the given tag.

Parameters
tagThe tag to use
valueToStoreThe value to store. Can be any type of value (e.g. number, text, boolean or list).

Definition at line 461 of file FirebaseDB.java.

◆ TagList()

void com.google.appinventor.components.runtime.FirebaseDB.TagList ( List  value)

Definition at line 734 of file FirebaseDB.java.

◆ Unauthenticate()

void com.google.appinventor.components.runtime.FirebaseDB.Unauthenticate ( )

Unauthenticate from Firebase.

Firebase keeps track of credentials in a cache in shared_prefs It will re-use these credentials as long as they are valid. Given That we retrieve a FirebaseToken with a version long life, this will effectively be forever. Shared_prefs survive an application update and depending on how backup is configured on a device, it might survive an application removal and reinstallation.

Normally this is not a problem, however if we change the credentials used, for example the App author is switching from one Firebase account to another, or invalided their firebase.secret, this cached credential is invalid, but will continue to be used, which results in errors.

This function permits us to unauthenticate, which tosses the cached credentials. The next time authentication is needed we will use our current FirebaseToken and get fresh credentials.

Definition at line 626 of file FirebaseDB.java.


The documentation for this class was generated from the following file: