Talking Picture List Outline

       

Things marked *EC* are for the extra credit.

++ Main UI                ++ Dialog UI          ++ Edit UI
ListView                  Linear                Linear
  ImageView TextView        Image                 Image
  Checkbox *EC*             Button                EditText
                                                  Buttons Record, Stop *EC*
                                                  Button Save
++ Room 
  DB
  Entities
    int id - primary key
    long imageId
    String description
    byte[] recording *EC*
    Constructor, setters, getters
  DAO
    fetchAll - query
    getById - query
    getByImageId - query
    insert, delete, update

++ Main activity
----------------------------------------------------------------
onCreate
    getPermissions
----------------------------------------------------------------
goOnCreating
    Set UI content
    Start random song looping 
    Build DB
    fillListView
    Create filename for recording in ExternalCacheDir *EC*
    Create TTS
----------------------------------------------------------------
fillListView
    Fetch images to get an image cursor (needs to be global)
    Convert to ArrayList of HashMap
      Put thumbnail
      if image is in DB
        Put description
        Put recording *EC*
    Create and set SimpleAdapter
    Set ViewBinder and ItemClickListener to this
    Assign adpater to ListView
----------------------------------------------------------------
setViewValue
    switch on view id
      Cast data to right type and put in view
    return true
----------------------------------------------------------------
onItemCLick
    Get image id and Uri from image cursor
    Pause the song
    if image is in the DB (look for the image id)
      Put Uri in Bundle
      Show dialog
      Speak description
      Speak any recording *EC*
    else
      Put image id and Uri in Intent
      Launch edit activity
----------------------------------------------------------------
ARL edit activity
  onActivityResult
    if RESULT_OK
      Put image id in DB entity
      Put new description in DB entity
      Put new recording in DB entity *EC*
      Add entity to DB
      fillListView  (how lazy)
    Resume song
----------------------------------------------------------------
onDestroy
    Close DB
    Shutdown TTS
    Release song player
    Close image cursor
----------------------------------------------------------------
stopTalking (from dialog)
  Stop TTS
  Stop playing recording *EC*
----------------------------------------------------------------
getPermissions
----------------------------------------------------------------

++ Dialog
----------------------------------------------------------------
onCreateView
    Inflate dialog
    Get image URI and set in dialog
    Set OnClickListener
----------------------------------------------------------------
onClick
    Call stopTalking in activity 
    dismiss()
----------------------------------------------------------------
public interface StopTalking
    public void stopTalking
----------------------------------------------------------------

++ Edit activity
----------------------------------------------------------------
onCreate
    Get image id and Uri from Intent and put in UI
----------------------------------------------------------------
clickHandler
    switch on buttons
      case record *EC*
        Start recording to file
      case stop *EC*
        Stop recording
        Read bytes from file
      case save
        if a description or recording has been entered
          Put image id in Intent
          Put description in Intent
          Put recording bytes in Intent *EC*
          return RESULT_OK
        else
          return RESULT_CANCELLED
      finish()
----------------------------------------------------------------