diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java index 7c56c1e1..c4adc066 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java @@ -115,6 +115,11 @@ public class NoteEditFragment extends SearchableBaseNoteFragment { return binding.directEditing; } + protected ExtendedFloatingActionButton getNormalEditButton() { + // the edit fragment does not have a button + return null; + } + @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java index 21f8a7c7..368fb5d9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java @@ -58,6 +58,10 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O public void onPrepareOptionsMenu(@NonNull Menu menu) { super.onPrepareOptionsMenu(menu); menu.findItem(R.id.menu_edit).setVisible(true); + if(getNormalEditButton().getVisibility() == View.VISIBLE) { + menu.findItem(R.id.menu_edit).setVisible(false); + } + menu.findItem(R.id.menu_preview).setVisible(false); } @@ -92,6 +96,11 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O return binding.directEditing; } + @Override + protected ExtendedFloatingActionButton getNormalEditButton() { + return binding.edit; + } + @Override protected Layout getLayout() { binding.singleNoteContent.onPreDraw(); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java b/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java index 4711c0bf..652a5eea 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/edit/SearchableBaseNoteFragment.java @@ -85,7 +85,7 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); checkDirectEditingAvailable(); - if (directEditAvailable) { + if (directEditAvailable && isDirectEditEnabled()) { final ExtendedFloatingActionButton directEditingButton = getDirectEditingButton(); directEditingButton.setExtended(false); ExtendedFabUtil.toggleExtendedOnLongClick(directEditingButton); @@ -96,6 +96,15 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { }); } else { getDirectEditingButton().setVisibility(View.GONE); + ExtendedFloatingActionButton edit = getNormalEditButton(); + if(edit!=null) { + edit.setVisibility(View.VISIBLE); + edit.setOnClickListener(v -> { + if (listener != null) { + listener.changeMode(NoteFragmentListener.Mode.EDIT, true); + } + }); + } } } @@ -110,6 +119,14 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { } } + protected boolean isDirectEditEnabled() { + if (!directEditAvailable) { + return false; + } + //todo: handle preference here + return false; + } + @Override public void onPrepareOptionsMenu(@NonNull Menu menu) { super.onPrepareOptionsMenu(menu); @@ -258,6 +275,7 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { @NonNull protected abstract ExtendedFloatingActionButton getDirectEditingButton(); + protected abstract ExtendedFloatingActionButton getNormalEditButton(); private void showSearchFabs() { ExtendedFabUtil.setExtendedFabVisibility(getDirectEditingButton(), false); @@ -353,5 +371,9 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment { util.material.themeFAB(getSearchNextButton()); util.material.themeFAB(getSearchPrevButton()); util.material.themeExtendedFAB(getDirectEditingButton()); + var editFab = getNormalEditButton(); + if(editFab != null) { + util.material.themeExtendedFAB(editFab); + } } } diff --git a/app/src/main/res/layout/fragment_note_preview.xml b/app/src/main/res/layout/fragment_note_preview.xml index 30c95662..707223d7 100644 --- a/app/src/main/res/layout/fragment_note_preview.xml +++ b/app/src/main/res/layout/fragment_note_preview.xml @@ -81,4 +81,19 @@ app:layout_anchor="@id/scrollView" app:layout_anchorGravity="bottom|end" app:icon="@drawable/ic_rich_editing" /> + +