fixes binwiederhier/ntfy#235
This commit is contained in:
parent
d3806ea347
commit
8cb852a2cb
3 changed files with 18 additions and 8 deletions
|
@ -14,10 +14,18 @@ class Colors {
|
||||||
return if (isDarkThemeOn(context)) R.color.black_800b else R.color.gray_400
|
return if (isDarkThemeOn(context)) R.color.black_800b else R.color.gray_400
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun cardBackground(context: Context): Int {
|
||||||
|
return if (isDarkThemeOn(context)) R.color.black_800b else R.color.white
|
||||||
|
}
|
||||||
|
|
||||||
fun cardSelectedBackground(context: Context): Int {
|
fun cardSelectedBackground(context: Context): Int {
|
||||||
return if (isDarkThemeOn(context)) R.color.black_700b else R.color.gray_500
|
return if (isDarkThemeOn(context)) R.color.black_700b else R.color.gray_500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun cardBackgroundColor(context: Context): Int {
|
||||||
|
return ContextCompat.getColor(context, cardBackground(context))
|
||||||
|
}
|
||||||
|
|
||||||
fun cardSelectedBackgroundColor(context: Context): Int {
|
fun cardSelectedBackgroundColor(context: Context): Int {
|
||||||
return ContextCompat.getColor(context, cardSelectedBackground(context))
|
return ContextCompat.getColor(context, cardSelectedBackground(context))
|
||||||
}
|
}
|
||||||
|
|
|
@ -636,7 +636,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
finishActionMode()
|
finishActionMode()
|
||||||
} else {
|
} else {
|
||||||
actionMode!!.title = adapter.selected.size.toString()
|
actionMode!!.title = adapter.selected.size.toString()
|
||||||
redrawList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -717,8 +716,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
|
|
||||||
private fun beginActionMode(notification: Notification) {
|
private fun beginActionMode(notification: Notification) {
|
||||||
actionMode = startActionMode(this)
|
actionMode = startActionMode(this)
|
||||||
adapter.selected.add(notification.id)
|
adapter.toggleSelection(notification.id)
|
||||||
redrawList()
|
|
||||||
|
|
||||||
// Fade status bar color
|
// Fade status bar color
|
||||||
val fromColor = ContextCompat.getColor(this, Colors.statusBarNormal(this))
|
val fromColor = ContextCompat.getColor(this, Colors.statusBarNormal(this))
|
||||||
|
@ -734,7 +732,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
private fun endActionModeAndRedraw() {
|
private fun endActionModeAndRedraw() {
|
||||||
actionMode = null
|
actionMode = null
|
||||||
adapter.selected.clear()
|
adapter.selected.clear()
|
||||||
redrawList()
|
adapter.notifyItemRangeChanged(0, adapter.currentList.size-1)
|
||||||
|
|
||||||
// Fade status bar color
|
// Fade status bar color
|
||||||
val fromColor = ContextCompat.getColor(this, Colors.statusBarActionMode(this))
|
val fromColor = ContextCompat.getColor(this, Colors.statusBarActionMode(this))
|
||||||
|
@ -742,10 +740,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
fadeStatusBarColor(window, fromColor, toColor)
|
fadeStatusBarColor(window, fromColor, toColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun redrawList() {
|
|
||||||
mainList.adapter = adapter // Oh, what a hack ...
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "NtfyDetailActivity"
|
const val TAG = "NtfyDetailActivity"
|
||||||
const val EXTRA_SUBSCRIPTION_ID = "subscriptionId"
|
const val EXTRA_SUBSCRIPTION_ID = "subscriptionId"
|
||||||
|
|
|
@ -58,6 +58,12 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
|
||||||
} else {
|
} else {
|
||||||
selected.add(notificationId)
|
selected.add(notificationId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (selected.size != 0) {
|
||||||
|
val listIds = currentList.map { notification -> notification.id }
|
||||||
|
val notificationPosition = listIds.indexOf(notificationId)
|
||||||
|
notifyItemChanged(notificationPosition)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ViewHolder for Topic, takes in the inflated view and the onClick behavior. */
|
/* ViewHolder for Topic, takes in the inflated view and the onClick behavior. */
|
||||||
|
@ -114,6 +120,8 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
|
||||||
}
|
}
|
||||||
if (selected.contains(notification.id)) {
|
if (selected.contains(notification.id)) {
|
||||||
cardView.setCardBackgroundColor(Colors.cardSelectedBackgroundColor(context))
|
cardView.setCardBackgroundColor(Colors.cardSelectedBackgroundColor(context))
|
||||||
|
} else {
|
||||||
|
cardView.setCardBackgroundColor(Colors.cardBackgroundColor(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
|
||||||
|
|
Loading…
Reference in a new issue