use the correct paddings for status info and follow notifications (#4958)

On my device the status info was just slighty misaligned, so I
investigated. Turns out the dp values were correct, but the
`Utils.dpToPx` method calculates with the exact density of the device,
whereas everything else uses the density buckets Android defines. And on
some devices that makes a visible difference. Did a little refactor and
now everything should always be aligned correctly.

And in `item_follow` the padding was just different from other
notification items.
This commit is contained in:
Konrad Pozniak 2025-02-28 10:20:17 +01:00 committed by GitHub
commit ba4f57ecaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 10 deletions

View file

@ -18,7 +18,6 @@
package com.keylesspalace.tusky.components.notifications
import android.view.View
import at.connyduck.sparkbutton.helpers.Utils
import com.keylesspalace.tusky.R
import com.keylesspalace.tusky.adapter.StatusViewHolder
import com.keylesspalace.tusky.entity.Notification
@ -57,16 +56,16 @@ internal class StatusViewHolder(
if (payloads.isNotEmpty()) {
return
}
val res = itemView.resources
if (viewData.type == Notification.Type.Poll) {
statusInfo.setText(if (accountId == viewData.account.id) R.string.poll_ended_created else R.string.poll_ended_voted)
statusInfo.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_poll_24dp, 0, 0, 0)
statusInfo.setCompoundDrawablePadding(Utils.dpToPx(statusInfo.context, 10))
statusInfo.setPaddingRelative(Utils.dpToPx(statusInfo.context, 28), 0, 0, 0)
statusInfo.setCompoundDrawablePadding(res.getDimensionPixelSize(R.dimen.status_info_drawable_padding_large))
statusInfo.setPadding(res.getDimensionPixelSize(R.dimen.status_info_padding_large), 0, 0, 0)
statusInfo.show()
} else if (viewData.type == Notification.Type.Mention) {
statusInfo.setCompoundDrawablePadding(Utils.dpToPx(statusInfo.context, 6))
statusInfo.setPaddingRelative(Utils.dpToPx(statusInfo.context, 38), 0, 0, 0)
statusInfo.setCompoundDrawablePadding(res.getDimensionPixelSize(R.dimen.status_info_drawable_padding_small))
statusInfo.setPaddingRelative(res.getDimensionPixelSize(R.dimen.status_info_padding_small), 0, 0, 0)
statusInfo.show()
if (viewData.statusViewData.status.inReplyToAccountId == accountId) {
statusInfo.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.ic_reply_18dp, 0, 0, 0)