Merge branch '831-room' into 831-room-livedata

# Conflicts:
#	app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java
This commit is contained in:
Stefan Niedermann 2020-10-08 13:50:12 +02:00
commit 0b263beea5
5 changed files with 9 additions and 15 deletions

View file

@ -114,7 +114,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego
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 Note(-1, -1, null, NoteUtil.generateNoteTitle(content), content, false, getString(R.string.category_readonly), null, DBStatus.VOID, -1, "", 0);
note = new Note(-1, -1L, null, NoteUtil.generateNoteTitle(content), content, false, getString(R.string.category_readonly), null, DBStatus.VOID, -1, "", 0);
}
} else {
note = db.getNoteDao().getNote(localAccount.getId(), db.addNoteAndSync(ssoAccount, localAccount.getId(), cloudNote));

View file

@ -179,7 +179,7 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
if (content == null) {
content = "";
}
Note newNote = new Note(0, Calendar.getInstance(), NoteUtil.generateNonEmptyNoteTitle(content, this), content, favorite, category, null);
Note newNote = new Note(null, Calendar.getInstance(), NoteUtil.generateNonEmptyNoteTitle(content, this), content, favorite, category, null);
fragment = NoteEditFragment.newInstanceWithNewNote(newNote);
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_view, fragment).commit();
}

View file

@ -196,12 +196,6 @@ public class MainActivity extends LockedActivity implements NoteClickListener, V
this.fabCreate = binding.activityNotesListView.fabCreate;
this.listView = binding.activityNotesListView.recyclerView;
mainViewModel.filterChanged().observe(this, (v) -> {
noteWithCategoryLiveData.removeObserver(noteWithCategoryObserver);
noteWithCategoryLiveData = mainViewModel.getNotesListLiveData();
noteWithCategoryLiveData.observe(this, noteWithCategoryObserver);
});
String categoryAdapterSelectedItem = ADAPTER_KEY_RECENT;
if (savedInstanceState == null) {
if (ACTION_RECENT.equals(getIntent().getAction())) {

View file

@ -152,7 +152,7 @@ public abstract class NotesDatabase extends RoomDatabase {
* @param note Note
*/
public long addNoteAndSync(SingleSignOnAccount ssoAccount, long accountId, Note note) {
Note entity = new Note(0, 0, note.getModified(), note.getTitle(), note.getContent(), note.getFavorite(), note.getCategory(), note.getETag(), DBStatus.LOCAL_EDITED, accountId, generateNoteExcerpt(note.getContent(), note.getTitle()), 0);
Note entity = new Note(0, null, note.getModified(), note.getTitle(), note.getContent(), note.getFavorite(), note.getCategory(), note.getETag(), DBStatus.LOCAL_EDITED, accountId, generateNoteExcerpt(note.getContent(), note.getTitle()), 0);
long id = addNote(accountId, entity);
notifyWidgets();
serverSyncHelper.scheduleSync(ssoAccount, true);
@ -179,7 +179,7 @@ public abstract class NotesDatabase extends RoomDatabase {
entity.setAccountId(accountId);
entity.setExcerpt(generateNoteExcerpt(note.getContent(), note.getTitle()));
}
if (note.getRemoteId() > 0) {
if (note.getRemoteId() != null && note.getRemoteId() > 0) {
entity.setRemoteId(note.getRemoteId());
}
entity.setTitle(note.getTitle());
@ -194,7 +194,7 @@ public abstract class NotesDatabase extends RoomDatabase {
public void moveNoteToAnotherAccount(SingleSignOnAccount ssoAccount, long oldAccountId, Note note, long newAccountId) {
// Add new note
addNoteAndSync(ssoAccount, newAccountId, new Note(0, note.getModified(), note.getTitle(), note.getContent(), note.getFavorite(), note.getCategory(), null));
addNoteAndSync(ssoAccount, newAccountId, new Note(null, note.getModified(), note.getTitle(), note.getContent(), note.getFavorite(), note.getCategory(), null));
deleteNoteAndSync(ssoAccount, note.getId());
notifyWidgets();
@ -261,7 +261,7 @@ public abstract class NotesDatabase extends RoomDatabase {
if (newTitle != null) {
title = newTitle;
} else {
if (oldNote.getRemoteId() == 0 || localAccount.getPreferredApiVersion() == null || localAccount.getPreferredApiVersion().compareTo(new ApiVersion("1.0", 0, 0)) < 0) {
if (oldNote.getRemoteId() == null || oldNote.getRemoteId() == 0 || localAccount.getPreferredApiVersion() == null || localAccount.getPreferredApiVersion().compareTo(new ApiVersion("1.0", 0, 0)) < 0) {
title = NoteUtil.generateNonEmptyNoteTitle(newContent, context);
} else {
title = oldNote.getTitle();

View file

@ -57,14 +57,14 @@ public class Note implements Serializable {
@ColumnInfo(defaultValue = "0")
private Integer scrollY = 0;
@Ignore
private String category;
private String category = "";
public Note() {
super();
}
@Ignore
public Note(long remoteId, Calendar modified, String title, String content, Boolean favorite, String category, String eTag) {
public Note(Long remoteId, Calendar modified, String title, String content, Boolean favorite, String category, String eTag) {
this.remoteId = remoteId;
this.title = title;
this.modified = modified;
@ -75,7 +75,7 @@ public class Note implements Serializable {
}
@Ignore
public Note(long id, long remoteId, Calendar modified, String title, String content, boolean favorite, String category, String etag, DBStatus status, long accountId, @NonNull String excerpt, Integer scrollY) {
public Note(long id, Long remoteId, Calendar modified, String title, String content, boolean favorite, String category, String etag, DBStatus status, long accountId, @NonNull String excerpt, Integer scrollY) {
this(remoteId, modified, title, content, favorite, category, etag);
this.id = id;
this.status = status;