Skip to content

Commit

Permalink
Fixed sharing of notes and migration from db 2 to 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamuno committed Jul 31, 2022
1 parent 3874e2a commit 83bb475
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,25 @@ public void migrate(SupportSQLiteDatabase database) {
while (!c.isAfterLast()) {
String note = c.getString(c.getColumnIndexOrThrow("content"));

if(note.startsWith("<p")) {
if(note.startsWith("<p dir=")) {
i++;
c.moveToNext();
continue;
}

String encodedNote = Html.toHtml(new SpannedString(note));

encodedContent[i] = new Pair<>(c.getInt(c.getColumnIndexOrThrow("_id")), encodedNote);
encodedContent[i++] = new Pair<>(c.getInt(c.getColumnIndexOrThrow("_id")), encodedNote);
c.moveToNext();
}
}
c.close();
}

for(Pair<Integer,String> note : encodedContent) {
if(note == null) {
continue;
}
ContentValues cv = new ContentValues();
cv.put("content", note.second);
database.update("notes", 0, cv, "_id = ?", new String[]{Integer.toString(note.first)});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, etName.getText().toString() + "\n\n" + Html.toHtml(etContent.getText()));
sendIntent.putExtra(Intent.EXTRA_TEXT, etName.getText().toString() + "\n\n" + etContent.getText());
startActivity(Intent.createChooser(sendIntent, null));
}

Expand Down

0 comments on commit 83bb475

Please sign in to comment.