Пример #1
0
  private void changeTextSize(float factor) {
    mTextSize = bodyEditText.getTextSize();
    mTextSize *= factor;

    bodyEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);

    getSharedPreferences(PREFS_NAME, MODE_PRIVATE).edit().putFloat(TEXT_SIZE, mTextSize).commit();
  }
Пример #2
0
  private void saveNote() {
    Log.d(TAG, "saveNote() called");

    String title = titleEditText.getText().toString();
    String body = bodyEditText.getText().toString();

    if (title.isEmpty()) {
      if (!body.isEmpty()) {
        note.setTitle(body.substring(0, DEFAULT_TITLE_LENGTH));
      } else {
        note.setTitle(PLACEHOLDER_TEXT_FOR_DATABASE);
      }
    }
    if (body.isEmpty()) {
      note.setBody(PLACEHOLDER_TEXT_FOR_DATABASE);
    }

    note.setTitle(title);
    note.setBody(body);

    if (noteExistsInDatabase == false) {
      Log.d(TAG, "Adding the following note: " + note.toString());
      noteProvider.addNote(note);
    } else {
      Log.d(TAG, "Updating the following note: " + note.toString());
      noteProvider.updateNote(note);
    }

    noteExistsInDatabase = true;
  }
Пример #3
0
 private void shareNote() {
   Log.d(TAG, "shareNote() called");
   String body = bodyEditText.getText().toString();
   Intent share = new Intent(Intent.ACTION_SEND);
   share.setType("text/plain");
   share.putExtra(Intent.EXTRA_TEXT, body);
   this.startActivity(Intent.createChooser(share, this.getString(R.string.share_text)));
 }
Пример #4
0
  private void saveNoteIfNotEmpty() {

    Log.d(TAG, "saveNoteIfNotEmpty() called");

    String title = titleEditText.getText().toString();
    String body = bodyEditText.getText().toString();

    if (title.isEmpty() && body.isEmpty()) {
      return;
    } else {
      saveNote();
    }
  }
Пример #5
0
  private void setupRowPositionAndTextSize(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
      mRowId = savedInstanceState.getLong(KEY_SAVED_POSITION);
      mTextSize = savedInstanceState.getFloat(TEXT_SIZE, 0);
    }

    if (mTextSize == 0) {
      mTextSize = getSharedPreferences(PREFS_NAME, MODE_PRIVATE).getFloat(TEXT_SIZE, 0);
    }

    if (mTextSize != 0) {
      bodyEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextSize);
    }
  }
Пример #6
0
  private void setUpNoteFromDatabase(Intent intent) {
    long id = intent.getLongExtra(EXTRA_NOTE_ID, 1);
    Log.d(TAG, "Got ID " + id + " from intent extra");

    note = noteProvider.getNote(id);
    Log.d(TAG, "Retrieved the following Note from the database: " + note.toString());

    if (note.getTitle().equals(PLACEHOLDER_TEXT_FOR_DATABASE)) {
      note.setTitle("");
    }
    if (note.getBody().equals(PLACEHOLDER_TEXT_FOR_DATABASE)) {
      note.setBody("");
    }

    titleEditText.setText(note.getTitle());
    bodyEditText.setText(note.getBody());

    noteExistsInDatabase = true;
  }