Siddharth2010 Bubbles Save Abandoned

⚡️A library for adding messenger style floating bubbles to any android application 📲

Project README

License: MIT Download Build Status

Bubbles

Bubbles is an Android library to provide a backwards compatible Android Q (API 29) Bubble Experience for all android devices (API 16+).

Screenshots:

App Permissions The Bubble Bubble Tapped Just Before Delete
App Permissions The Bubble Bubble Tapped Just Before Delete

Package Structure of the Library

Package Structure

Usage

Setup

Gradle

Add the JitPack repository to your build file

    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

Add the dependency

    dependencies {
        implementation 'com.github.siddharth2010:Bubbles:v1.0.0'
    }

Maven

Add the JitPack repository to your build file

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add the dependency

	<dependency>
	    <groupId>com.github.siddharth2010</groupId>
	    <artifactId>Bubbles</artifactId>
	    <version>v1.0.0</version>
	</dependency>

Interface

Let's start with a simple setup for the Service

public class FloatingService extends FloatingBubbleService {
    ...
}

Adding your library in the manifest

<service android:name="<YOUR_PACKAGE>.FloatingService" />

Start the service

startService(new Intent(context, FloatingService.class));

Customising the Service

public class FloatingService extends FloatingBubbleService {

  @Override
  protected FloatingBubbleConfig getConfig() {
    return new FloatingBubbleConfig.Builder()
        // Set the drawable for the bubble
        .bubbleIcon(bubbleDrawable)

        // Set the drawable for the remove bubble
        .removeBubbleIcon(removeIconDrawable)

        // Set the size of the bubble in dp
        .bubbleIconDp(64)

        // Set the size of the remove bubble in dp
        .removeBubbleIconDp(64)

        // Set the padding of the view from the boundary
        .paddingDp(4)

        // Set the radius of the border of the expandable view
        .borderRadiusDp(4)

        // Does the bubble attract towards the walls
        .physicsEnabled(true)

        // The color of background of the layout
        .expandableColor(Color.WHITE)

        // The color of the triangular layout
        .triangleColor(Color.WHITE)

        // Horizontal gravity of the bubble when expanded
        .gravity(Gravity.END)

        // The view which is visible in the expanded view
        .expandableView(yourViewAfterClick)

        // Set the alpha value for the remove bubble icon
        .removeBubbleAlpha(0.75f)
        
        // Enable and disable the bubble movement on touch
        .moveBubbleOnTouch(true)
        
        // Set the time for a touch event
        .touchClickTime(250)
        
        // Set the notification circle background color
        .notificationBackgroundColor(Color.RED)
        
        // Set the start value for the notification counter
        .notificationCounter(0)
        
        // Activates a expansion icon in the bubble
        .bubbleExpansionIcon(expansionIconDrawable)

        // Building
        .build();
  }
}

Override the onGetIntent function. It will return true if the intent is valid, else false

  @Override
  protected boolean onGetIntent(@NonNull Intent intent) {
    // your logic to get information from the intent
    return true;
  }

You can change the state of the expanded view at runtime by

// To expand
setState(true);

// To compress
setState(false);

You can change the notification counter at runtime by

// To increase
increaseNotificationCounterBy(1);

// To decrease
decreaseNotificationCounterBy(1);

You can change the bubble icon at runtime by

// To update the icon
updateBubbleIcon(drawableResource);

// To restore to the default build bubble icon
restoreBubbleIcon();

If you activate the expansion icon, you can config the expansion at runtime by

// To show
setExpansionVisibility(true)

// To hide
setExpansionVisibility(false)

// To toggle
toggleExpansionVisibility()

// To set a listener in the icon
setExpansionListener(onClickListener)

Acknowledgements

Thanks to @Tobaloidee for the awesome logo!

Open Source Agenda is not affiliated with "Siddharth2010 Bubbles" Project. README Source: 0xsiddharthks/Bubbles
Stars
94
Open Issues
4
Last Commit
1 year ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating