diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java b/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java index b1fed044f..d18e55a44 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/ListFragment.java @@ -34,6 +34,7 @@ import static it.feio.android.omninotes.utils.ConstantsBase.PREF_FAB_EXPANSION_BEHAVIOR; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_FILTER_ARCHIVED_IN_CATEGORIES; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_FILTER_PAST_REMINDERS; +import static it.feio.android.omninotes.utils.ConstantsBase.PREF_MINIMAL_VIEW; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_NAVIGATION; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_SORTING_COLUMN; import static it.feio.android.omninotes.utils.ConstantsBase.PREF_WIDGET_PREFIX; @@ -735,6 +736,7 @@ private void setActionItemsVisibility(Menu menu, boolean searchViewHasFocus) { mainActivity.getDrawerLayout() != null && mainActivity.getDrawerLayout().isDrawerOpen (GravityCompat.START); boolean expandedView = Prefs.getBoolean(PREF_EXPANDED_VIEW, true); + boolean minimalView = Prefs.getBoolean(PREF_MINIMAL_VIEW, true); int navigation = Navigation.getNavigation(); boolean navigationReminders = navigation == Navigation.REMINDERS; @@ -770,7 +772,9 @@ private void setActionItemsVisibility(Menu menu, boolean searchViewHasFocus) { menu.findItem(R.id.menu_expanded_view) .setVisible(!drawerOpen && !expandedView && !searchViewHasFocus); menu.findItem(R.id.menu_contracted_view) - .setVisible(!drawerOpen && expandedView && !searchViewHasFocus); + .setVisible(!drawerOpen && (expandedView || minimalView) && !searchViewHasFocus); + menu.findItem(R.id.menu_minimal_view) + .setVisible(!drawerOpen && (expandedView || !minimalView) && !searchViewHasFocus); menu.findItem(R.id.menu_empty_trash).setVisible(!drawerOpen && navigationTrash); menu.findItem(R.id.menu_uncomplete_checklists).setVisible(searchViewHasFocus); menu.findItem(R.id.menu_tags).setVisible(searchViewHasFocus); @@ -833,10 +837,13 @@ public void performAction(MenuItem item, ActionMode actionMode) { initSortingSubmenu(); break; case R.id.menu_expanded_view: - switchNotesView(); + switchNotesView(1); + break; + case R.id.menu_minimal_view: + switchNotesView(2); break; case R.id.menu_contracted_view: - switchNotesView(); + switchNotesView(3); break; case R.id.menu_empty_trash: emptyTrash(); @@ -903,16 +910,26 @@ private void addReminders() { } - private void switchNotesView() { - boolean expandedView = Prefs.getBoolean(PREF_EXPANDED_VIEW, true); - Prefs.edit().putBoolean(PREF_EXPANDED_VIEW, !expandedView).apply(); + private void switchNotesView(int flag) { + if (flag == 1){ + Prefs.edit().putBoolean(PREF_EXPANDED_VIEW, true).apply(); + Prefs.edit().putBoolean(PREF_MINIMAL_VIEW, false).apply(); + } + else if (flag == 2){ + Prefs.edit().putBoolean(PREF_MINIMAL_VIEW, true).apply(); + Prefs.edit().putBoolean(PREF_EXPANDED_VIEW, false).apply(); + } + else{ + Prefs.edit().putBoolean(PREF_EXPANDED_VIEW, false).apply(); + Prefs.edit().putBoolean(PREF_MINIMAL_VIEW, false).apply(); + } + // Change list view initNotesList(mainActivity.getIntent()); // Called to switch menu voices mainActivity.supportInvalidateOptionsMenu(); } - void editNote(final Note note, final View view) { if (note.isLocked() && !Prefs.getBoolean("settings_password_access", false)) { PasswordHelper.requestPassword(mainActivity, passwordConfirmed -> { @@ -1165,7 +1182,7 @@ public void onEvent(CategoriesUpdatedEvent categoriesUpdatedEvent) { public void onEvent(NotesLoadedEvent notesLoadedEvent) { - listAdapter = new NoteAdapter(mainActivity, Prefs.getBoolean(PREF_EXPANDED_VIEW, true), + listAdapter = new NoteAdapter(mainActivity, Prefs.getBoolean(PREF_EXPANDED_VIEW, true), Prefs.getBoolean(PREF_MINIMAL_VIEW, false), notesLoadedEvent.getNotes()); initSwipeGesture(); diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/models/adapters/NoteAdapter.java b/omniNotes/src/main/java/it/feio/android/omninotes/models/adapters/NoteAdapter.java index f34fcffe5..6aa13f4b4 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/models/adapters/NoteAdapter.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/models/adapters/NoteAdapter.java @@ -55,14 +55,16 @@ public class NoteAdapter extends RecyclerView.Adapter { private final List notes; private final SparseBooleanArray selectedItems = new SparseBooleanArray(); private final boolean expandedView; + private final boolean minimalView; private long closestNoteReminder = Long.parseLong(TIMESTAMP_UNIX_EPOCH_FAR); private int closestNotePosition; - public NoteAdapter(Activity activity, boolean expandedView, List notes) { + public NoteAdapter(Activity activity, boolean expandedView, boolean minimalView, List notes) { this.mActivity = activity; this.notes = notes; this.expandedView = expandedView; + this.minimalView = minimalView; navigation = Navigation.getNavigation(); manageCloserNote(notes, navigation); } @@ -127,7 +129,7 @@ private void initIcons(Note note, NoteViewHolder holder) { // ...the locked with password state holder.lockedIcon.setVisibility(note.isLocked() ? View.VISIBLE : View.GONE); // ...the attachment icon for contracted view - if (!expandedView) { + if (!expandedView && !minimalView) { holder.attachmentIcon .setVisibility(!note.getAttachmentsList().isEmpty() ? View.VISIBLE : View.GONE); } @@ -304,12 +306,17 @@ public NoteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType View view; if (expandedView) { view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.note_layout_expanded, parent, false); - } else { + .inflate(R.layout.note_layout_expanded, parent, false); + } + else if (minimalView){ + view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.note_layout_minimal, parent, false); + } + else { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.note_layout, parent, false); } - return new NoteViewHolder(view, expandedView); + return new NoteViewHolder(view, expandedView, minimalView); } @Override diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/models/holders/NoteViewHolder.java b/omniNotes/src/main/java/it/feio/android/omninotes/models/holders/NoteViewHolder.java index dacdb637a..8cbcbc247 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/models/holders/NoteViewHolder.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/models/holders/NoteViewHolder.java @@ -46,7 +46,7 @@ public class NoteViewHolder extends ViewHolder { @Nullable public SquareImageView attachmentThumbnail; - public NoteViewHolder(View view, boolean expandedView) { + public NoteViewHolder(View view, boolean expandedView, boolean minimalView) { super(view); if (expandedView) { @@ -64,7 +64,22 @@ public NoteViewHolder(View view, boolean expandedView) { attachmentThumbnail = binding.attachmentThumbnail; lockedIcon = binding.lockedIcon; lockedIcon = binding.lockedIcon; - } else { + } else if (minimalView){ + NoteLayoutExpandedBinding binding = NoteLayoutExpandedBinding.bind(view); + root = binding.root; + cardLayout = binding.cardLayout; + categoryMarker = binding.categoryMarker; + title = binding.noteTitle; + content = binding.noteContent; + date = binding.noteDate; + archiveIcon = binding.archivedIcon; + locationIcon = binding.locationIcon; + alarmIcon = binding.alarmIcon; + lockedIcon = binding.lockedIcon; + attachmentThumbnail = binding.attachmentThumbnail; + lockedIcon = binding.lockedIcon; + lockedIcon = binding.lockedIcon; + }else { NoteLayoutBinding binding = NoteLayoutBinding.bind(view); root = binding.root; cardLayout = binding.cardLayout; diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/utils/ConstantsBase.java b/omniNotes/src/main/java/it/feio/android/omninotes/utils/ConstantsBase.java index 235c74818..3041b7136 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/utils/ConstantsBase.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/utils/ConstantsBase.java @@ -86,6 +86,7 @@ public interface ConstantsBase { String PREF_KEEP_CHECKED = "keep_checked"; String PREF_KEEP_CHECKMARKS = "show_checkmarks"; String PREF_EXPANDED_VIEW = "expanded_view"; + String PREF_MINIMAL_VIEW = "minimal_view"; String PREF_COLORS_APP_DEFAULT = "strip"; String PREF_WIDGET_PREFIX = "widget_"; String PREF_SHOW_UNCATEGORIZED = "settings_show_uncategorized"; diff --git a/omniNotes/src/main/res/layout/note_layout_minimal.xml b/omniNotes/src/main/res/layout/note_layout_minimal.xml new file mode 100644 index 000000000..593c819cc --- /dev/null +++ b/omniNotes/src/main/res/layout/note_layout_minimal.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/omniNotes/src/main/res/menu/menu_list.xml b/omniNotes/src/main/res/menu/menu_list.xml index b3dfc9d17..b88b6d91a 100644 --- a/omniNotes/src/main/res/menu/menu_list.xml +++ b/omniNotes/src/main/res/menu/menu_list.xml @@ -156,6 +156,13 @@ app:showAsAction="never" android:title="@string/contracted_view" android:visible="false" /> + + 102dp 100dp 71dp + 42dp 16sp diff --git a/omniNotes/src/main/res/values/strings.xml b/omniNotes/src/main/res/values/strings.xml index 254270288..8de61b641 100644 --- a/omniNotes/src/main/res/values/strings.xml +++ b/omniNotes/src/main/res/values/strings.xml @@ -169,6 +169,7 @@ Proceed Reduced view Expanded view + Minimal view Grid view Add shortcut Shortcut added to home screen