Exemplo n.º 1
0
  @Override
  public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.abstract_logging_activity, menu);

    final SubMenu menuLog = menu.findItem(R.id.menu_templates).getSubMenu();
    for (final LogTemplate template : LogTemplateProvider.getTemplatesWithSignature()) {
      menuLog.add(0, template.getItemId(), 0, template.getResourceId());
    }

    final SubMenu menuSmilies = menu.findItem(R.id.menu_smilies).getSubMenu();
    for (final Smiley smiley : GCSmiliesProvider.getSmilies()) {
      menuSmilies.add(0, smiley.getItemId(), 0, smiley.text);
    }

    return true;
  }
Exemplo n.º 2
0
  @Override
  public boolean onOptionsItemSelected(final MenuItem item) {
    final int id = item.getItemId();
    if (id == R.id.menu_repeat_last) {
      replaceLog(getLastLog());
      return true;
    }

    final LogTemplate template = LogTemplateProvider.getTemplate(id);
    if (template != null) {
      insertIntoLog(template.getValue(getLogContext()), true);
      return true;
    }

    final Smiley smiley = GCSmiliesProvider.getSmiley(id);
    if (smiley != null) {
      insertIntoLog("[" + smiley.text + "]", true);
      return true;
    }

    return super.onOptionsItemSelected(item);
  }