From 5c64538ed141c52cdf0baa51245110991dae5121 Mon Sep 17 00:00:00 2001 From: Dan Roundhill Date: Fri, 27 Jul 2018 13:30:05 -0700 Subject: [PATCH] Version bumping, and adding a hotfix for notes getting accidentally trashed. --- Simplenote/build.gradle | 6 ++-- .../simplenote/NoteEditorFragment.java | 34 +++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Simplenote/build.gradle b/Simplenote/build.gradle index 21264161b..d210cb980 100644 --- a/Simplenote/build.gradle +++ b/Simplenote/build.gradle @@ -61,7 +61,7 @@ dependencies { wearApp project(':Wear') } -version "1.6.2" +version "1.6.3" android { testOptions { @@ -74,7 +74,7 @@ android { defaultConfig { applicationId "com.automattic.simplenote" versionName project.version - versionCode 65 + versionCode 66 minSdkVersion 16 targetSdkVersion 26 @@ -98,7 +98,7 @@ android { } debug { - applicationIdSuffix '.debug' + //applicationIdSuffix '.debug' } } diff --git a/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java b/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java index 3d62985d1..0936768ec 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/NoteEditorFragment.java @@ -92,7 +92,7 @@ public void run() { private Handler mHistoryTimeoutHandler; private LinearLayout mPlaceholderView; private CursorAdapter mAutocompleteAdapter; - private boolean mIsLoadingNote, mIsMarkdownEnabled, mTextDidChange; + private boolean mIsLoadingNote, mIsMarkdownEnabled; private ActionMode mActionMode; private MenuItem mViewLinkMenuItem; private String mLinkUrl; @@ -367,13 +367,7 @@ public void onPause() { } mHighlighter.stop(); - - // Delete the note if user never edited a new note - if (newNoteWasNeverEdited()) { - permanentlyDeleteNote(); - } else { - saveNote(); - } + saveNote(); super.onPause(); } @@ -502,10 +496,6 @@ private void showInfo() { } } - private boolean newNoteWasNeverEdited() { - return mNote != null && TextUtils.isEmpty(getNoteContentString()) && mNote.isNew() && !mTextDidChange; - } - protected void setMarkdownEnabled(boolean enabled) { mIsMarkdownEnabled = enabled; @@ -532,13 +522,7 @@ public void setNote(String noteID, String matchOffsets) { } - if (newNoteWasNeverEdited()) { - // Delete a new, never edited note - permanentlyDeleteNote(); - } else { - // If we have a note already (on a tablet in landscape), save the note. - saveNote(); - } + saveNote(); new loadNoteTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, noteID); } @@ -659,7 +643,6 @@ public void afterTextChanged(Editable editable) { @Override public void onTextChanged(CharSequence charSequence, int start, int before, int count) { - mTextDidChange = true; // When text changes, start timer that will fire after AUTOSAVE_DELAY_MILLIS passes if (mAutoSaveHandler != null) { mAutoSaveHandler.removeCallbacks(mAutoSaveRunnable); @@ -1162,8 +1145,17 @@ protected Void doInBackground(String... args) { mIsMarkdownEnabled = mNote.isMarkdownEnabled(); } } catch (BucketObjectMissingException e) { - // TODO: Handle a missing note + // See if the note is in the object store + Bucket.ObjectCursor notesCursor = notesBucket.allObjects(); + while (notesCursor.moveToNext()) { + Note currentNote = notesCursor.getObject(); + if (currentNote != null && currentNote.getSimperiumKey().equals(noteID)) { + mNote = currentNote; + return null; + } + } } + return null; }