#439 Allow Rendering of any markdown file

Some refactorings
This commit is contained in:
stefan-niedermann 2020-01-23 22:35:16 +01:00
parent 5cde97fe73
commit 10de6d0adf
4 changed files with 8 additions and 7 deletions

View file

@ -75,7 +75,7 @@
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:mimeType="text/*" />
</intent-filter>
</activity>

View file

@ -177,19 +177,19 @@ public class EditNoteActivity extends AppCompatActivity implements BaseNoteFragm
private void launchReadonlyNote() {
Intent intent = getIntent();
StringBuilder text = new StringBuilder();
StringBuilder content = new StringBuilder();
try {
InputStream inputStream = getContentResolver().openInputStream(Objects.requireNonNull(intent.getData()));
BufferedReader r = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream)));
String mLine;
while ((mLine = r.readLine()) != null) {
text.append(mLine).append('\n');
String line;
while ((line = r.readLine()) != null) {
content.append(line).append('\n');
}
} catch (IOException e) {
e.printStackTrace();
}
fragment = NoteReadonlyFragment.newInstance(text.toString());
fragment = NoteReadonlyFragment.newInstance(content.toString());
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fragment).commit();
}

View file

@ -92,7 +92,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
if (content == null) {
throw new IllegalArgumentException(PARAM_NOTE_ID + " is not given, argument " + PARAM_NEWNOTE + " is missing and " + PARAM_CONTENT + " is missing.");
} else {
note = new DBNote(-1, -1, null, NoteUtil.generateNonEmptyNoteTitle(content, getContext()), content, false, "", null, DBStatus.VOID, -1, "");
note = new DBNote(-1, -1, null, NoteUtil.generateNonEmptyNoteTitle(content, getContext()), content, false, getString(R.string.category_readonly), null, DBStatus.VOID, -1, "");
}
} else {
note = db.getNote(localAccount.getId(), db.addNoteAndSync(localAccount.getId(), cloudNote));

View file

@ -143,6 +143,7 @@
<string name="checkbox_could_not_be_toggled">Checkbox could not be toggled.</string>
<string name="bulk_notes_deleted">Deleted %1$d notes</string>
<string name="bulk_notes_restored">Restored %1$d notes</string>
<string name="category_readonly">Read only</string>
<!-- Array: note modes -->
<string-array name="noteMode_entries">