This commit is contained in:
Philipp Heckel 2022-06-18 19:12:02 -04:00
parent c480c14055
commit d2535e0523
2 changed files with 37 additions and 19 deletions

View file

@ -10,6 +10,7 @@ import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.MediaStore
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@ -22,6 +23,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider
import androidx.core.view.allViews
import androidx.core.widget.TextViewCompat
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
@ -189,7 +191,7 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
private fun maybeRenderActions(context: Context, notification: Notification) {
if (notification.actions != null && notification.actions.isNotEmpty()) {
actionsWrapperView.visibility = View.VISIBLE
val actionsCount = min(notification.actions.size, 3) // per documentation, only 3 actions are available
val actionsCount = Math.min(notification.actions.size, 3) // per documentation, only 3 actions are available
for (i in 0 until actionsCount) {
val action = notification.actions[i]
val label = formatActionLabel(action)

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
style="@style/CardView"
xmlns:tools="http://schemas.android.com/tools" style="@style/CardView"
android:id="@+id/detail_item_card"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
@ -143,25 +143,41 @@
app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_padding_bottom"
android:id="@+id/detail_item_actions_wrapper" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="10dp" android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone" android:layout_marginTop="2dp"
android:padding="4dp">
android:layout_width="match_parent"
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_padding_bottom"
android:id="@+id/detail_item_actions_wrapper" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="8dp" android:layout_marginEnd="10dp"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="visible" android:layout_marginTop="2dp"
android:padding="0dp">
<com.google.android.material.button.MaterialButton
android:text="Open Bing"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button2" tools:layout_editor_absoluteY="4dp" tools:layout_editor_absoluteX="171dp" android:textSize="14sp" android:padding="0dp" android:layout_margin="0dp" tools:visibility="visible"/>
<com.google.android.material.button.MaterialButton
android:text="Open Google"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button3" tools:visibility="visible" tools:layout_editor_absoluteY="52dp" tools:layout_editor_absoluteX="4dp" android:textSize="14sp"/>
<com.google.android.material.button.MaterialButton
android:text="Open DuckDuckGo"
style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/button1" tools:visibility="visible" tools:layout_editor_absoluteY="4dp" tools:layout_editor_absoluteX="4dp" android:textSize="14sp"/>
<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:flow_wrapMode="chain"
app:flow_horizontalStyle="packed"
android:id="@+id/detail_item_actions_flow"
app:layout_constraintStart_toStartOf="parent"
app:flow_horizontalBias="0"
app:flow_verticalGap="0dp" app:flow_horizontalGap="0dp"/>
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:flow_wrapMode="chain2"
app:flow_horizontalStyle="packed"
android:id="@+id/detail_item_actions_flow"
app:layout_constraintStart_toStartOf="parent"
app:flow_horizontalBias="0"
app:flow_verticalGap="0dp" app:flow_horizontalGap="0dp"
app:constraint_referenced_ids="button1,button2,button3"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>