How dofire/floating-bubble-view works
Main Components
• Library Module (FloatingBubbleView):
• Contains the core code for the floating bubble functionality.
• Organized into packages such as:
○ Main functionality (e.g., AndroidVersions.kt, AnimHelper.kt, XMath.kt)
○ Bubble components under “bubble” (Bubble, FloatingBubble, FloatingCloseBubble, etc.)
○ Service layer under “service” (including ExpandableBubbleService, FullScreenBubbleService) along with sub-packages like “expandable” (BubbleBuilder, ExpandedBubbleBuilder) and “fullscreen”
○ Helper classes (NotificationHelper, ViewHelper)
○ Supporting utilities (ComposeLifecycleOwner, etc.)
• Resources (animations, drawables, layouts, values) used for the bubble’s appearance and animations.
• Sample App Module (“app”):
• Demonstrates the integration and usage of the library.
• Contains example activities, manifest definitions, and Java/Kotlin sample code.
• Helps in visualizing how the floating bubble service is started, how bubbles are expanded/minimized, and how notifications are integrated.
• External Factors:
• Android OS: Manages system-level aspects like foreground services and special permissions (e.g., SYSTEM_ALERT_WINDOW, FOREGROUND_SERVICE, POST_NOTIFICATIONS for Android 13+).
• Gradle Build System: Used for compiling the project and managing dependencies.
Relationships and Interactions
• User Interaction:
• The user interacts with the floating bubble on the screen.
• When the user taps the bubble, an event listener (FloatingBubbleListener) triggers actions such as “expand” to show an expanded bubble view.
• Service Interaction:
• The core logic is encapsulated in the service (ExpandableBubbleService/FloatingBubbleService) that manages showing, collapsing, and animating the bubble.
• The service is responsible for starting in the foreground and managing notifications (handled by NotificationHelper).
• Builder Pattern:
• The library makes use of builder classes (BubbleBuilder and ExpandedBubbleBuilder) to allow flexible configuration of both the bubble view and its expanded variant.
• UI Integration:
• The library supports both traditional XML and Jetpack Compose approaches for defining bubble UIs.
Important Architectural Patterns and Technologies
• Modular Architecture:
• Separation between the library (FloatingBubbleView) and the sample application (app) to demonstrate usage.
• Builder Pattern:
• Utilized for configuring the bubble view and the expanded bubble. This provides a clear and extendable API for developers.
• Service-Oriented Design:
• The bubble functionality is delivered through an Android foreground service to handle life-cycle events, notifications, and user interactions reliably.
• UI Flexibility:
• Dual support for XML layouts and Jetpack Compose enables modern UI development alongside legacy methods.
• Integration with Android's Foreground Services and Permission Model:
• Clear reliance on Android OS permissions and service management for rendering UI elements on top of other apps.