Example #1
0
 private void autosave() {
   if (!sendSuccessful && mMessage != null) {
     if (mMessage.length() < 1
         || mMessage.getText().toString().replaceAll("\\s", "").length() < 1
         || this.sendSuccessful) {
       Log.i(TAG, "Message unchanged, discarding.");
       deleteReply(); // if the reply is unchanged, throw it out.
       mMessage.setText("");
     } else {
       Log.i(TAG, "Message Unsent, saving.");
       saveReply();
     }
   }
 }
 @Override
 public void onStop() {
   super.onStop();
   if (!sendSuccessful) {
     if (mMessage
         .getText()
         .toString()
         .replaceAll("\\s", "")
         .equalsIgnoreCase(originalReplyData.replaceAll("\\s", ""))) {
       Log.i(TAG, "Message unchanged, discarding.");
       deleteReply(); // if the reply is unchanged, throw it out.
     } else {
       Log.i(TAG, "Message Unsent, saving.");
       saveReply();
     }
   }
   cleanupTasks();
 }
Example #3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (DEBUG) Log.e(TAG, "onOptionsItemSelected");
    switch (item.getItemId()) {
      case R.id.bbcode_bold:
        insertBBCode(BBCODE.BOLD);
        break;
      case R.id.bbcode_italics:
        insertBBCode(BBCODE.ITALICS);
        break;
      case R.id.bbcode_underline:
        insertBBCode(BBCODE.UNDERLINE);
        break;
      case R.id.bbcode_strikeout:
        insertBBCode(BBCODE.STRIKEOUT);
        break;
      case R.id.bbcode_url:
        insertBBCode(BBCODE.URL);
        break;
      case R.id.bbcode_video:
        insertBBCode(BBCODE.VIDEO);
        break;
      case R.id.bbcode_image:
        insertBBCode(BBCODE.IMAGE);
        break;
      case R.id.bbcode_thumbnail:
        insertBBCode(BBCODE.THUMBNAIL);
        break;
      case R.id.bbcode_quote:
        insertBBCode(BBCODE.QUOTE);
        break;
      case R.id.bbcode_spoiler:
        insertBBCode(BBCODE.SPOILER);
        break;
      case R.id.bbcode_code:
        insertBBCode(BBCODE.CODE);
        break;
      case R.id.submit_button:
        postReply();
        break;
      case R.id.discard:
        deleteReply();
        getActivity().setResult(RESULT_CANCELLED);
        leave();
        break;
      case R.id.save_draft:
        saveReply();
        getActivity().setResult(RESULT_CANCELLED);
        leave();
        break;
      case R.id.emotes:
        selectionStart = mMessage.getSelectionStart();
        new EmoteFragment(this).show(getFragmentManager(), "emotes");
        break;
      case R.id.add_attachment:
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        startActivityForResult(Intent.createChooser(intent, "Select Picture"), ADD_ATTACHMENT);

        break;
      case R.id.remove_attachment:
        this.mFileAttachment = null;
        Toast removeToast =
            Toast.makeText(
                getAwfulActivity(),
                getAwfulActivity().getResources().getText(R.string.file_removed),
                Toast.LENGTH_SHORT);
        removeToast.show();
        invalidateOptionsMenu();
        break;
      case R.id.signature:
        item.setChecked(!item.isChecked());
        postSignature = item.isChecked();
        break;
      case R.id.disableEmots:
        item.setChecked(!item.isChecked());
        disableEmots = item.isChecked();
        break;
      default:
        return super.onOptionsItemSelected(item);
    }

    return true;
  }