/commandslib/src/com/google/android/marvin/commands/Command.java

http://eyes-free.googlecode.com/ · Java · 51 lines · 9 code · 7 blank · 35 comment · 0 complexity · c69636486044a9d0f4d65823fea5763e MD5 · raw file

  1. // Copyright 2010 Google Inc. All Rights Reserved.
  2. package com.google.android.marvin.commands;
  3. /**
  4. * An interface that should be implemented by any user commands. A user command is an event
  5. * sent to a {@link android.content.BroadcastReceiver} that requests some action be taken.
  6. *
  7. * Keyboards can choose to invoke the commands using the provided keyboard shortcut, consisting
  8. * of a modifier key and additional key.
  9. *
  10. * To invoke the command, send a broadcast with the provided action, via {@code getAction()},
  11. * with an extra named {@code CommandConstants.EXTRA_EVENT_TYPE} whose contents are
  12. * {@code getDisplayName()}.
  13. *
  14. * @author clsimon@google.com (Cheryl Simon)
  15. *
  16. */
  17. public interface Command {
  18. /**
  19. * @return The key code of the second key to be pressed to execute the command.
  20. */
  21. int getKeyCode();
  22. /**
  23. * Set the key code of the second key to be pressed to execute the command.
  24. */
  25. void setKeyCode(int keyCode);
  26. /**
  27. * @return The key code of the modifier key involved in the command execution. Possible options
  28. * are search and menu.
  29. */
  30. int getModifier();
  31. /**
  32. * Set the key code of the modifier key involved in the command execution.
  33. */
  34. void setModifier(int keyCode);
  35. /**
  36. * @return The name of the command that will be displayed to the user in settings, and
  37. * will be used as the contents of the extra when invoking the command.
  38. */
  39. String getDisplayName();
  40. /**
  41. * @return The action to direct the broadcast at to invoke the command.
  42. */
  43. String getAction();
  44. }