Make action buttons look good
This commit is contained in:
parent
c5910d405c
commit
78ff855f32
3 changed files with 57 additions and 37 deletions
|
@ -5,12 +5,10 @@ import android.app.Activity
|
|||
import android.content.*
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
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
|
||||
|
@ -23,8 +21,6 @@ import androidx.core.app.ActivityCompat
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.core.view.allViews
|
||||
import androidx.core.view.marginLeft
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -38,7 +34,6 @@ import io.heckel.ntfy.msg.NotificationService
|
|||
import io.heckel.ntfy.msg.NotificationService.Companion.ACTION_VIEW
|
||||
import io.heckel.ntfy.util.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.lang.Integer.min
|
||||
|
||||
|
||||
class DetailAdapter(private val activity: Activity, private val lifecycleScope: CoroutineScope, private val repository: Repository, private val onClick: (Notification) -> Unit, private val onLongClick: (Notification) -> Unit) :
|
||||
|
@ -217,14 +212,10 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
|
|||
}
|
||||
|
||||
private fun createCardButton(context: Context, label: String, onClick: () -> Boolean): View {
|
||||
val layoutParams = ConstraintLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT)
|
||||
layoutParams.setMargins(0, 0, 0, 0)
|
||||
|
||||
val button = MaterialButton(context, null, R.attr.materialButtonOutlinedStyle)
|
||||
// See https://stackoverflow.com/a/41139179/1440785
|
||||
val button = LayoutInflater.from(context).inflate(R.layout.button_action, null) as MaterialButton
|
||||
button.id = View.generateViewId()
|
||||
button.layoutParams = layoutParams
|
||||
button.text = label
|
||||
button.setPadding(0, 0,0,0)
|
||||
button.setOnClickListener { onClick() }
|
||||
return button
|
||||
}
|
||||
|
|
21
app/src/main/res/layout/button_action.xml
Normal file
21
app/src/main/res/layout/button_action.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="?attr/borderlessButtonStyle"
|
||||
android:id="@+id/button"
|
||||
android:text="Button"
|
||||
android:layout_margin="0dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="0dp"
|
||||
android:minHeight="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetLeft="0dp"
|
||||
android:insetRight="0dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:textSize="14sp"
|
||||
/>
|
|
@ -25,7 +25,7 @@
|
|||
android:orientation="horizontal"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:focusable="true"
|
||||
android:paddingBottom="7dp" android:paddingTop="7dp">
|
||||
android:paddingBottom="6dp" android:paddingTop="6dp">
|
||||
<TextView
|
||||
android:text="Sun, October 31, 2021, 10:43:12"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -112,7 +112,6 @@
|
|||
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"
|
||||
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="12dp" android:layout_marginEnd="12dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/detail_item_padding_bottom"
|
||||
android:visibility="visible" android:layout_marginTop="2dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true" android:focusable="true" android:padding="4dp" android:paddingStart="0dp">
|
||||
|
@ -136,54 +135,63 @@
|
|||
app:layout_constraintTop_toTopOf="@+id/detail_item_attachment_file_icon"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/detail_item_attachment_file_icon"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp" android:id="@+id/detail_item_padding_bottom"
|
||||
app:layout_constraintBottom_toTopOf="@+id/detail_item_actions_wrapper" app:layout_constraintStart_toStartOf="parent"
|
||||
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_marginEnd="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"
|
||||
android:id="@+id/detail_item_actions_wrapper"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:visibility="gone"
|
||||
android:padding="0dp" android:layout_marginStart="12dp">
|
||||
android:padding="0dp" android:layout_marginStart="4dp" android:layout_marginTop="4dp">
|
||||
|
||||
<Button
|
||||
android:text="Open Bing"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||
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="Show me Google"
|
||||
android:text="Bing it"
|
||||
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" tools:visibility="visible"/>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:text="Google it"
|
||||
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"
|
||||
android:text="DuckDuckGo it"
|
||||
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" android:padding="0dp" android:layout_margin="0dp"/>
|
||||
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_margin="0dp"/>
|
||||
<androidx.constraintlayout.helper.widget.Flow
|
||||
android:id="@+id/detail_item_actions_flow"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:id="@+id/detail_item_actions_flow"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:flow_wrapMode="chain"
|
||||
app:flow_wrapMode="chain2"
|
||||
app:flow_horizontalStyle="packed"
|
||||
app:flow_horizontalBias="0"
|
||||
app:flow_verticalBias="0"
|
||||
app:flow_verticalGap="0dp"
|
||||
app:flow_horizontalGap="0dp"
|
||||
app:flow_verticalStyle="packed"
|
||||
app:flow_verticalAlign="top"
|
||||
app:flow_horizontalBias="0"
|
||||
app:flow_horizontalGap="0dp"
|
||||
app:flow_horizontalAlign="start"
|
||||
app:flow_firstHorizontalBias="0"
|
||||
app:flow_firstVerticalBias="0"
|
||||
app:flow_firstHorizontalStyle="packed"
|
||||
app:flow_firstVerticalStyle="packed"
|
||||
app:flow_maxElementsWrap="1"
|
||||
android:layout_margin="0dp"
|
||||
android:padding="0dp"
|
||||
app:constraint_referenced_ids="button1,button2,button3"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:id="@+id/detail_item_padding_bottom"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/detail_item_actions_wrapper" app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
|
Loading…
Reference in a new issue