Android Library/SDK


Index

Advanced UI

Catapush SDK comes with a native ready-to-go solution to display your messages.

Catapush RecyclerView Adapter

Catapush SDK provides full support for RecyclerView via CatapushRecyclerViewAdapter. This adapter can receive a list of messages and display them in a stylish bubble cell:

 
adapter = new CatapushRecyclerViewAdapter();
recyclerView.setAdapter(adapter);
Catapush.getInstance().getMessagesAsList(new Callback<List<CatapushMessage>>() {
@Override
public void success(List<CatapushMessage> catapushMessages) {
adapter.set(catapushMessages);
}

@Override
public void failure(Throwable throwable) {
Log.e("MyApp", throwable.getMessage());
}
});

Toast on copy to clipboard

Catapush gives you the opportunity to copy a message content to the clipboard using long click. Every time you copy a message, a Toast message appears. You can disable this toast message with:

adapter.setClipboardToast(false);

Messages containing urls

Catapush gives you the opportunity to send messages containing URLs, like these

  • www.google.com
  • http://www.google.com
  • google.com

A message containg an URL is clickable and default web browser will take care of opening the URL. You can disable this behavior with:

adapter.setUrlInPlainMessagesClickable(false)

Customization

Colors

Catapush provides a default color scheme that you can override to achieve the user experience you want. To customize the color scheme, you will need to create these colors in your res/values/colors.xml:

<color name="catapush_message_list_item_bg">#b6e6ed</color>
<color name="catapush_message_border_color">#b6e6ed</color>

<color name="catapush_message_title_color">#ff0000</color>
<color name="catapush_message_subtitle_color">#999292</color>
<color name="catapush_message_datetime_color">#ff9d9d9d</color>

Changing these colors, you will change the previous image into this:

Text

Catapush provides a default text style that you can override to achieve the user experience you want. To customize the text, you will need to create these styles in your res/values/styles.xml

<style name="catapush_message_title" parent="android:Widget.TextView">
  <item name="android:singleLine">false</item>
  <item name="android:textColor">@color/catapush_message_title_color</item>
  <item name="android:textSize">@dimen/catapush_message_title_size</item>
  <item name="android:typeface">sans</item>
  <item name="android:textStyle">normal</item>
</style>

<style name="catapush_message_subtitle" parent="android:Widget.TextView">
  <item name="android:textColor">@color/catapush_message_subtitle_color</item>
  <item name="android:textSize">@dimen/catapush_message_list_item_subtitle_size</item>
  <item name="android:textStyle">bold</item>
  <item name="android:typeface">sans</item>
</style>

<style name="catapush_message_datetime" parent="android:Widget.TextView">
  <item name="android:textColor">@color/catapush_message_datetime_color</item>
  <item name="android:textSize">@dimen/catapush_message_list_item_datetime_size</item>
  <item name="android:textStyle">italic</item>
  <item name="android:typeface">sans</item>
</style>

These styles relay on colors and dimensions. You can override Catapush default dimensions adding these values to your res/values/dimens.xml file:

<dimen name="catapush_message_title_size">22sp</dimen>
<dimen name="catapush_message_list_item_padding">5dp</dimen>
<dimen name="catapush_message_list_item_subtitle_size">12sp</dimen>
<dimen name="catapush_message_list_item_datetime_size">6sp</dimen>

Changing these dimensions like this will produce this result:


Corners

Catapush message bubbles come with rounded corners. You can change them overriding this property in your res/values/dimens.xml file:

<dimen name="catapush_message_corner_radius">10dp</dimen>

If you don't want rounded corners at all, simply set it to 0dp.

 

Notification icon

By default, Catapush shows your notification icon with a grey background. During the setup time, this color can be customized:

Notification notification = Notification.builder()
.swipeToDismissEnabled(false) .title(view.getString(R.string.app_name)) .vibrationEnabled(true) .vibrationPattern(new long[]{100, 200, 100, 300}) .soundEnabled(true) .soundResourceUri(sound) .circleColor(circleColor) .ledEnabled(true) .ledColor(Color.BLUE) .ledOnMS(2000) .ledOffMS(1000) .build()

The previous snippet shows a typical configiration of Catapush notification. The highlighted line shows how to customize the icon background color. circleColor can be any ARBG int value, for example:

int circleColor = ContextCompat.getColor(context, R.color.accent)

Sending messages

Catapush provides the possibility to let your users sent you messages. Just add a SendFieldView to your layout, like this:

<com.catapush.library.SendFieldView
    android:id="@+id/send_container"
    android:layout_width="match_parent"
    android:layout_height="60dp"/>

SentFieldView_example.png

SendFieldView colors can be customized like this:

<color name="catapush_sentfield_border_color">YOUR COLOR</color>
<color name="catapush_sentfield_bg_color">YOUR COLOR</color>

FAQ

Which is the minimum supported Android API?

Catapush supports Android API 16 (Jelly Bean) and greater. For details about Android versions distribution, you can check Android Dashboards.

What's the size of the library?

Catapush is less than 400KB and we try to keep the methods count as smallest as possible, too.

What are battery and bandwidth usages?

Catapush works hard to be a good citizen. In a test environment, with new messages received hourly, Catapush has proved to use less than 1% of battery and less than 100KB/day. In everyday scenarios, with low or zero message traffic, Catapush uses even less battery and the data traffic is near to 0KB/day.

There is an example project available?

You can download an example project here.