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

feat: Show each post's scheduled time in the list of scheduled posts #1033

Merged
merged 3 commits into from
Oct 20, 2024
Merged
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 @@ -23,6 +23,7 @@ import androidx.recyclerview.widget.DiffUtil
import app.pachli.core.network.model.ScheduledStatus
import app.pachli.core.ui.BindingHolder
import app.pachli.databinding.ItemScheduledStatusBinding
import java.text.DateFormat

interface ScheduledStatusActionListener {
fun edit(item: ScheduledStatus)
Expand Down Expand Up @@ -50,15 +51,18 @@ class ScheduledStatusAdapter(

override fun onBindViewHolder(holder: BindingHolder<ItemScheduledStatusBinding>, position: Int) {
getItem(position)?.let { item ->
holder.binding.timestamp.text = dateFormat.format(item.scheduledAt)
holder.binding.edit.isEnabled = true
holder.binding.delete.isEnabled = true
holder.binding.text.text = item.params.text
holder.binding.edit.setOnClickListener {
listener.edit(item)
}
holder.binding.delete.setOnClickListener {
listener.delete(item)
}
holder.binding.edit.setOnClickListener { listener.edit(item) }
holder.binding.delete.setOnClickListener { listener.delete(item) }
holder.binding.root.setOnClickListener { listener.edit(item) }
}
}

companion object {
private val dateFormat =
DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.SHORT)
}
}
59 changes: 43 additions & 16 deletions app/src/main/res/layout/item_scheduled_status.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_marginTop="16dp"
android:minHeight="?listPreferredItemHeight"
android:paddingStart="?listPreferredItemPaddingStart"
android:paddingEnd="?listPreferredItemPaddingEnd">

<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.91"
android:padding="8dp"
android:textSize="?attr/status_text_medium" />
android:textSize="?attr/status_text_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:autoText="false"
tools:text="@tools:sample/lorem[10]"
tools:ignore="SelectableText" />

<TextView
android:id="@+id/timestamp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="?attr/status_text_medium"
app:drawableStartCompat="@drawable/ic_access_time"
app:drawableTint="?colorPrimary"
app:layout_constraintBottom_toBottomOf="@+id/edit"
app:layout_constraintEnd_toStartOf="@id/edit"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/edit"
tools:text="2024-10-20 18:00:00" />

<ImageButton
android:id="@+id/edit"
style="@style/AppImageButton"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_margin="12dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="8dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_edit"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/delete"
app:layout_constraintStart_toEndOf="@id/timestamp"
app:layout_constraintTop_toBottomOf="@+id/text"
app:srcCompat="@drawable/ic_create_24dp" />

<ImageButton
android:id="@+id/delete"
style="@style/AppImageButton"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_gravity="center_vertical"
android:layout_margin="12dp"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_delete"
android:padding="4dp"
app:layout_constraintBottom_toBottomOf="@+id/edit"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/ic_clear_24dp" />

</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>