Skip to content
Merged
Show file tree
Hide file tree
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
Fix toolbar when switching between direct edit and normal edit
Signed-off-by: Álvaro Brey <[email protected]>
  • Loading branch information
AlvaroBrey committed Mar 7, 2023
commit 05a76e45033d26d11000a3e033c12b1c55d24205
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@ protected void onNoteLoaded(Note note) {
protected void onScroll(int scrollY, int oldScrollY) {
}

protected boolean shouldShowToolbar() {
return true;
}

public void onCloseNote() {
if (!titleModified && originalNote == null && getContent().isEmpty()) {
repo.deleteNoteAndSync(localAccount, note.getId());
Expand Down Expand Up @@ -383,8 +387,6 @@ enum Mode {

void onNoteUpdated(Note note);

void setToolbarVisibility(boolean visible);

void changeMode(@NonNull Mode mode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ private void launchExistingNote(long accountId, long noteId, @Nullable final Str
fragment.setInitialSavedState(savedState);
}
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container_view, fragment).commit();
if(!fragment.shouldShowToolbar()){
binding.toolbar.setVisibility(View.GONE);
}else {
binding.toolbar.setVisibility(View.VISIBLE);
}
}

private String getPreferenceMode() {
Expand Down Expand Up @@ -334,11 +339,6 @@ public void onNoteUpdated(Note note) {
}
}

@Override
public void setToolbarVisibility(boolean visible) {
binding.toolbar.setVisibility(visible ? View.VISIBLE : View.GONE);
}

@Override
public void changeMode(@NonNull Mode mode) {
switch (mode) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package it.niedermann.owncloud.notes.edit

import android.annotation.SuppressLint
import android.content.Context
import android.content.pm.ApplicationInfo
import android.net.http.SslError
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.webkit.JavascriptInterface
Expand All @@ -26,13 +26,15 @@ import it.niedermann.owncloud.notes.persistence.DirectEditingRepository
import it.niedermann.owncloud.notes.persistence.entity.Note
import it.niedermann.owncloud.notes.shared.model.ISyncCallback
import it.niedermann.owncloud.notes.shared.util.ExtendedFabUtil
import it.niedermann.owncloud.notes.shared.util.ExtendedFabUtil.toggleVisibilityOnScroll

class NoteDirectEditFragment : BaseNoteFragment(), Branded {
private var _binding: FragmentNoteDirectEditBinding? = null
private val binding: FragmentNoteDirectEditBinding
get() = _binding!!

// for hiding / showing the fab
private var scrollStart: Int = 0

public override fun getScrollView(): ScrollView? {
return null
}
Expand Down Expand Up @@ -71,8 +73,21 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
private fun setupFab() {
binding.plainEditingFab.isExtended = false
ExtendedFabUtil.toggleExtendedOnLongClick(binding.plainEditingFab)
binding.noteWebview.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
toggleVisibilityOnScroll(binding.plainEditingFab, scrollY, oldScrollY)
binding.noteWebview.setOnTouchListener { _, event ->
when (event.action) {
MotionEvent.ACTION_DOWN -> {
scrollStart = event.y.toInt()
}
MotionEvent.ACTION_UP -> {
val scrollEnd = event.y.toInt()
ExtendedFabUtil.toggleVisibilityOnScroll(
binding.plainEditingFab,
scrollStart,
scrollEnd,
)
}
}
return@setOnTouchListener false
}
binding.plainEditingFab.setOnClickListener {
// TODO save note?
Expand All @@ -86,11 +101,6 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
_binding = null
}

override fun onAttach(context: Context) {
super.onAttach(context)
listener.setToolbarVisibility(false)
}

override fun onNoteLoaded(note: Note) {
super.onNoteLoaded(note)
Log.d(TAG, "onNoteLoaded() called with: note = $note")
Expand All @@ -106,12 +116,15 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded {
Log.d(TAG, "onNoteLoaded: url = $url")
}
binding.noteWebview.loadUrl(url)
// TODO show warn/error if not loaded after 10 seconds
}, { throwable ->
// TODO handle error
Log.e(TAG, "onNoteLoaded:", throwable)
})
}

override fun shouldShowToolbar(): Boolean = false

@SuppressLint("SetJavaScriptEnabled")
private fun setupWebSettings(webSettings: WebSettings) {
WebView.setWebContentsDebuggingEnabled(true)
Expand Down