Loading app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java +35 −11 Original line number Original line 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.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.owncloud.android.lib.common.utils.Log_OC; import java.util.ArrayList; import java.util.ArrayList; import java.util.Calendar; import java.util.Calendar; Loading Loading @@ -141,7 +142,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego requireActivity().invalidateOptionsMenu(); requireActivity().invalidateOptionsMenu(); } } } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); Log_OC.e(TAG, e.getLocalizedMessage()); } } }); }); setHasOptionsMenu(true); setHasOptionsMenu(true); Loading Loading @@ -240,16 +241,26 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego repo.updateNoteAndSync(localAccount, originalNote, null, null, null); repo.updateNoteAndSync(localAccount, originalNote, null, null, null); } } }); }); if (listener != null) { listener.close(); listener.close(); } return true; return true; } else if (itemId == R.id.menu_delete) { } else if (itemId == R.id.menu_delete) { repo.deleteNoteAndSync(localAccount, note.getId()); repo.deleteNoteAndSync(localAccount, note.getId()); if (listener != null) { listener.close(); listener.close(); } return true; return true; } else if (itemId == R.id.menu_favorite) { } else if (itemId == R.id.menu_favorite) { note.setFavorite(!note.getFavorite()); note.setFavorite(!note.getFavorite()); repo.toggleFavoriteAndSync(localAccount, note); repo.toggleFavoriteAndSync(localAccount, note); if (listener != null) { listener.onNoteUpdated(note); listener.onNoteUpdated(note); } prepareFavoriteOption(item); prepareFavoriteOption(item); return true; return true; } else if (itemId == R.id.menu_category) { } else if (itemId == R.id.menu_category) { Loading Loading @@ -288,15 +299,29 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego } } protected void shareNote() { protected void shareNote() { if (note == null) { Log_OC.w(TAG, "Note is null in shareNote"); return; } ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); } } @CallSuper @CallSuper protected void onNoteLoaded(Note note) { protected void onNoteLoaded(Note note) { if (note == null) { Log_OC.w(TAG, "Note is null in onNoteLoaded"); return; } this.originalScrollY = note.getScrollY(); this.originalScrollY = note.getScrollY(); scrollToY(originalScrollY); scrollToY(originalScrollY); final var scrollView = getScrollView(); 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) -> { scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> { if (scrollY > 0) { if (scrollY > 0) { note.setScrollY(scrollY); note.setScrollY(scrollY); Loading @@ -304,7 +329,6 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego onScroll(scrollY, oldScrollY); onScroll(scrollY, oldScrollY); }); }); } } } /** /** * Scroll callback, to be overridden by subclasses. Default implementation is empty * Scroll callback, to be overridden by subclasses. Default implementation is empty Loading Loading
app/src/main/java/it/niedermann/owncloud/notes/edit/BaseNoteFragment.java +35 −11 Original line number Original line 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.NextcloudFilesAppAccountNotFoundException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.exceptions.NoCurrentAccountSelectedException; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.nextcloud.android.sso.helper.SingleAccountHelper; import com.owncloud.android.lib.common.utils.Log_OC; import java.util.ArrayList; import java.util.ArrayList; import java.util.Calendar; import java.util.Calendar; Loading Loading @@ -141,7 +142,7 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego requireActivity().invalidateOptionsMenu(); requireActivity().invalidateOptionsMenu(); } } } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) { e.printStackTrace(); Log_OC.e(TAG, e.getLocalizedMessage()); } } }); }); setHasOptionsMenu(true); setHasOptionsMenu(true); Loading Loading @@ -240,16 +241,26 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego repo.updateNoteAndSync(localAccount, originalNote, null, null, null); repo.updateNoteAndSync(localAccount, originalNote, null, null, null); } } }); }); if (listener != null) { listener.close(); listener.close(); } return true; return true; } else if (itemId == R.id.menu_delete) { } else if (itemId == R.id.menu_delete) { repo.deleteNoteAndSync(localAccount, note.getId()); repo.deleteNoteAndSync(localAccount, note.getId()); if (listener != null) { listener.close(); listener.close(); } return true; return true; } else if (itemId == R.id.menu_favorite) { } else if (itemId == R.id.menu_favorite) { note.setFavorite(!note.getFavorite()); note.setFavorite(!note.getFavorite()); repo.toggleFavoriteAndSync(localAccount, note); repo.toggleFavoriteAndSync(localAccount, note); if (listener != null) { listener.onNoteUpdated(note); listener.onNoteUpdated(note); } prepareFavoriteOption(item); prepareFavoriteOption(item); return true; return true; } else if (itemId == R.id.menu_category) { } else if (itemId == R.id.menu_category) { Loading Loading @@ -288,15 +299,29 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego } } protected void shareNote() { protected void shareNote() { if (note == null) { Log_OC.w(TAG, "Note is null in shareNote"); return; } ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); ShareUtil.openShareDialog(requireContext(), note.getTitle(), note.getContent()); } } @CallSuper @CallSuper protected void onNoteLoaded(Note note) { protected void onNoteLoaded(Note note) { if (note == null) { Log_OC.w(TAG, "Note is null in onNoteLoaded"); return; } this.originalScrollY = note.getScrollY(); this.originalScrollY = note.getScrollY(); scrollToY(originalScrollY); scrollToY(originalScrollY); final var scrollView = getScrollView(); 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) -> { scrollView.setOnScrollChangeListener((View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) -> { if (scrollY > 0) { if (scrollY > 0) { note.setScrollY(scrollY); note.setScrollY(scrollY); Loading @@ -304,7 +329,6 @@ public abstract class BaseNoteFragment extends BrandedFragment implements Catego onScroll(scrollY, oldScrollY); onScroll(scrollY, oldScrollY); }); }); } } } /** /** * Scroll callback, to be overridden by subclasses. Default implementation is empty * Scroll callback, to be overridden by subclasses. Default implementation is empty Loading