Skip to content

Commit a70e970

Browse files
committed
fix(clipboard): don't dim the list on long press, shape the popup like the cards
1 parent e8e2f3d commit a70e970

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardAdapter.kt‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
package helium314.keyboard.keyboard.clipboard
44

55
import android.annotation.SuppressLint
6+
import android.content.res.Resources
67
import android.graphics.Typeface
78
import android.util.TypedValue
89
import android.view.LayoutInflater
@@ -236,8 +237,7 @@ class ClipboardAdapter(
236237

237238
private fun createCardBackground(view: View): Drawable {
238239
val colors = Settings.getValues().mColors
239-
val radiusDp = Settings.getValues().mKeyBorderRadius.takeIf { it >= 0f } ?: 8f
240-
val radiusPx = radiusDp * view.resources.displayMetrics.density
240+
val radiusPx = clipboardCornerRadiusPx(view.resources)
241241
val cardBg = colors.get(ColorType.POPUP_KEYS_BACKGROUND)
242242
val mainBg = colors.get(ColorType.MAIN_BACKGROUND)
243243
val isDark = isDarkColor(mainBg) || isDarkColor(cardBg)
@@ -318,8 +318,7 @@ class ClipboardAdapter(
318318
selectedOverlay?.background = GradientDrawable().apply {
319319
val colors = Settings.getValues().mColors
320320
val accentColor = colors.get(ColorType.ACTION_KEY_BACKGROUND)
321-
val radiusDp = Settings.getValues().mKeyBorderRadius.takeIf { it >= 0f } ?: 8f
322-
val radiusPx = radiusDp * view.resources.displayMetrics.density
321+
val radiusPx = clipboardCornerRadiusPx(view.resources)
323322
shape = GradientDrawable.RECTANGLE
324323
cornerRadius = radiusPx
325324
setColor(ColorUtils.setAlphaComponent(accentColor, 0x26))
@@ -448,3 +447,7 @@ class ClipboardAdapter(
448447
}
449448
}
450449
}
450+
451+
/** Corner radius shared by the clipboard cards and their popup, following the key corner radius setting. */
452+
internal fun clipboardCornerRadiusPx(resources: Resources): Float =
453+
(Settings.getValues().mKeyBorderRadius.takeIf { it >= 0f } ?: 8f) * resources.displayMetrics.density

‎app/src/main/java/helium314/keyboard/keyboard/clipboard/ClipboardHistoryView.kt‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,13 @@ class ClipboardHistoryView @JvmOverloads constructor(
885885
?.setInterpolator(android.view.animation.AccelerateInterpolator())
886886
?.withEndAction {
887887
overlay.visibility = View.GONE
888-
overlay.background = null
889888
pill.alpha = 1f
890889
pill.scaleX = 1f
891890
pill.scaleY = 1f
892891
}
893892
?.start()
894893
} else {
895894
overlay.visibility = View.GONE
896-
overlay.background = null
897895
}
898896
return true
899897
}
@@ -934,18 +932,17 @@ class ClipboardHistoryView @JvmOverloads constructor(
934932
Color.WHITE
935933
}
936934

937-
val pillRadius = 24.dpToPx(resources).toFloat()
938935
val pillDrawable = GradientDrawable().apply {
939936
shape = GradientDrawable.RECTANGLE
940-
cornerRadius = pillRadius
937+
cornerRadius = clipboardCornerRadiusPx(resources)
941938
setColor(pillFillColor)
939+
// the list behind is not dimmed, and shadows barely show on dark themes
940+
setStroke(1.dpToPx(resources), ColorUtils.setAlphaComponent(colors.get(ColorType.KEY_ICON), 0x40))
942941
}
943942
pill.background = pillDrawable
944943
pill.clipToOutline = true
945944
pill.elevation = 8.dpToPx(resources).toFloat()
946945

947-
overlay.setBackgroundColor(if (isDark) 0x44000000.toInt() else 0x22000000)
948-
949946
// Configure Pin button
950947
val pinIconRes = if (pinIconId != 0) pinIconId else R.drawable.ic_clipboard_pin_rounded
951948
pinBtn.setImageResource(pinIconRes)

0 commit comments

Comments
 (0)