Loading app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java +35 −11 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.core.graphics.drawable.IconCompat; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.owncloud.android.lib.common.utils.Log_OC; import java.util.ArrayList; import java.util.Calendar; Loading Loading @@ -141,7 +142,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego requireActivity().invalidateOptionsMenu(); } } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); Log_OC.e(TAG, e.getLocalizedMessage()); } }); setHasOptionsMenu(true); Loading Loading @@ -240,16 +241,26 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego repo.updateNoteAndSync(localAccount, originalNote, null, null, null); } }); if (listener != null) { listener.close(); } return true; } else if (itemId == R.id.menu_delete) { repo.deleteNoteAndSync(localAccount, note.getId()); if (listener != null) { listener.close(); } return true; } else if (itemId == R.id.menu_favorite) { note.setFavorite(!note.getFavorite()); repo.toggleFavoriteAndSync(localAccount, note); if (listener != null) { listener.onNoteUpdated(note); } prepareFavoriteOption(item); return true; } else if (itemId == R.id.menu_category) { Loading Loading @@ -288,15 +299,29 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego } protected void shareNote() { if (note == null) { Log_OC.w(TAG, "Note is null in shareNote"); return; } ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); } @CallSuper protected void onNoteLoaded(Note note) { if (note == null) { Log_OC.w(TAG, "Note is null in onNoteLoaded"); return; } this.originalScrollY = note.getScrollY(); scrollToY(originalScrollY); final var scrollView = getScrollView(); if (scrollView != null) { if (scrollView == null) { Log_OC.w(TAG, "Scroll view is null, onNoteLoaded"); return; } scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> { if (scrollY > 0) { note.setScrollY(scrollY); Loading @@ -304,7 +329,6 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego onScroll(scrollY, oldScrollY); }); } } /** * Scroll callback, to be overridden by subclasses. Default implementation is empty Loading app/src/main/java/it/niedermann/owncloud/notes/edit/NoteDirectEditFragment.kt +6 −1 Original line number Diff line number Diff line Loading @@ -148,8 +148,13 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded { disposables.add(timeoutDisposable) } override fun onNoteLoaded(note: Note) { override fun onNoteLoaded(note: Note?) { super.onNoteLoaded(note) if (note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded") return } Log.d(TAG, "onNoteLoaded() called") val newNoteParam = arguments?.getSerializable(PARAM_NEWNOTE) as Note? if (newNoteParam != null || note.remoteId == null) { Loading app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.preference.PreferenceManager; import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.owncloud.android.lib.common.utils.Log_OC; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; Loading Loading @@ -182,7 +183,8 @@ public class NoteEditFragment extends SearchableBaseNoteFragment { @Override protected void onNoteLoaded(Note note) { super.onNoteLoaded(note); if (binding == null) { if (binding == null || note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded"); return; } Loading app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java +5 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,11 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O @Override protected void onNoteLoaded(Note note) { super.onNoteLoaded(note); if (note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded"); return; } noteLoaded = true; registerInternalNoteLinkHandler(); Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java +35 −11 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import androidx.core.graphics.drawable.IconCompat; import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.owncloud.android.lib.common.utils.Log_OC; import java.util.ArrayList; import java.util.Calendar; Loading Loading @@ -141,7 +142,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego requireActivity().invalidateOptionsMenu(); } } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); Log_OC.e(TAG, e.getLocalizedMessage()); } }); setHasOptionsMenu(true); Loading Loading @@ -240,16 +241,26 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego repo.updateNoteAndSync(localAccount, originalNote, null, null, null); } }); if (listener != null) { listener.close(); } return true; } else if (itemId == R.id.menu_delete) { repo.deleteNoteAndSync(localAccount, note.getId()); if (listener != null) { listener.close(); } return true; } else if (itemId == R.id.menu_favorite) { note.setFavorite(!note.getFavorite()); repo.toggleFavoriteAndSync(localAccount, note); if (listener != null) { listener.onNoteUpdated(note); } prepareFavoriteOption(item); return true; } else if (itemId == R.id.menu_category) { Loading Loading @@ -288,15 +299,29 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego } protected void shareNote() { if (note == null) { Log_OC.w(TAG, "Note is null in shareNote"); return; } ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); } @CallSuper protected void onNoteLoaded(Note note) { if (note == null) { Log_OC.w(TAG, "Note is null in onNoteLoaded"); return; } this.originalScrollY = note.getScrollY(); scrollToY(originalScrollY); final var scrollView = getScrollView(); if (scrollView != null) { if (scrollView == null) { Log_OC.w(TAG, "Scroll view is null, onNoteLoaded"); return; } scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> { if (scrollY > 0) { note.setScrollY(scrollY); Loading @@ -304,7 +329,6 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego onScroll(scrollY, oldScrollY); }); } } /** * Scroll callback, to be overridden by subclasses. Default implementation is empty Loading
app/src/main/java/it/niedermann/owncloud/notes/edit/NoteDirectEditFragment.kt +6 −1 Original line number Diff line number Diff line Loading @@ -148,8 +148,13 @@ class NoteDirectEditFragment : BaseNoteFragment(), Branded { disposables.add(timeoutDisposable) } override fun onNoteLoaded(note: Note) { override fun onNoteLoaded(note: Note?) { super.onNoteLoaded(note) if (note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded") return } Log.d(TAG, "onNoteLoaded() called") val newNoteParam = arguments?.getSerializable(PARAM_NEWNOTE) as Note? if (newNoteParam != null || note.remoteId == null) { Loading
app/src/main/java/it/niedermann/owncloud/notes/edit/NoteEditFragment.java +3 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import androidx.preference.PreferenceManager; import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.owncloud.android.lib.common.utils.Log_OC; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; Loading Loading @@ -182,7 +183,8 @@ public class NoteEditFragment extends SearchableBaseNoteFragment { @Override protected void onNoteLoaded(Note note) { super.onNoteLoaded(note); if (binding == null) { if (binding == null || note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded"); return; } Loading
app/src/main/java/it/niedermann/owncloud/notes/edit/NotePreviewFragment.java +5 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,11 @@ public class NotePreviewFragment extends SearchableBaseNoteFragment implements O @Override protected void onNoteLoaded(Note note) { super.onNoteLoaded(note); if (note == null) { Log_OC.w(TAG, "Note is null, onNoteLoaded"); return; } noteLoaded = true; registerInternalNoteLinkHandler(); Loading