Skip to content

Commit f20e347

Browse files
AlvaroBreyAndyScherzinger
authored andcommitted
wip: Copy note actions to overflow menu on each note action
Signed-off-by: Álvaro Brey <[email protected]>
1 parent 6f091bb commit f20e347

15 files changed

+89
-11
lines changed

app/src/main/java/it/niedermann/owncloud/notes/AppendToNoteActivity.java

+6
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,10 @@ public void onNoteClick(int position, View v) {
6565
}
6666
finish();
6767
}
68+
69+
@Override
70+
public void onNoteActionsClick(int position, View v) {
71+
// TODO
72+
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
73+
}
6874
}

app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.text.TextUtils;
2828
import android.util.Log;
2929
import android.view.View;
30+
import android.widget.Toast;
3031

3132
import androidx.annotation.ColorInt;
3233
import androidx.annotation.NonNull;
@@ -769,6 +770,12 @@ public void onNoteFavoriteClick(int position, View view) {
769770
toggleLiveData.observe(this, (next) -> toggleLiveData.removeObservers(this));
770771
}
771772

773+
@Override
774+
public void onNoteActionsClick(int position, View v) {
775+
// TODO
776+
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
777+
}
778+
772779
@Override
773780
public void onBackPressed() {
774781
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {

app/src/main/java/it/niedermann/owncloud/notes/main/items/NoteViewHolder.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import androidx.recyclerview.selection.ItemDetailsLookup;
2525
import androidx.recyclerview.widget.RecyclerView;
2626

27+
import com.google.android.material.button.MaterialButton;
2728
import com.google.android.material.chip.Chip;
2829
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
2930

@@ -95,6 +96,13 @@ protected void bindSearchableContent(@NonNull Context context, @NonNull TextView
9596
}
9697
}
9798

99+
protected void bindActions(@NonNull MaterialButton actionsButton, int color) {
100+
final BrandingUtil util = BrandingUtil.of(color, actionsButton.getContext());
101+
util.material.colorMaterialButtonText(actionsButton);
102+
util.material.colorMaterialTextButton(actionsButton);
103+
actionsButton.setOnClickListener(view -> noteClickListener.onNoteActionsClick(getLayoutPosition(), view));
104+
}
105+
98106
public abstract void showSwipe(boolean left);
99107

100108
@Nullable
@@ -113,4 +121,4 @@ public Long getSelectionKey() {
113121
}
114122
};
115123
}
116-
}
124+
}

app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolder.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
5555
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
5656
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), color);
5757
binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);
58+
bindActions(binding.noteActions, color);
5859
}
5960

6061
@Nullable
6162
public View getNoteSwipeable() {
6263
return null;
6364
}
64-
}
65+
}

app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolderOnlyTitle.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
4444
bindStatus(binding.noteStatus, note.getStatus(), color);
4545
bindFavorite(binding.noteFavorite, note.getFavorite());
4646
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
47+
bindActions(binding.noteActions, color);
4748
}
4849

4950
@Nullable
5051
public View getNoteSwipeable() {
5152
return null;
5253
}
53-
}
54+
}

app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithExcerpt.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
4444

4545
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
4646
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt(), color);
47+
bindActions(binding.noteActions, color);
4748
}
4849

4950
@NonNull
5051
public View getNoteSwipeable() {
5152
return binding.noteSwipeable;
5253
}
53-
}
54+
}

app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithoutExcerpt.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
4242
bindStatus(binding.noteStatus, note.getStatus(), color);
4343
bindFavorite(binding.noteFavorite, note.getFavorite());
4444
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
45+
bindActions(binding.noteActions, color);
4546
}
4647

4748
@NonNull
4849
public View getNoteSwipeable() {
4950
return binding.noteSwipeable;
5051
}
51-
}
52+
}

app/src/main/java/it/niedermann/owncloud/notes/shared/model/NoteClickListener.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ public interface NoteClickListener {
1212
void onNoteClick(int position, View v);
1313

1414
void onNoteFavoriteClick(int position, View v);
15-
}
15+
16+
void onNoteActionsClick(int position, View v);
17+
}

app/src/main/java/it/niedermann/owncloud/notes/widget/singlenote/SingleNoteWidgetConfigurationActivity.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
import android.view.View;
1616
import android.widget.Toast;
1717

18-
import androidx.appcompat.widget.Toolbar;
19-
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
20-
2118
import it.niedermann.owncloud.notes.NotesApplication;
2219
import it.niedermann.owncloud.notes.R;
2320
import it.niedermann.owncloud.notes.exception.ExceptionHandler;
@@ -79,4 +76,10 @@ public void onNoteClick(int position, View v) {
7976
}
8077
});
8178
}
79+
80+
@Override
81+
public void onNoteActionsClick(int position, View v) {
82+
// TODO
83+
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
84+
}
8285
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- drawable/dots_vertical.xml --><vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:width="24dp" android:viewportWidth="24" android:viewportHeight="24"><path android:fillColor="#000000" android:pathData="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z" /></vector>

app/src/main/res/layout/item_notes_list_note_item_grid.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,16 @@
108108
tools:text="@tools:sample/lorem/random" />
109109
</FrameLayout>
110110
</LinearLayout>
111+
112+
<com.google.android.material.button.MaterialButton
113+
android:id="@+id/noteActions"
114+
style="@style/Widget.Material3.Button.IconButton"
115+
android:layout_width="wrap_content"
116+
android:layout_height="wrap_content"
117+
android:layout_gravity="bottom|end"
118+
android:contentDescription="@string/note_actions"
119+
app:icon="@drawable/ic_dots_vertical"
120+
app:iconTint="?android:textColorPrimary"
121+
app:rippleColor="@color/fg_secondary" />
111122
</LinearLayout>
112-
</com.google.android.material.card.MaterialCardView>
123+
</com.google.android.material.card.MaterialCardView>

app/src/main/res/layout/item_notes_list_note_item_grid_only_title.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,16 @@
6262
android:textColor="@color/fg_default"
6363
tools:maxLength="50"
6464
tools:text="@tools:sample/lorem/random" />
65+
66+
<com.google.android.material.button.MaterialButton
67+
android:id="@+id/noteActions"
68+
style="@style/Widget.Material3.Button.IconButton"
69+
android:layout_width="wrap_content"
70+
android:layout_height="wrap_content"
71+
android:layout_gravity="bottom|end"
72+
android:contentDescription="@string/note_actions"
73+
app:icon="@drawable/ic_dots_vertical"
74+
app:iconTint="?android:textColorPrimary"
75+
app:rippleColor="@color/fg_secondary" />
6576
</LinearLayout>
66-
</com.google.android.material.card.MaterialCardView>
77+
</com.google.android.material.card.MaterialCardView>

app/src/main/res/layout/item_notes_list_note_item_with_excerpt.xml

+12
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@
122122
tools:text="@tools:sample/lorem/random" />
123123
</LinearLayout>
124124
</LinearLayout>
125+
126+
<com.google.android.material.button.MaterialButton
127+
android:id="@+id/noteActions"
128+
style="@style/Widget.Material3.Button.IconButton"
129+
android:layout_width="wrap_content"
130+
android:layout_height="wrap_content"
131+
android:layout_gravity="center_vertical"
132+
android:contentDescription="@string/note_actions"
133+
app:icon="@drawable/ic_dots_vertical"
134+
app:iconTint="?android:textColorPrimary"
135+
app:rippleColor="@color/fg_secondary" />
136+
125137
</LinearLayout>
126138

127139
</FrameLayout>

app/src/main/res/layout/item_notes_list_note_item_without_excerpt.xml

+12
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@
9494
android:textSize="@dimen/secondary_font_size"
9595
tools:maxLength="15"
9696
tools:text="@tools:sample/lorem/random" />
97+
98+
<com.google.android.material.button.MaterialButton
99+
android:id="@+id/noteActions"
100+
style="@style/Widget.Material3.Button.IconButton"
101+
android:layout_width="wrap_content"
102+
android:layout_height="wrap_content"
103+
android:layout_gravity="center_vertical"
104+
android:contentDescription="@string/note_actions"
105+
app:icon="@drawable/ic_dots_vertical"
106+
app:iconTint="?android:textColorPrimary"
107+
app:rippleColor="@color/fg_secondary" />
108+
97109
</LinearLayout>
98110

99111
</FrameLayout>

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,5 @@
378378
<string name="switch_to_plain_editing">Switch to plain editing</string>
379379
<string name="action_back">Back</string>
380380
<string name="user_agent" translatable="false">Mozilla/5.0 (Android) %1$s-android/%2$s</string>
381+
<string name="note_actions">Note actions</string>
381382
</resources>

0 commit comments

Comments
 (0)