mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Use long click to open menu, clean up some cruft.
This commit is contained in:
@@ -4,7 +4,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -13,21 +12,15 @@ import org.briarproject.briar.android.util.UiUtils;
|
||||
import org.briarproject.briar.android.view.TextAvatarView;
|
||||
import org.briarproject.briar.api.forum.Forum;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static java.util.logging.Logger.getLogger;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.briar.android.activity.BriarActivity.GROUP_NAME;
|
||||
|
||||
class ForumViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private static final Logger LOG =
|
||||
getLogger(ForumViewHolder.class.getName());
|
||||
|
||||
private final ForumListViewModel viewModel;
|
||||
private final Context ctx;
|
||||
private final ViewGroup layout;
|
||||
@@ -35,7 +28,6 @@ class ForumViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView name;
|
||||
private final TextView postCount;
|
||||
private final TextView date;
|
||||
private final ImageButton menuButton;
|
||||
|
||||
ForumViewHolder(View v, ForumListViewModel viewModel) {
|
||||
super(v);
|
||||
@@ -46,7 +38,6 @@ class ForumViewHolder extends RecyclerView.ViewHolder {
|
||||
name = v.findViewById(R.id.forumNameView);
|
||||
postCount = v.findViewById(R.id.postCountView);
|
||||
date = v.findViewById(R.id.dateView);
|
||||
menuButton = v.findViewById(R.id.menuButton);
|
||||
}
|
||||
|
||||
void bind(ForumListItem item) {
|
||||
@@ -76,20 +67,19 @@ class ForumViewHolder extends RecyclerView.ViewHolder {
|
||||
date.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
// Open popup menu
|
||||
menuButton.setOnClickListener(v -> {
|
||||
LOG.info("Menu click");
|
||||
PopupMenu pm = new PopupMenu(ctx, menuButton);
|
||||
// Open popup menu on long click
|
||||
layout.setOnLongClickListener(v -> {
|
||||
PopupMenu pm = new PopupMenu(ctx, v);
|
||||
pm.getMenuInflater().inflate(R.menu.forum_list_item_actions,
|
||||
pm.getMenu());
|
||||
pm.setOnMenuItemClickListener(it -> {
|
||||
LOG.info("Menu item click");
|
||||
if (it.getItemId() == R.id.action_forum_delete) {
|
||||
viewModel.deleteForum(item.getForum().getId());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
pm.show();
|
||||
return true;
|
||||
});
|
||||
|
||||
// Open Forum on Click
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:layout_marginRight="@dimen/listitem_horizontal_margin"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
app:layout_constraintEnd_toStartOf="@id/menuButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/avatarView"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="This is a name of a forum which can be long" />
|
||||
@@ -44,19 +44,6 @@
|
||||
app:layout_constraintTop_toBottomOf="@+id/forumNameView"
|
||||
tools:text="@string/no_forum_posts" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/menuButton"
|
||||
style="@style/Widget.AppCompat.ActionButton.Overflow"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_margin="@dimen/listitem_horizontal_margin"
|
||||
android:contentDescription="@string/menu"
|
||||
app:icon="@drawable/ic_more_vert_accent"
|
||||
app:layout_constraintBottom_toTopOf="@id/dateView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/forumNameView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dateView"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -66,7 +53,6 @@
|
||||
android:textSize="@dimen/text_size_small"
|
||||
app:layout_constraintBaseline_toBaselineOf="@+id/postCountView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/menuButton"
|
||||
tools:text="Dec 24" />
|
||||
|
||||
<View
|
||||
|
||||
@@ -936,6 +936,5 @@
|
||||
<string name="screenshot_message_2">Hi Alice! Thanks for telling me about Briar!</string>
|
||||
<!-- This is a message to be used in screenshots. -->
|
||||
<string name="screenshot_message_3">No problem, hope you like it 😀</string>
|
||||
<string name="menu">Menu</string>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user