WIP Cards
This commit is contained in:
parent
835ace34cd
commit
0d790a447f
8 changed files with 268 additions and 211 deletions
|
@ -1,6 +1,7 @@
|
||||||
package io.heckel.ntfy.ui
|
package io.heckel.ntfy.ui
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import io.heckel.ntfy.R
|
import io.heckel.ntfy.R
|
||||||
import io.heckel.ntfy.util.isDarkThemeOn
|
import io.heckel.ntfy.util.isDarkThemeOn
|
||||||
|
|
||||||
|
@ -13,6 +14,10 @@ class Colors {
|
||||||
return if (isDarkThemeOn(context)) R.color.gray_dark else R.color.gray_light
|
return if (isDarkThemeOn(context)) R.color.gray_dark else R.color.gray_light
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun itemSelectedBackgroundColor(context: Context): Int {
|
||||||
|
return ContextCompat.getColor(context, itemSelectedBackground(context))
|
||||||
|
}
|
||||||
|
|
||||||
fun statusBarNormal(context: Context): Int {
|
fun statusBarNormal(context: Context): Int {
|
||||||
return if (isDarkThemeOn(context)) R.color.black_light else R.color.teal
|
return if (isDarkThemeOn(context)) R.color.black_light else R.color.teal
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.core.app.ActivityCompat
|
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
|
||||||
|
@ -64,6 +65,7 @@ class DetailAdapter(private val activity: Activity, private val repository: Repo
|
||||||
class DetailViewHolder(private val activity: Activity, private val repository: Repository, itemView: View, private val selected: Set<String>, val onClick: (Notification) -> Unit, val onLongClick: (Notification) -> Unit) :
|
class DetailViewHolder(private val activity: Activity, private val repository: Repository, itemView: View, private val selected: Set<String>, val onClick: (Notification) -> Unit, val onLongClick: (Notification) -> Unit) :
|
||||||
RecyclerView.ViewHolder(itemView) {
|
RecyclerView.ViewHolder(itemView) {
|
||||||
private var notification: Notification? = null
|
private var notification: Notification? = null
|
||||||
|
private val cardView: CardView = itemView.findViewById(R.id.detail_item_card)
|
||||||
private val priorityImageView: ImageView = itemView.findViewById(R.id.detail_item_priority_image)
|
private val priorityImageView: ImageView = itemView.findViewById(R.id.detail_item_priority_image)
|
||||||
private val dateView: TextView = itemView.findViewById(R.id.detail_item_date_text)
|
private val dateView: TextView = itemView.findViewById(R.id.detail_item_date_text)
|
||||||
private val titleView: TextView = itemView.findViewById(R.id.detail_item_title_text)
|
private val titleView: TextView = itemView.findViewById(R.id.detail_item_title_text)
|
||||||
|
@ -85,8 +87,8 @@ class DetailAdapter(private val activity: Activity, private val repository: Repo
|
||||||
dateView.text = formatDateShort(notification.timestamp)
|
dateView.text = formatDateShort(notification.timestamp)
|
||||||
messageView.text = maybeAppendActionErrors(formatMessage(notification), notification)
|
messageView.text = maybeAppendActionErrors(formatMessage(notification), notification)
|
||||||
newDotImageView.visibility = if (notification.notificationId == 0) View.GONE else View.VISIBLE
|
newDotImageView.visibility = if (notification.notificationId == 0) View.GONE else View.VISIBLE
|
||||||
itemView.setOnClickListener { onClick(notification) }
|
cardView.setOnClickListener { onClick(notification) }
|
||||||
itemView.setOnLongClickListener { onLongClick(notification); true }
|
cardView.setOnLongClickListener { onLongClick(notification); true }
|
||||||
if (notification.title != "") {
|
if (notification.title != "") {
|
||||||
titleView.visibility = View.VISIBLE
|
titleView.visibility = View.VISIBLE
|
||||||
titleView.text = formatTitle(notification)
|
titleView.text = formatTitle(notification)
|
||||||
|
@ -100,7 +102,7 @@ class DetailAdapter(private val activity: Activity, private val repository: Repo
|
||||||
tagsView.visibility = View.GONE
|
tagsView.visibility = View.GONE
|
||||||
}
|
}
|
||||||
if (selected.contains(notification.id)) {
|
if (selected.contains(notification.id)) {
|
||||||
itemView.setBackgroundResource(Colors.itemSelectedBackground(context))
|
cardView.setCardBackgroundColor(Colors.itemSelectedBackgroundColor(context))
|
||||||
}
|
}
|
||||||
val attachment = notification.attachment
|
val attachment = notification.attachment
|
||||||
val exists = if (attachment?.contentUri != null) fileExists(context, attachment.contentUri) else false
|
val exists = if (attachment?.contentUri != null) fileExists(context, attachment.contentUri) else false
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -47,6 +48,7 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
||||||
RecyclerView.ViewHolder(itemView) {
|
RecyclerView.ViewHolder(itemView) {
|
||||||
private var subscription: Subscription? = null
|
private var subscription: Subscription? = null
|
||||||
private val context: Context = itemView.context
|
private val context: Context = itemView.context
|
||||||
|
private val cardView: CardView = itemView.findViewById(R.id.main_item_card)
|
||||||
private val nameView: TextView = itemView.findViewById(R.id.main_item_text)
|
private val nameView: TextView = itemView.findViewById(R.id.main_item_text)
|
||||||
private val statusView: TextView = itemView.findViewById(R.id.main_item_status)
|
private val statusView: TextView = itemView.findViewById(R.id.main_item_status)
|
||||||
private val dateView: TextView = itemView.findViewById(R.id.main_item_date)
|
private val dateView: TextView = itemView.findViewById(R.id.main_item_date)
|
||||||
|
@ -97,10 +99,10 @@ class MainAdapter(private val repository: Repository, private val onClick: (Subs
|
||||||
newItemsView.visibility = View.VISIBLE
|
newItemsView.visibility = View.VISIBLE
|
||||||
newItemsView.text = if (subscription.newCount <= 99) subscription.newCount.toString() else "99+"
|
newItemsView.text = if (subscription.newCount <= 99) subscription.newCount.toString() else "99+"
|
||||||
}
|
}
|
||||||
itemView.setOnClickListener { onClick(subscription) }
|
cardView.setOnClickListener { onClick(subscription) }
|
||||||
itemView.setOnLongClickListener { onLongClick(subscription); true }
|
cardView.setOnLongClickListener { onLongClick(subscription); true }
|
||||||
if (selected.contains(subscription.id)) {
|
if (selected.contains(subscription.id)) {
|
||||||
itemView.setBackgroundResource(Colors.itemSelectedBackground(context))
|
cardView.setCardBackgroundColor(Colors.itemSelectedBackgroundColor(context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,12 @@
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.DetailActivity">
|
tools:context=".ui.DetailActivity"
|
||||||
|
>
|
||||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
android:id="@+id/detail_notification_list_container"
|
android:id="@+id/detail_notification_list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/detail_notification_list"
|
android:id="@+id/detail_notification_list"
|
||||||
|
@ -19,7 +18,9 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:layout_marginTop="10dp"
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
app:layoutManager="LinearLayoutManager"/>
|
app:layoutManager="LinearLayoutManager"/>
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout 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:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
>
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -134,7 +136,6 @@
|
||||||
android:text="@string/main_banner_json_stream_button_dismiss"
|
android:text="@string/main_banner_json_stream_button_dismiss"
|
||||||
tools:layout_editor_absoluteX="260dp" tools:layout_editor_absoluteY="83dp"/>
|
tools:layout_editor_absoluteX="260dp" tools:layout_editor_absoluteY="83dp"/>
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/main_banner_json_stream_learn_mode"
|
android:id="@+id/main_banner_json_stream_learn_mode"
|
||||||
style="@style/Widget.MaterialComponents.Button.TextButton"
|
style="@style/Widget.MaterialComponents.Button.TextButton"
|
||||||
|
@ -149,7 +150,6 @@
|
||||||
android:id="@+id/main_subscriptions_list_container"
|
android:id="@+id/main_subscriptions_list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
@ -158,6 +158,9 @@
|
||||||
android:id="@+id/main_subscriptions_list"
|
android:id="@+id/main_subscriptions_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:paddingTop="5dp"
|
||||||
|
android:paddingBottom="5dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
|
|
@ -1,14 +1,32 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.cardview.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:id="@+id/detail_item_card"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:padding="3dp"
|
||||||
|
android:paddingBottom="3dp"
|
||||||
|
app:cardBackgroundColor="@color/white"
|
||||||
|
app:cardCornerRadius="3dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:cardMaxElevation="2dp"
|
||||||
|
app:cardPreventCornerOverlap="true"
|
||||||
|
app:cardUseCompatPadding="true">
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal" android:clickable="true"
|
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
>
|
android:paddingBottom="5dp">
|
||||||
|
|
||||||
<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"
|
||||||
|
@ -124,5 +142,5 @@
|
||||||
android:layout_height="5dp" android:id="@+id/detail_item_padding_bottom"
|
android:layout_height="5dp" android:id="@+id/detail_item_padding_bottom"
|
||||||
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"/>
|
app:layout_constraintTop_toBottomOf="@id/detail_item_attachment_file_box"/>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
|
@ -1,12 +1,33 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.cardview.widget.CardView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/main_item_card"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginEnd="6dp"
|
||||||
|
android:layout_marginBottom="0dp"
|
||||||
|
android:padding="0dp"
|
||||||
|
app:cardBackgroundColor="@color/white"
|
||||||
|
app:cardCornerRadius="3dp"
|
||||||
|
app:cardElevation="2dp"
|
||||||
|
app:cardMaxElevation="2dp"
|
||||||
|
app:cardPreventCornerOverlap="true"
|
||||||
|
app:cardUseCompatPadding="true">
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingEnd="15dp"
|
||||||
|
android:paddingStart="15dp"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal" android:clickable="true"
|
android:focusable="true"
|
||||||
android:focusable="true" android:paddingEnd="15dp"
|
android:paddingBottom="3dp">
|
||||||
android:paddingStart="15dp">
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="35dp"
|
android:layout_width="35dp"
|
||||||
android:layout_height="35dp" app:srcCompat="@drawable/ic_sms_gray_24dp"
|
android:layout_height="35dp" app:srcCompat="@drawable/ic_sms_gray_24dp"
|
||||||
|
@ -71,5 +92,5 @@
|
||||||
app:layout_constraintEnd_toEndOf="@+id/main_item_date"
|
app:layout_constraintEnd_toEndOf="@+id/main_item_date"
|
||||||
app:layout_constraintStart_toEndOf="@+id/main_item_instant_image"
|
app:layout_constraintStart_toEndOf="@+id/main_item_instant_image"
|
||||||
android:textSize="10sp" android:textStyle="bold"/>
|
android:textSize="10sp" android:textStyle="bold"/>
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||||
<item name="colorPrimary">@color/teal</item>
|
<item name="colorPrimary">@color/teal</item>
|
||||||
<item name="colorAccent">@color/teal</item> <!-- checkboxes, text fields -->
|
<item name="colorAccent">@color/teal</item> <!-- checkboxes, text fields -->
|
||||||
<item name="android:colorBackground">@color/white</item> <!-- background -->
|
<item name="android:colorBackground">@color/gray_light</item> <!-- background -->
|
||||||
<item name="android:statusBarColor">@color/teal</item>
|
<item name="android:statusBarColor">@color/teal</item>
|
||||||
<item name="actionModeBackground">@color/teal_dark</item>
|
<item name="actionModeBackground">@color/teal_dark</item>
|
||||||
|
<item name="android:popupMenuStyle">@style/PopupMenu</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Danger buttons & text -->
|
<!-- Danger buttons & text -->
|
||||||
|
@ -24,4 +25,8 @@
|
||||||
<item name="cornerFamily">rounded</item>
|
<item name="cornerFamily">rounded</item>
|
||||||
<item name="cornerSize">5dp</item>
|
<item name="cornerSize">5dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="PopupMenu" parent="@style/Widget.Material3.PopupMenu">
|
||||||
|
<item name="android:popupBackground">@color/white</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Reference in a new issue