Revert "Remove message delete button."
This reverts commit b0e85623861e48abb1c6fb49800234f453fc82ee.
This commit is contained in:
committed by
Jannis Mattheis
parent
8d4a331bba
commit
f49900e0ef
@@ -5,6 +5,7 @@ import android.text.util.Linkify;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -14,6 +15,7 @@ import butterknife.ButterKnife;
|
|||||||
import com.github.gotify.R;
|
import com.github.gotify.R;
|
||||||
import com.github.gotify.Settings;
|
import com.github.gotify.Settings;
|
||||||
import com.github.gotify.Utils;
|
import com.github.gotify.Utils;
|
||||||
|
import com.github.gotify.client.model.Message;
|
||||||
import com.github.gotify.messages.provider.MessageWithImage;
|
import com.github.gotify.messages.provider.MessageWithImage;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
import io.noties.markwon.Markwon;
|
import io.noties.markwon.Markwon;
|
||||||
@@ -28,16 +30,22 @@ public class ListMessageAdapter extends RecyclerView.Adapter<ListMessageAdapter.
|
|||||||
private Context content;
|
private Context content;
|
||||||
private Picasso picasso;
|
private Picasso picasso;
|
||||||
private List<MessageWithImage> items;
|
private List<MessageWithImage> items;
|
||||||
|
private Delete delete;
|
||||||
private Settings settings;
|
private Settings settings;
|
||||||
private Markwon markwon;
|
private Markwon markwon;
|
||||||
|
|
||||||
ListMessageAdapter(
|
ListMessageAdapter(
|
||||||
Context context, Settings settings, Picasso picasso, List<MessageWithImage> items) {
|
Context context,
|
||||||
|
Settings settings,
|
||||||
|
Picasso picasso,
|
||||||
|
List<MessageWithImage> items,
|
||||||
|
Delete delete) {
|
||||||
super();
|
super();
|
||||||
this.content = context;
|
this.content = context;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.picasso = picasso;
|
this.picasso = picasso;
|
||||||
this.items = items;
|
this.items = items;
|
||||||
|
this.delete = delete;
|
||||||
|
|
||||||
this.markwon =
|
this.markwon =
|
||||||
Markwon.builder(context)
|
Markwon.builder(context)
|
||||||
@@ -84,6 +92,7 @@ public class ListMessageAdapter extends RecyclerView.Adapter<ListMessageAdapter.
|
|||||||
message.message.getDate() != null
|
message.message.getDate() != null
|
||||||
? Utils.dateToRelative(message.message.getDate())
|
? Utils.dateToRelative(message.message.getDate())
|
||||||
: "?");
|
: "?");
|
||||||
|
holder.delete.setOnClickListener((ignored) -> delete.delete(message.message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,9 +119,16 @@ public class ListMessageAdapter extends RecyclerView.Adapter<ListMessageAdapter.
|
|||||||
@BindView(R.id.message_date)
|
@BindView(R.id.message_date)
|
||||||
TextView date;
|
TextView date;
|
||||||
|
|
||||||
|
@BindView(R.id.message_delete)
|
||||||
|
ImageButton delete;
|
||||||
|
|
||||||
ViewHolder(final View view) {
|
ViewHolder(final View view) {
|
||||||
super(view);
|
super(view);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface Delete {
|
||||||
|
void delete(Message message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,8 @@ public class MessagesActivity extends AppCompatActivity
|
|||||||
DividerItemDecoration dividerItemDecoration =
|
DividerItemDecoration dividerItemDecoration =
|
||||||
new DividerItemDecoration(
|
new DividerItemDecoration(
|
||||||
messagesView.getContext(), layoutManager.getOrientation());
|
messagesView.getContext(), layoutManager.getOrientation());
|
||||||
ListMessageAdapter adapter = new ListMessageAdapter(this, settings, picasso, emptyList());
|
ListMessageAdapter adapter =
|
||||||
|
new ListMessageAdapter(this, settings, picasso, emptyList(), this::delete);
|
||||||
|
|
||||||
messagesView.addItemDecoration(dividerItemDecoration);
|
messagesView.addItemDecoration(dividerItemDecoration);
|
||||||
messagesView.setHasFixedSize(true);
|
messagesView.setHasFixedSize(true);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:text=""
|
android:text=""
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/message_delete"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -52,4 +52,15 @@
|
|||||||
app:layout_constraintStart_toEndOf="@+id/message_image"
|
app:layout_constraintStart_toEndOf="@+id/message_image"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/message_title" />
|
app:layout_constraintTop_toBottomOf="@+id/message_title" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/message_delete"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:contentDescription="@string/delete_message"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/message_date"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_delete" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user