Skip to content

Commit

Permalink
fix: Use const for actions height
Browse files Browse the repository at this point in the history
  • Loading branch information
axel358 committed Oct 29, 2024
1 parent 9a0da8c commit a6686bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NotificationAdapter(
) : RecyclerView.Adapter<NotificationAdapter.ViewHolder>() {
private var sharedPreferences: SharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context)

private val actionsHeight = Utils.dpToPx(context, 20)

interface OnNotificationClickListener {
fun onNotificationClicked(notification: StatusBarNotification, item: View)
Expand All @@ -51,7 +51,7 @@ class NotificationAdapter(
if (actions != null) {
val actionLayoutParams = LinearLayout.LayoutParams(
0,
Utils.dpToPx(context, 20)
actionsHeight
)
actionLayoutParams.weight = 1f
if (AppUtils.isMediaNotification(notification)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ class NotificationService : NotificationListenerService(), OnNotificationClickLi
private var margins = 0
private var dockHeight: Int = 0
private lateinit var notificationLayoutParams: WindowManager.LayoutParams
private var actionsHeight = 0
override fun onCreate() {
super.onCreate()
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
preferLastDisplay = sharedPreferences.getBoolean("prefer_last_display", false)
context = DeviceUtils.getDisplayContext(this, preferLastDisplay)
actionsHeight = Utils.dpToPx(context, 20)
windowManager = context.getSystemService(WINDOW_SERVICE) as WindowManager
notificationLayoutParams = Utils.makeWindowParams(
Utils.dpToPx(context, 300), LinearLayout.LayoutParams.WRAP_CONTENT, context,
Expand Down Expand Up @@ -194,7 +196,7 @@ class NotificationService : NotificationListenerService(), OnNotificationClickLi
val actions = notification.actions
notificationActionsLayout.removeAllViews()
if (actions != null) {
val actionLayoutParams = LinearLayout.LayoutParams(0, Utils.dpToPx(context, 20))
val actionLayoutParams = LinearLayout.LayoutParams(0, actionsHeight)
actionLayoutParams.weight = 1f
if (AppUtils.isMediaNotification(notification)) {
for (action in actions) {
Expand Down

0 comments on commit a6686bf

Please sign in to comment.