This commit is contained in:
Philipp Heckel 2022-06-24 14:24:49 -04:00
parent 104d4222ba
commit e351884abe
2 changed files with 35 additions and 25 deletions

View file

@ -23,6 +23,7 @@ import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import androidx.core.view.allViews import androidx.core.view.allViews
import androidx.core.view.marginLeft
import androidx.core.widget.TextViewCompat import androidx.core.widget.TextViewCompat
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.ListAdapter
@ -210,16 +211,20 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
actionsWrapperView.addView(actionsFlow) actionsWrapperView.addView(actionsFlow)
} }
private fun addButtonToCard(button: MaterialButton) { private fun addButtonToCard(button: View) {
actionsWrapperView.addView(button) actionsWrapperView.addView(button)
actionsFlow.addView(button) actionsFlow.addView(button)
} }
private fun createCardButton(context: Context, label: String, onClick: () -> Boolean): MaterialButton { private fun createCardButton(context: Context, label: String, onClick: () -> Boolean): View {
val button = MaterialButton(context, null, R.attr.borderlessButtonStyle) val layoutParams = ConstraintLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
layoutParams.setMargins(0, 0, 0, 0)
val button = MaterialButton(context, null, R.attr.materialButtonOutlinedStyle)
button.id = View.generateViewId() button.id = View.generateViewId()
button.layoutParams = ConstraintLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) button.layoutParams = layoutParams
button.text = label button.text = label
button.setPadding(0, 0,0,0)
button.setOnClickListener { onClick() } button.setOnClickListener { onClick() }
return button return button
} }

View file

@ -25,7 +25,7 @@
android:orientation="horizontal" android:orientation="horizontal"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
android:focusable="true" android:focusable="true"
android:paddingBottom="6dp" android:paddingTop="6dp"> android:paddingBottom="7dp" android:paddingTop="7dp">
<TextView <TextView
android:text="Sun, October 31, 2021, 10:43:12" android:text="Sun, October 31, 2021, 10:43:12"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -34,7 +34,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="5dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="5dp" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="10dp"/> android:layout_marginStart="12dp"/>
<TextView <TextView
android:layout_width="10dp" android:layout_width="10dp"
android:layout_height="10dp" android:id="@+id/detail_item_new_dot" android:layout_height="10dp" android:id="@+id/detail_item_new_dot"
@ -51,7 +51,7 @@
android:layout_height="26dp" app:srcCompat="@drawable/ic_more_horiz_gray_24dp" android:layout_height="26dp" app:srcCompat="@drawable/ic_more_horiz_gray_24dp"
android:id="@+id/detail_item_menu_button" android:id="@+id/detail_item_menu_button"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="5dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="7dp"
android:background="?android:attr/selectableItemBackground" android:paddingTop="-5dp" android:background="?android:attr/selectableItemBackground" android:paddingTop="-5dp"
/> />
<TextView <TextView
@ -63,8 +63,8 @@
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:autoLink="web" android:autoLink="web"
app:layout_constraintTop_toBottomOf="@id/detail_item_title_text" app:layout_constraintTop_toBottomOf="@id/detail_item_title_text"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="10dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="12dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="12dp"
app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_image"/> app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_image"/>
<TextView <TextView
android:text="This is an optional title. It can also be a little longer but not too long." android:text="This is an optional title. It can also be a little longer but not too long."
@ -74,9 +74,9 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:autoLink="web" android:autoLink="web"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="12dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="10dp" android:textStyle="bold" android:layout_marginStart="12dp" android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/detail_item_date_text"/> app:layout_constraintTop_toBottomOf="@+id/detail_item_date_text"/>
<ImageView <ImageView
android:layout_width="16dp" android:layout_width="16dp"
@ -90,7 +90,7 @@
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_cancel_gray_24dp" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_cancel_gray_24dp"
android:id="@+id/detail_item_attachment_image" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_image" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/detail_item_message_text" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/detail_item_message_text"
android:layout_marginStart="10dp" android:layout_marginEnd="10dp" android:layout_marginStart="12dp" android:layout_marginEnd="12dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:adjustViewBounds="true" android:maxHeight="150dp" android:layout_marginTop="5dp" android:adjustViewBounds="true" android:maxHeight="150dp" android:layout_marginTop="5dp"
app:shapeAppearanceOverlay="@style/roundedCornersImageView" android:visibility="visible" app:shapeAppearanceOverlay="@style/roundedCornersImageView" android:visibility="visible"
@ -101,8 +101,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/detail_item_tags_text" android:id="@+id/detail_item_tags_text"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="10dp" app:layout_constraintStart_toStartOf="parent" android:layout_marginStart="12dp"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="12dp"
app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_image" app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_image"
app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_file_box" app:layout_constraintBottom_toTopOf="@id/detail_item_attachment_file_box"
app:layout_constraintHorizontal_bias="0.0" android:layout_marginTop="2dp" app:layout_constraintHorizontal_bias="0.0" android:layout_marginTop="2dp"
@ -111,7 +111,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_tags_text" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_tags_text"
android:id="@+id/detail_item_attachment_file_box" app:layout_constraintStart_toStartOf="parent" android:id="@+id/detail_item_attachment_file_box" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="12dp" android:layout_marginEnd="12dp"
app:layout_constraintBottom_toTopOf="@id/detail_item_padding_bottom" app:layout_constraintBottom_toTopOf="@id/detail_item_padding_bottom"
android:visibility="visible" android:layout_marginTop="2dp" android:visibility="visible" android:layout_marginTop="2dp"
android:background="?android:attr/selectableItemBackground" android:background="?android:attr/selectableItemBackground"
@ -146,18 +146,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/detail_item_padding_bottom" 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" 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_constraintEnd_toEndOf="parent" android:layout_marginEnd="12dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:visibility="visible" android:layout_marginTop="2dp" android:visibility="visible"
android:padding="0dp"> android:padding="0dp" android:layout_marginStart="12dp">
<com.google.android.material.button.MaterialButton <Button
android:text="Open Bing" android:text="Open Bing"
style="?attr/borderlessButtonStyle" style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content" 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"/> 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 <com.google.android.material.button.MaterialButton
android:text="Open Google" android:text="Show me Google"
style="?attr/borderlessButtonStyle" style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content" 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"/> 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"/>
@ -165,18 +165,23 @@
android:text="Open DuckDuckGo" android:text="Open DuckDuckGo"
style="?attr/borderlessButtonStyle" style="?attr/borderlessButtonStyle"
android:layout_width="wrap_content" 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"/> 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" android:padding="0dp" android:layout_margin="0dp"/>
<androidx.constraintlayout.helper.widget.Flow <androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:flow_wrapMode="chain2"
app:flow_horizontalStyle="packed"
android:id="@+id/detail_item_actions_flow" android:id="@+id/detail_item_actions_flow"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:flow_wrapMode="chain"
app:flow_horizontalStyle="packed"
app:flow_horizontalBias="0" app:flow_horizontalBias="0"
app:flow_verticalGap="0dp" app:flow_horizontalGap="0dp" app:flow_verticalBias="0"
app:flow_verticalGap="0dp"
app:flow_horizontalGap="0dp"
app:flow_verticalStyle="packed"
android:layout_margin="0dp"
android:padding="0dp"
app:constraint_referenced_ids="button1,button2,button3"/> app:constraint_referenced_ids="button1,button2,button3"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>