Skip to content

Commit

Permalink
add triggerClickablePerimeterPx API, upgrade version, README
Browse files Browse the repository at this point in the history
  • Loading branch information
dofire committed Mar 27, 2024
1 parent 4f9286d commit 244eb81
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class BubbleBuilder(

internal var distanceToClosePx = 200
internal var closeBubbleBottomPaddingPx = 80
internal var triggerClickableAreaPx = 5f
internal var triggerClickablePerimeterPx = 5f

internal var listener: FloatingBubbleListener? = null
internal var behavior: CloseBubbleBehavior = CloseBubbleBehavior.FIXED_CLOSE_BUBBLE
Expand Down Expand Up @@ -74,6 +74,21 @@ class BubbleBuilder(

}

/**
* Set the clickable perimeter of the bubble in pixels (default = 5f).
*
* For example, when the bubble is dragged, it will still perform a click if
* the new location (when the bubble is released) is not further than the last location by the specified pixel amount.
*
* @param f The size of the clickable area in pixels.
* @return This BubbleBuilder instance for method chaining.
*/
@Discouraged("the name will be changed if I found a better one")
fun triggerClickablePerimeterPx(f: Float): BubbleBuilder{
this.triggerClickablePerimeterPx = f
return this
}

fun bubbleDraggable(b: Boolean): BubbleBuilder{
isBubbleDraggable = b
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ abstract class ExpandableBubbleService : FloatingBubbleService() {
forceDragging = bubbleBuilder.forceDragging,
containCompose = bubbleBuilder.bubbleCompose != null,
listener = bubbleBuilder.listener,
triggerClickableAreaPx = bubbleBuilder.triggerClickableAreaPx
triggerClickableAreaPx = bubbleBuilder.triggerClickablePerimeterPx
)
if (bubbleBuilder.bubbleView != null) {
bubble!!.rootGroup.addView(bubbleBuilder.bubbleView)
Expand All @@ -63,7 +63,7 @@ abstract class ExpandableBubbleService : FloatingBubbleService() {
bubbleBuilder.isAnimateToEdgeEnabled,
closeBehavior = bubbleBuilder.behavior,
isCloseBubbleEnabled = true,
triggerClickableAreaPx = bubbleBuilder.triggerClickableAreaPx
triggerClickableAreaPx = bubbleBuilder.triggerClickablePerimeterPx
)
bubble!!.layoutParams = bubbleBuilder.defaultLayoutParams()
bubble!!.isDraggable = bubbleBuilder.isBubbleDraggable
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ An Android library that creates floating bubbles on top of the screen 🎨, supp

<div align="center">

<h6> Find this library useful? 🥰 Don't forget to show some love by giving a &nbsp; -Star⭐- </h6>
<h6> Like this project? 🥰 Don't forget to show some love by giving a Star⭐ </h6>

| Bubble | Custom |
| :-: | :-: |
Expand Down Expand Up @@ -249,6 +249,7 @@ public class MyServiceJava extends ExpandableBubbleService {
.closeBubbleView(ViewHelper.fromDrawable(this, R.drawable.ic_close_bubble))
.closeBubbleStyle(R.style.default_close_bubble_style)
.distanceToClose(100)
.triggerClickablePerimeterPx(5f)
.closeBehavior(CloseBubbleBehavior.FIXED_CLOSE_BUBBLE)
.startLocation(100, 100)
.enableAnimateToEdge(true)
Expand Down Expand Up @@ -347,6 +348,9 @@ class MyServiceKt : ExpandableBubbleService() {
override fun onFingerDown(x: Float, y: Float) {} // ..., when finger tap the bubble
})

// set the clickable perimeter of the bubble in pixels (default = 5f)
.triggerClickablePerimeterPx(5f)

}

override fun configExpandedBubble(): ExpandedBubbleBuilder? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class MyServiceKt : ExpandableBubbleService() {
// set bubble view
.bubbleView(imgView)

.triggerClickablePerimeterPx(5f)

// or our sweetie, Jetpack Compose
// .bubbleCompose {
// BubbleCompose(expand = { expand() })
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ RELEASE_SIGNING_ENABLED=true

GROUP=io.github.torrydo
POM_ARTIFACT_ID=floating-bubble-view
VERSION_NAME=0.6.4
#prev: 0.6.3
VERSION_NAME=0.6.5
#prev: 0.6.4

POM_NAME=FloatingBubbleView
POM_PACKAGING=aar
Expand Down

0 comments on commit 244eb81

Please sign in to comment.