mirror of
https://github.com/nextcloud/notes-android.git
synced 2025-07-23 05:20:09 +00:00
Allow an edit fab to replace the rich text fab
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
This commit is contained in:

committed by
backportbot[bot]
![backportbot[bot]](/assets/img/avatar_default.png)
parent
6fc496565f
commit
c15c529352
@ -109,6 +109,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) {
|
||||
|
@ -52,6 +52,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);
|
||||
}
|
||||
|
||||
@ -86,6 +90,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();
|
||||
|
@ -79,7 +79,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);
|
||||
@ -90,6 +90,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,6 +113,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);
|
||||
@ -252,6 +269,7 @@ public abstract class SearchableBaseNoteFragment extends BaseNoteFragment {
|
||||
@NonNull
|
||||
protected abstract ExtendedFloatingActionButton getDirectEditingButton();
|
||||
|
||||
protected abstract ExtendedFloatingActionButton getNormalEditButton();
|
||||
|
||||
private void showSearchFabs() {
|
||||
ExtendedFabUtil.setExtendedFabVisibility(getDirectEditingButton(), false);
|
||||
@ -347,5 +365,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -75,4 +75,19 @@
|
||||
app:layout_anchor="@id/scrollView"
|
||||
app:layout_anchorGravity="bottom|end"
|
||||
app:icon="@drawable/ic_rich_editing" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:id="@+id/edit"
|
||||
style="?attr/floatingActionButtonPrimaryStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/spacer_2x"
|
||||
android:contentDescription="@string/noteMode_plain_edit"
|
||||
android:text="@string/noteMode_plain_edit"
|
||||
android:visibility="visible"
|
||||
app:backgroundTint="@color/defaultBrand"
|
||||
app:layout_anchor="@id/scrollView"
|
||||
app:layout_anchorGravity="bottom|end"
|
||||
app:icon="@drawable/ic_edit_grey600_24dp" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
Reference in New Issue
Block a user