Android bubbles recreates the chat bubbles as implemented by Facebook. It focuses on smooth animations for a smiliar user experience, and extremely easy implementation.
(Higher quality version can be found here)
You can start using Android Bubbles in 3 simple steps.
First, add Android Bubbles to your project dependencies.
Make sure you have jcenter as one of your repositories...
repositories {
...
jcenter()
}
...and add Android Bubbles to your dependencies.
dependencies {
...
compile 'com.rodrigopontes:android-bubbles:0.1.0'
}
Create a BubblesManager using a Context.
public class MainActivity extends Activity {
BubblesManager bubblesManager;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
bubblesManager = BubblesManager.create(this);
}
}
After you create it, you can also retrieve it with
bubblesManager = BubblesManager.getManager();
Add a bubble to BubblesManager
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.my_image);
Bubble bubble = new Bubble(imageView);
bubblesManager.addBubble(bubble);
You now have your first Android Bubble!
You can handle Bubble taps just as you would with a Button.
bubble.setBubbleOnTapListener(new BubbleOnTapListener {
@Override
public void onTap(Bubble.BubblePosition bubblePosition) {
Log.d("Bubbles", "Hello World!");
}
}
The Bubble's position can be retrieved from
bubblePosition.x
bubblePosition.y
You can also implement
public void onTapConfirmed(Bubble.BubblePosition)
public void onDoubleTap(Bubble.BubblePosition)
You can remove Bubbles programatically with
bubblesManager.removeBubble(bubble);
You can save a few lines of code by using Bubble's convenience contructors.
new Bubble(imageBitmap);
new Bubble(drawable);
new Bubble(resourceId);
new Bubble(imageUri);
You can customize the size of the Bubble by using
bubble.setImageViewSize(width, height);
To avoid problems with activity recreations, you can wrap your BubblesManager creation with
if(BubblesManager.exists()) {
bubblesManager = BubblesManager.getManager();
} else {
bubblesManager = BubblesManeger.create(this);
}
Screen rotations must be handled by the Activity that implements BubblesManager. That is made simple with
bubblesManager.updateConfiguration();
You can easily customize Android Bubble's feel by tweaking the fields in BubblesProperties.
Implemented Android Bubbles for your project? Send it to [email protected] and I'll share it here!
Copyright 2016 Rodrigo Pontes
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.