Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
c3cfbc4
feat(capabilities): Fetch and store direct editing capability using e…
AlvaroBrey Feb 15, 2023
d9aa4e7
feat: Implement direct editing repo
AlvaroBrey Feb 15, 2023
a133f9a
wip: Edit note with webview
AlvaroBrey Feb 17, 2023
4c1b5c8
wip: allow switching between the three note opening modes in preferences
AlvaroBrey Feb 24, 2023
8eea351
EditNoteActivity: if no setting, use plain edit, not direct edit
AlvaroBrey Feb 24, 2023
61a4399
feat: Add FAB to switch to rich editing mode from plain edit/preview
AlvaroBrey Feb 24, 2023
c0b2783
feat: add fab while direct editing to switch to normal editing
AlvaroBrey Feb 24, 2023
05a76e4
Fix toolbar when switching between direct edit and normal edit
AlvaroBrey Feb 27, 2023
3e4c90c
wip: error and conflict handling when switching edit modes
AlvaroBrey Mar 1, 2023
c3ea2f6
Only show direct editing FAB if direct editing is available
AlvaroBrey Mar 2, 2023
ff0a48c
EditNoteActivity: if pref is direct edit but it's not available, laun…
AlvaroBrey Mar 2, 2023
3fd864f
Show error if direct editing not loaded after 10 seconds
AlvaroBrey Mar 2, 2023
145af2e
Update user agent for Notes webview
AlvaroBrey Mar 2, 2023
6ac80ef
Support opening new notes with direct editing
AlvaroBrey Mar 2, 2023
08fad49
Allow invalid ssl certs for debug builds in webview
AlvaroBrey Mar 7, 2023
7b169a0
NoteDirectEdit: prevent duplicate note creation when creating it with…
AlvaroBrey Mar 7, 2023
5e517ff
Fix create with plain edit -> direct edit flow
AlvaroBrey Mar 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
EditNoteActivity: if pref is direct edit but it's not available, laun…
…ch normal edit instead

Signed-off-by: Álvaro Brey <[email protected]>
  • Loading branch information
AlvaroBrey committed Mar 7, 2023
commit ff0a48c008f6731af585ff2ad94aaf86a034b780
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import it.niedermann.owncloud.notes.databinding.ActivityEditBinding;
import it.niedermann.owncloud.notes.edit.category.CategoryViewModel;
import it.niedermann.owncloud.notes.main.MainActivity;
import it.niedermann.owncloud.notes.persistence.NotesRepository;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.shared.model.NavigationCategory;
Expand All @@ -59,11 +60,14 @@ public class EditNoteActivity extends LockedActivity implements BaseNoteFragment
private ActivityEditBinding binding;

private BaseNoteFragment fragment;
private NotesRepository repo;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

repo = NotesRepository.getInstance(getApplicationContext());

try {
if (SingleAccountHelper.getCurrentSingleSignOnAccount(this) == null) {
throw new NoCurrentAccountSelectedException();
Expand Down Expand Up @@ -184,11 +188,16 @@ private void launchExistingNote(long accountId, long noteId, @Nullable final Str
}


private String getPreferenceMode() {
private String getPreferenceMode(long accountId) {
final Account accountById = repo.getAccountById(accountId);
final var directEditAvailable = accountById != null && accountById.isDirectEditingAvailable();

final var prefKeyNoteMode = getString(R.string.pref_key_note_mode);
final var prefKeyLastMode = getString(R.string.pref_key_last_note_mode);
final var defaultMode = getString(R.string.pref_value_mode_edit);
final var prefValueLast = getString(R.string.pref_value_mode_last);
final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit);


final var preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
final String modePreference = preferences.getString(prefKeyNoteMode, defaultMode);
Expand All @@ -198,12 +207,16 @@ private String getPreferenceMode() {
effectiveMode = preferences.getString(prefKeyLastMode, defaultMode);
}

if (effectiveMode.equals(prefValueDirectEdit) && !directEditAvailable) {
effectiveMode = defaultMode;
}

return effectiveMode;
}

private BaseNoteFragment getNoteFragment(long accountId, long noteId, final @Nullable String modePref) {

final var effectiveMode = modePref == null ? getPreferenceMode() : modePref;
final var effectiveMode = modePref == null ? getPreferenceMode(accountId) : modePref;

final var prefValueEdit = getString(R.string.pref_value_mode_edit);
final var prefValueDirectEdit = getString(R.string.pref_value_mode_direct_edit);
Expand Down