Skip to content

Commit

Permalink
wip: Copy note actions to overflow menu on each note action
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Brey <[email protected]>
  • Loading branch information
AlvaroBrey authored and AndyScherzinger committed Mar 7, 2024
1 parent bea3f96 commit a5cf7ac
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ public void onNoteClick(int position, View v) {
}
finish();
}

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

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

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}

@Override
public void onBackPressed() {
if (activityBinding.searchToolbar.getVisibility() == VISIBLE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import androidx.recyclerview.selection.ItemDetailsLookup;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.button.MaterialButton;
import com.google.android.material.chip.Chip;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;

Expand Down Expand Up @@ -95,6 +96,13 @@ protected void bindSearchableContent(@NonNull Context context, @NonNull TextView
}
}

protected void bindActions(@NonNull MaterialButton actionsButton, int color) {
final BrandingUtil util = BrandingUtil.of(color, actionsButton.getContext());
util.material.colorMaterialButtonText(actionsButton);
util.material.colorMaterialTextButton(actionsButton);
actionsButton.setOnClickListener(view -> noteClickListener.onNoteActionsClick(getLayoutPosition(), view));
}

public abstract void showSwipe(boolean left);

@Nullable
Expand All @@ -113,4 +121,4 @@ public Long getSelectionKey() {
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), color);
binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);
bindActions(binding.noteActions, color);
}

@Nullable
public View getNoteSwipeable() {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindActions(binding.noteActions, color);
}

@Nullable
public View getNoteSwipeable() {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @

bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt(), color);
bindActions(binding.noteActions, color);
}

@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
bindActions(binding.noteActions, color);
}

@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface NoteClickListener {
void onNoteClick(int position, View v);

void onNoteFavoriteClick(int position, View v);
}

void onNoteActionsClick(int position, View v);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.widget.Toolbar;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.exception.ExceptionHandler;
Expand Down Expand Up @@ -79,4 +76,10 @@ public void onNoteClick(int position, View v) {
}
});
}

@Override
public void onNoteActionsClick(int position, View v) {
// TODO
Toast.makeText(v.getContext(), "Not implemented yet", Toast.LENGTH_SHORT).show();
}
}
1 change: 1 addition & 0 deletions app/src/main/res/drawable/ic_dots_vertical.xml
Original file line number Diff line number Diff line change
@@ -0,0 +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>
13 changes: 12 additions & 1 deletion app/src/main/res/layout/item_notes_list_note_item_grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,16 @@
tools:text="@tools:sample/lorem/random" />
</FrameLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,16 @@
android:textColor="@color/fg_default"
tools:maxLength="50"
tools:text="@tools:sample/lorem/random" />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/item_notes_list_note_item_with_excerpt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
tools:text="@tools:sample/lorem/random" />
</LinearLayout>
</LinearLayout>

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />

</LinearLayout>

</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,18 @@
android:textSize="@dimen/secondary_font_size"
tools:maxLength="15"
tools:text="@tools:sample/lorem/random" />

<com.google.android.material.button.MaterialButton
android:id="@+id/noteActions"
style="@style/Widget.Material3.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:contentDescription="@string/note_actions"
app:icon="@drawable/ic_dots_vertical"
app:iconTint="?android:textColorPrimary"
app:rippleColor="@color/fg_secondary" />

</LinearLayout>

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,5 @@
<string name="switch_to_plain_editing">Switch to plain editing</string>
<string name="action_back">Back</string>
<string name="user_agent" translatable="false">Mozilla/5.0 (Android) %1$s-android/%2$s</string>
<string name="note_actions">Note actions</string>
</resources>

0 comments on commit a5cf7ac

Please sign in to comment.