• Stars
    star
    370
  • Rank 114,758 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Chat heads library for android

THIS PROJECT IS NO MORE MAINTAINED. A good alternative is at https://github.com/google/hover

Springy heads

A chat head library for use within your apps. This includes all the UI physics and spring animations which drive multi user chat behaviour and toggling between maximized, minimized and circular arrangements.

Demo

springy chat heads demo

You can also download the demo app

Get it on Google Play

Installation

Gradle:

compile 'com.flipkart.springyheads:library:0.9.6'

How to use

Define the view group in your layout file

<com.flipkart.chatheads.ui.ChatHeadContainer
android:id="@+id/chat_head_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>  

Then define the view adapter in your activity

final ChatHeadContainer chatContainer = (ChatHeadContainer) findViewById(R.id.chat_container);
chatContainer.setViewAdapter(new ChatHeadViewAdapter() {
    @Override
    public FragmentManager getFragmentManager() {
        return getSupportFragmentManager();
    }

    @Override
    public Fragment attachView(Object key, ChatHead chatHead) {
        // return the fragment which should be shown when the arrangment switches to maximized (on clicking a chat head)
        // you can use the key parameter to get back the object you passed in the addChatHead method.
        // this key should be used to decide which fragment to show.
        return new Fragment();
    }

    @Override
    public Drawable getChatHeadDrawable(Object key) {
        // this is where you return a drawable for the chat head itself based on the key. Typically you return a circular shape
        // you may want to checkout circular image library https://github.com/flipkart-incubator/circular-image
        return getResources().getDrawable(R.drawable.circular_view);
    }
});

Then add the chat heads

chatContainer.addChatHead("head0", false); // you can even pass a custom object instead of "head0"
chatContainer.addChatHead("head1", true); // a sticky chat head (passed as 'true') cannot be closed and will remain when all other chat heads are closed.

And finally set the arrangement

chatContainer.setArrangement(MinimizedArrangement.class, null);

The view adapter is invoked when someone selects a chat head. In this example a String object ("head0") is attached to each chat head. You can instead attach any custom object, for e.g a Conversation object to denote each chat head. This object will represent a chat head uniquely and will be passed back in all callbacks.

Toggle arrangements

You can toggle between the Minimized and Maximized arrangement like this

chatContainer.setArrangement(MinimizedArrangement.class, null);
            
/** OR **/
             
chatContainer.setArrangement(MaximizedArrangement.class, null);

Callbacks

chatContainer.setListener(new ChatHeadListener() {
    @Override
    public void onChatHeadAdded(Object key) {
        //called whenever a new chat head with the specified 'key' has been added
    }

    @Override
    public void onChatHeadRemoved(Object key, boolean userTriggered) {
        //called whenever a new chat head with the specified 'key' has been removed.
        // userTriggered: 'true' says whether the user removed the chat head, 'false' says that the code triggered it
    }

    @Override
    public void onChatHeadArrangementChanged(ChatHeadArrangement oldArrangement, ChatHeadArrangement newArrangement) {
        //called whenever the chat head arrangement changed. For e.g minimized to maximized or vice versa.
    }

    @Override
    public void onChatHeadAnimateStart(ChatHead chatHead) {
        //called when the chat head has started moving (
    }

    @Override
    public void onChatHeadAnimateEnd(ChatHead chatHead) {
        //called when the chat head has settled after moving
    }
});

In normal scenarios you dont need to know when a chat head is selected because the fragment returned by the view adapter is automatically attached to it. For special cases where you need to perform any external action, you can use item selected listener.

chatContainer.setOnItemSelectedListener(new ChatHeadContainer.OnItemSelectedListener() {
    @Override
    public boolean onChatHeadSelected(Object key, ChatHead chatHead) {
        if (chatContainer.getArrangementType() == MaximizedArrangement.class) {
            Log.d("springyheads","Clicked on " + key + " " +
                    "when arrangement was Maximized");
        }
        return false; //returning true will mean that you have handled the behaviour and the default behaviour will be skipped
    }
});

Configuration

You can override the standard sizes by writing a custom class which extends the default config class. For e.g., the below class defines some standard properties and also the initial position of the chat head.

public class CustomChatHeadConfig extends ChatHeadDefaultConfig {
    public CustomChatHeadConfig(Context context, int xPosition, int yPosition) {
        super(context);
        setHeadHorizontalSpacing(ChatHeadUtils.dpToPx(context, -2));
        setHeadVerticalSpacing(ChatHeadUtils.dpToPx(context, 2));
        setHeadWidth(ChatHeadUtils.dpToPx(context, 50));
        setHeadHeight(ChatHeadUtils.dpToPx(context, 50));
        setInitialPosition(new Point(xPosition, yPosition));
        setCloseButtonHeight(ChatHeadUtils.dpToPx(context, 50));
        setCloseButtonWidth(ChatHeadUtils.dpToPx(context, 50));
        setCloseButtonBottomMargin(ChatHeadUtils.dpToPx(context, 100));
        setCircularRingWidth(ChatHeadUtils.dpToPx(context, 53));
        setCircularRingHeight(ChatHeadUtils.dpToPx(context, 53));
    }

    @Override
    public int getMaxChatHeads(int maxWidth, int maxHeight) {
        return (int) Math.floor(maxWidth / (getHeadWidth() + getHeadHorizontalSpacing(maxWidth, maxHeight))) - 1;
    }
}

Once this config class is defined, you can set it to the manager

chatContainer.setConfig(new CustomChatHeadConfig(this, 0, 100);

Setting badge count

Do check out our library circular-image (https://github.com/flipkart-incubator/circular-image) for generating a circular drawable containing upto 4 smaller bitmaps as well as a badge count.

License

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.

More info

You can find a working example in MainActivity of demo module included in the source. If you want to add a feature or fix a bug, please issue a pull request. This implementation of chat heads is meant to be used within the activity context and cannot be used inside a service.

More Repositories

1

Astra

Automated Security Testing For REST API's
Python
2,484
star
2

proteus

Proteus : A JSON based LayoutInflater for Android
Java
1,302
star
3

zjsonpatch

This is an implementation of RFC 6902 JSON Patch written in Java
Java
522
star
4

watchdog

Watchdog - A Comprehensive Security Scanning and a Vulnerability Management Tool.
Python
410
star
5

RTA

Red team Arsenal - An intelligent scanner to detect security vulnerabilities in company's layer 7 assets.
Python
409
star
6

android-inline-youtube-view

Utility library around using YouTube inside your android app.
Java
323
star
7

fk-visual-search

Flipkart's visual search and recommendation system
Python
172
star
8

Lois

Golang like channels for java
Java
108
star
9

flux

Highly scalable Event-driven, Reactive system for building Stateful apps and Workflow services.
Java
107
star
10

optimus

Train, evaluate and deploy Deep Learning based text classifiers. Currently supports CNN
Python
105
star
11

okhttp-stats

OkHttp Analytical library to get stats like average network speed. Also get global callbacks for network errors and successes. Can be used for logging errors to Fabric or Firebase analytical tools
Java
95
star
12

phrontend

A Framework to build rich UIs
JavaScript
88
star
13

ContentSheet

A simple control that enables presenting any view controller or navigation controller or any other object that can provide a view like an ActionSheet
Swift
82
star
14

hbase-orm

A production-grade HBase ORM library that makes accessing HBase clean, fast and fun (Can also be used as Bigtable ORM)
Java
78
star
15

madman-android

Madman (Media ads manager) is a high performance alternative to Google's standard IMA android SDK. If you have your own VAST server and want to render video ads and have full control over the UI, then this library is for you.
Kotlin
69
star
16

dkv

Distributed KV data store with tunable consistency, synchronous replication
Go
62
star
17

fk-ios-chatheads

Objective-C
58
star
18

batchman

This library for Android will take any set of events and batch them up before sending it to the server. It also supports persisting the events on disk so that no event gets lost because of an app crash. Typically used for developing any in-house analytics sdk where you have to make a single api call to push events to the server but you want to optimize the calls so that the api call happens only once per x events, or say once per x minutes. It also supports exponential backoff in case of network failures
Java
55
star
19

priority-kafka-client

Library to support priority queuing in Kafka
Java
54
star
20

animation-wrapper-view

Declarative animations with imperative controls for RN/RNW.
TypeScript
52
star
21

phantom

Phantom is a high performance proxy for accessing distributed services. It is an RPC system with support for different transports and protocols. Phantom is inspired by Twitter Finagle clients and builds on the capabilities of technologies like Netty, Unix Domain Sockets, Netflix Hystrix and Spring. Phantom proxies have been used to serve several hundred million API calls in production deployments at Flipkart.
Java
49
star
22

spark-transformers

Spark-Transformers: Library for exporting Apache Spark MLLIB models to use them in any Java application with no other dependencies.
Java
40
star
23

kafka-filtering

Very fast & efficient grep for Kafka stream
Java
38
star
24

databuilderframework

A data driven execution engine
Java
33
star
25

circular-image

Creates circular image drawable.
Java
30
star
26

android-studio-proteus-plugin

Plugin for Android studio which helps you to convert XML resources to JSON which can be used by proteus.
Java
29
star
27

storm-mysql

Storm Spout that reads off MySql Bin Logs
Java
29
star
28

ranger

Feature rich service discovery on ZooKeeper
Java
27
star
29

android-video-player

Kotlin
26
star
30

varadhi

Java
24
star
31

Poseidon

Platform to build API applications that have to aggregate data from distributed services in an efficient way.
Java
21
star
32

ios-inline-youtube-view

Utility library around using YouTube inside your iOS app.
Objective-C
20
star
33

grpc-jexpress

Developer friendly container for writing gRPC services using grpc-java
Java
17
star
34

hbase-k8s-operator

Hbase operator for kubernetes
Go
15
star
35

diligent

Run performance experiments on MySQL compatible databases
Go
15
star
36

StockPile

Provides in-memory and database based caching
Objective-C
14
star
37

Hunch

Hunch allows users to turn arbitrary machine learning models built using Python into a scalable, hosted service.
Python
14
star
38

scroll-coordinator-ios

ScrollCoordinator allows you to attach gestures to scrollviews and perform behaviours like Hiding the navigation bar, hiding the bottom bar and anchoring your scroll on these gestures.
Swift
13
star
39

gojira

Gojira is a record and replay framework for Java apps meant for regression testing. It provides complete recording capability within a single request-response scope, by recording request, response and any external interactions(outside of the jvm), thereby circumventing the need to provide a mock service.
Java
12
star
40

kubric

Android's co-ordinator layout ported to work on react native (Android, iOS and on the web)
TypeScript
11
star
41

babel-plugin-pseudolocalize-react-native

Babel plugin to transform React Native Text nodes with a custom language map for Pseudo-localization
JavaScript
11
star
42

pulsar-weighted-consumer

Pulsar consumer clients offering priority consumption
Java
10
star
43

phrontend-webpack

A webpack config maker for phrontend apps
JavaScript
10
star
44

kafka-balancer

Balance partitions among brokers with minimal data movement. Supports re-replication of under replicated partitions and setting replication as well.
Java
9
star
45

hbase-compactor

Trigger major compaction in Hbase
Java
9
star
46

BlueShift

Hadoop Data Mover Project
Java
8
star
47

android-RDX

Redux for Android.
Java
8
star
48

lenna

Go
8
star
49

Krystal

Java
7
star
50

Lyrics

Java
7
star
51

Iris-BufferQueue

A fast, in-process, persisted queue for buffering data on local host.
Java
7
star
52

hbase-sep

HBase side-effect-processor to stream changes from WAL to kafka sink.
Java
6
star
53

Cuppa

Caffe as a service and KNN as a service
Python
5
star
54

chronosq

⏱ A Scalable Distributed Scheduler
Java
5
star
55

hydra

A JVM based DispatcherComposer Engine
Java
5
star
56

mongodb-replicator

Mongodb Replicator java library for both sharded & non-sharded mongo setup.
Java
4
star
57

CTDrive

A tool which uses Google drive APIs internally and allows users to easily navigate through their files. This tool allows to maintain all organisation documents at one place similar to Confluence
TypeScript
4
star
58

polyglot

Tiered data store for use by on-line applications
Java
4
star
59

nexus

Sync replication using RAFT consensus onto pluggable backends
Go
4
star
60

dropwizard-one

Dropwizard One is a wrapper around Dropwizard that enables writing web services with minimal boilerplate code and good testability.
Java
4
star
61

Service-Worker-Tools

HTML
4
star
62

dropwizard-multitenancy

Java
4
star
63

bifrost

A remote execution framework over RabbitMQ.
Java
3
star
64

vbroker

high throughput PUSH based messaging
Java
3
star
65

wolverine

Master elected daemon, which heals itself
Java
3
star
66

prognos

Scala
3
star
67

truss

Javascript Framework
JavaScript
3
star
68

Lego

Library to build any entity (web/api response) in a scatter-gather fashion
Java
3
star
69

protobuf-util

Utility library for protobuf
Java
3
star
70

simpleJobScheduler

Java
3
star
71

ultra-docs

Documentation for Project Ultra : Flipkart's App-in-App experience
3
star
72

dsp

Java
2
star
73

tef

Java
2
star
74

molecule

ML platform with seamless experiment tracking and sharing. Supports multiple languages and platforms, meta-learning constructs and MLOps.
CSS
2
star
75

rediscast

Rediscast is an In-memory data grid, that synchronizes Entity changes in Redis server with all cluster nodes (JVM instances) within a short SLA. It uses Redis Streams for change data propagation.
Java
2
star
76

polyguice

A set of useful extensions to Google Guice and better integration with popular frameworks for creation of highly concurrent micro-services.
Java
2
star
77

portkey

Portkey is a Java model abstraction of persistence that works across multiple data stores and supports sharding. Entities can be persisted to more than one data store based on a set of rules.
Java
2
star
78

Swagger-publish

Java
2
star
79

ottoscalr

Ottoscalr provides a drop-in component for autonomous management of HPAs
Go
2
star
80

Regnator

Rule based decision engine. RESTful service where one could define the facts/variables and configures rules for the evaluation on the facts/variables and eventually choose one of the configured decision/result.
1
star
81

CoreDataLite

Lightweight core data library for iOS
Objective-C
1
star
82

statreduce

A library which to write Hadoop MapReduce jobs with map step in Java and reduce step in R for statistical computations
Java
1
star
83

homebrew-taps

Ruby
1
star
84

light-house

JavaScript
1
star
85

jupyterlab-extensions

Jupyterlab extensions
TypeScript
1
star
86

continuum

Lambda Architecture is not enough! Continuum is more fundamental
1
star
87

storm-sidelining

Java
1
star
88

turbo-relayer

Java
1
star
89

foxtrot-client

A service discovery client for foxtrot.
Java
1
star