Ringer (lua)

Example: Ringer

ringer.xml
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <templates>
  3. <!-- switches ringer on and off, stores current volume locally -->
  4. <template name="ringer" icon="@drawable/ringer_on"> <!-- todo string for ringer -->
  5. <keyConfiguration>
  6. <lua>
  7. <code>
  8. local currentlyMuted = false
  9. local path = "sound/volumes/ringing"
  10. local configuredVolume = config.get( path )
  11.  
  12. function onConfigChanged()
  13. local c = config.get( path )
  14. print( c )
  15. if not (c == "0") then
  16. key:setLed("off")
  17. configuredVolume = c
  18. currentlyMuted = false
  19. else
  20. currentlyMuted = true
  21. key:setLed("red")
  22. end
  23. end
  24.  
  25. function onKeyUp()
  26. if currentlyMuted then
  27. config.set( path, configuredVolume )
  28. else
  29. config.set( path, 0 )
  30. end
  31. end
  32.  
  33. config.register(path, onConfigChanged)
  34. </code>
  35. </lua>
  36. </keyConfiguration>
  37. </template>
  38. </templates>