Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an option for a 'minimal view' in addition to the reduced view … #913

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteViewHolder> {
private final List<Note> 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<Note> notes) {
public NoteAdapter(Activity activity, boolean expandedView, boolean minimalView, List<Note> notes) {
this.mActivity = activity;
this.notes = notes;
this.expandedView = expandedView;
this.minimalView = minimalView;
navigation = Navigation.getNavigation();
manageCloserNote(notes, navigation);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
136 changes: 136 additions & 0 deletions omniNotes/src/main/res/layout/note_layout_minimal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2013-2023 Federico Iosue ([email protected])
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:pixlui="http://schemas.android.com/apk/com.neopixl.pixlui"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="@dimen/note_item_min_height_minimal"
android:background="@drawable/bg_card"
android:paddingBottom="2dp">

<LinearLayout
android:id="@+id/card_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="@dimen/note_item_min_height_minimal"
android:orientation="horizontal">

<View
android:id="@+id/category_marker"
android:layout_width="7dp"
android:layout_height="match_parent"
android:background="@null" />

<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="7dp"
android:paddingStart="6dp"
android:paddingEnd="16dp"
android:paddingTop="7dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<com.neopixl.pixlui.components.textview.TextView
android:id="@+id/note_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="top|start"
android:singleLine="true"
android:textAppearance="@style/Text.Big"
pixlui:typeface="RobotoSlab-Bold.ttf" />

<ImageView
android:id="@+id/alarmIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:src="@drawable/ic_alarm_black_48dp"
android:alpha="0.6"
android:visibility="gone" />

<ImageView
android:id="@+id/locationIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:src="@drawable/ic_pin_drop_black_18dp"
android:alpha="0.6"
android:visibility="gone" />

<ImageView
android:id="@+id/archivedIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:src="@drawable/ic_archive_black_18dp"
android:alpha="0.6"
android:visibility="gone" />

<ImageView
android:id="@+id/attachmentIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:src="@drawable/ic_attachment_black_18dp"
android:alpha="0.6"
android:visibility="gone" />

<ImageView
android:id="@+id/lockedIcon"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:src="@drawable/ic_lock_black_24dp"
android:alpha="0.6"
android:visibility="gone" />
</LinearLayout>

<com.neopixl.pixlui.components.textview.TextView
android:id="@+id/note_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:maxLines="@integer/textview_max_lines"
android:textAppearance="@style/Text.Normal"
android:visibility="gone"
pixlui:typeface="RobotoSlab-Regular.ttf" />

<com.neopixl.pixlui.components.textview.TextView
android:id="@+id/note_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:textAppearance="@style/Text.Small"
android:alpha="0.6"
pixlui:typeface="Roboto-Regular.ttf" />
</LinearLayout>
<it.feio.android.omninotes.models.views.SquareImageView
android:id="@+id/attachmentThumbnail"
android:layout_width="@dimen/note_item_min_height_inner"
android:layout_height="match_parent"
android:contentDescription="@string/note_thumbnail"
android:layout_gravity="center_vertical" />
</LinearLayout>

</FrameLayout>
7 changes: 7 additions & 0 deletions omniNotes/src/main/res/menu/menu_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@
app:showAsAction="never"
android:title="@string/contracted_view"
android:visible="false" />
<item
android:id="@+id/menu_minimal_view"
android:orderInCategory="800"
app:showAsAction="never"
android:title="@string/minimal_view"
android:visible="false" />

<item
android:id="@+id/menu_synchronize"
android:orderInCategory="850"
Expand Down
1 change: 1 addition & 0 deletions omniNotes/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<dimen name="note_item_min_height">102dp</dimen>
<dimen name="note_item_min_height_inner">100dp</dimen>
<dimen name="note_item_min_height_reduced">71dp</dimen>
<dimen name="note_item_min_height_minimal">42dp</dimen>

<!-- Attachment dialog -->
<dimen name="attachment_dialog_text_size">16sp</dimen>
Expand Down
1 change: 1 addition & 0 deletions omniNotes/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
<string name="proceed">Proceed</string>
<string name="contracted_view">Reduced view</string>
<string name="expanded_view">Expanded view</string>
<string name="minimal_view">Minimal view</string>
<string name="grid_view">Grid view</string>
<string name="add_shortcut">Add shortcut</string>
<string name="shortcut_added">Shortcut added to home screen</string>
Expand Down