An Android library that allows to show floating contextual menu like Google

Related tags

Chat & Messaging fcm
Overview

Screenshots

screen1 screen2 screen3 screen4


Sample

get_it

Sample source can be found here


Description

floating-contextual-menu is an Android library for creating floating contextual menus


Usage

Include fcm in your build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:24.2.1'

    ...
    
    compile 'org.bitbucket.stefanodp91:fcm:0.1.2' // add this
}

Create the menu:

FloatingContextualMenu floatingContextualMenu = 
      new FloatingContextualMenu.Builder(getApplicationContext())
                        .add(new FloatingContextualItem.Builder("Reply", onReplyClickListener)
                                .icon(R.drawable.ic_reply_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Copy", onCopyClickListener)
                                .icon(R.drawable.ic_content_copy_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Forward", onForwardClickListener)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Select all", onSelectAllClickListener)
                                .visible(false)
                                .build())
                        .add(new FloatingContextualItem.Builder("Translate", onTranslateClickListener)
                                .visible(true)
                                .build())
                        .anchor(mAnchorView) // set the view to be anchored
      .build();

Show it:

...
floatingContextualMenu.show();

FloatingContextualMenu.Builder customization

It can set the number of visible items when menu is collapsed

 new FloatingContextualMenu.Builder(getApplicationContext())
                        .add(new FloatingContextualItem.Builder("Reply", onReplyClickListener)
                                .icon(R.drawable.ic_reply_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Copy", onCopyClickListener)
                                .icon(R.drawable.ic_content_copy_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Forward", onForwardClickListener)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Select all", onSelectAllClickListener)
                                .visible(false)
                                .build())
                        .add(new FloatingContextualItem.Builder("Translate", onTranslateClickListener)
                                .visible(true)
                                .build())
                        .children(3) // number of visible items when the menu is collapsed
      .build();

Use:

  1. Type.TEXT to show only text
  2. Type.ICON to show only icons
  3. Type.BOTH to show both text and icons
 new FloatingContextualMenu.Builder(getApplicationContext())
                        .add(new FloatingContextualItem.Builder("Reply", onReplyClickListener)
                                .icon(R.drawable.ic_reply_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Copy", onCopyClickListener)
                                .icon(R.drawable.ic_content_copy_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Forward", onForwardClickListener)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Select all", onSelectAllClickListener)
                                .visible(false)
                                .build())
                        .add(new FloatingContextualItem.Builder("Translate", onTranslateClickListener)
                                .visible(true)
                                .build())
                        .children(3)
                        .type(Type.TEXT) // show text only
      .build();

It can choose the less / more icon's color:

 new FloatingContextualMenu.Builder(getApplicationContext())
                        .add(new FloatingContextualItem.Builder("Reply", onReplyClickListener)
                                .icon(R.drawable.ic_reply_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Copy", onCopyClickListener)
                                .icon(R.drawable.ic_content_copy_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Forward", onForwardClickListener)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Select all", onSelectAllClickListener)
                                .visible(false)
                                .build())
                        .add(new FloatingContextualItem.Builder("Translate", onTranslateClickListener)
                                .visible(true)
                                .build())
                        .children(3)
                        .type(Type.TEXT)
                        .moreColor(R.color.grey_500) // change the more / less icon color
      .build();

and the menu's background color

 new FloatingContextualMenu.Builder(getApplicationContext())
                        .add(new FloatingContextualItem.Builder("Reply", onReplyClickListener)
                                .icon(R.drawable.ic_reply_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Copy", onCopyClickListener)
                                .icon(R.drawable.ic_content_copy_white_24dp)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Forward", onForwardClickListener)
                                .visible(true)
                                .build())
                        .add(new FloatingContextualItem.Builder("Select all", onSelectAllClickListener)
                                .visible(false)
                                .build())
                        .add(new FloatingContextualItem.Builder("Translate", onTranslateClickListener)
                                .visible(true)
                                .build())
                        .children(3)
                        .type(Type.TEXT)
                        .moreColor(R.color.grey_500) 
                        .backgroundColor(R.color.white) // background color
      .build();

FloatingContextualItem.Builder customization

mItemTitle and mItemClickListener are mandatory

FloatingContextualItem mFloatingContextualItem = 
      new FloatingContextualItem.Builder(mItemTitle, mItemClickListener)
      .build()

mItemClickListener is a View.OnClickListener().

In the OnClickListener() remember to dismiss the floatingContextualMenu

private View.OnClickListener mItemClickListener = new View.OnClickListener() {
      @Override
      public void onClick(View v) {
          Toast.makeText(getApplicationContext(), "mItemClickListener pressed", Toast.LENGTH_SHORT).show();
          floatingContextualMenu.dismiss();
      }
  };

You can set your own icon drawable:

new FloatingContextualItem.Builder(mItemTitle, mItemClickListener)
      .icon(R.drawable.ic_reply_white_24dp) // set the icon drawable
      .build()

and the item visibility:

new FloatingContextualItem.Builder(mItemTitle, mItemClickListener)
      .icon(R.drawable.ic_reply_white_24dp)
      .visible(true) // set the item visibility
      .build()

you can choose a color for the title

new FloatingContextualItem.Builder(mItemTitle, mItemClickListener)
      .icon(R.drawable.ic_reply_white_24dp)
      .visible(true) 
      .textColor(R.color.black) // title color
      .build()

and for the icon

new FloatingContextualItem.Builder(mItemTitle, mItemClickListener)
      .icon(R.drawable.ic_reply_white_24dp)
      .visible(true) 
      .textColor(R.color.black) 
      .iconColor(R.color.black)  // icon color
      .build()

Credits

Author: Stefano de Pascalis

Google+ LinkedIn


License

Copyright 2016 stefanodp91.

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.
You might also like...
Email-based instant messaging for Android.
Email-based instant messaging for Android.

Delta Chat Android Client This is the Android client for Delta Chat. It is available on F-Droid and the Google Play Store. The APK can also be downloa

A glossy Matrix collaboration client for Android.
A glossy Matrix collaboration client for Android.

Element Android Element Android is an Android Matrix Client provided by Element. It is a total rewrite of Riot-Android with a new user experience. Nig

The most beautiful SMS messenger for Android
The most beautiful SMS messenger for Android

QKSMS QKSMS is an open source replacement to the stock messaging app on Android. It is currently available on the Google Play Store and on F-Droid Rep

Unofficial, FOSS-friendly fork of the original Telegram client for Android

or 1McafEgMvqAVujNLtcJumZHxp2UfaNByqs Telegram-FOSS Telegram is a messaging app with a focus on speed and security. It’s superfast, simple and free. T

Official Android client for the Kontalk messaging system

This is the official Android client for the Kontalk messaging system. It always implements the latest protocol.

Open Source Messenger App For Android - Real-time Messaging, Voice and Video Calls

Open Source Messenger App For Android - Real-time Messaging, Voice and Video Calls

Sample Android App for WebRTC with Firebase as backend
Sample Android App for WebRTC with Firebase as backend

Simple Demo App for Android WebRTC video call using Firebase Realtime Database as Signalling server.

A hybrid chat android application based on the features of Instagram and Whatsapp having UI just as Telegram.
A hybrid chat android application based on the features of Instagram and Whatsapp having UI just as Telegram.

A hybrid chat android application based on the features of Instagram and Whatsapp having UI just as Telegram.

A private-chat-only Android App for Secure Scuttlebutt
A private-chat-only Android App for Secure Scuttlebutt

Tremola README Tremola is a Secure Scuttlebutt (SSB) client for Android that only supports private chat. Tremola aims at having the same functionality

Owner
stefanodp91
stefanodp91
SayHi! is an instant messaging app that allows users to send text messages to other people using the app

SayHi SayHi! is an instant messaging app that allows users to send text messages to other people using the app ?? Screen Shots ?? Features OTP Verific

Prince Fahad 0 Dec 25, 2021
Multi Lingual Chat app - A modern chat application that allows users to translate text messages into their preferred language

Multi Lingual Chat app - A modern chat application that allows users to translate text messages into their preferred language

Manjunath Nayak 0 Jan 18, 2022
This app includes Implementation of Huawei and Google Kits in a single codebase using Build Variants. 🗺 📩

Build Variant App ?? ?? ?? Build variant is a feature of Android Studio to create a project which can be build in different versions. By using Build V

Halil Özel 13 May 26, 2022
Chat with anyone you like through the power of chatcom.

Chat with anyone you like through the power of chatcom. This app provides End-To-End Encryption so that the word doesn't leak out.

Puranjay Savar Mattas 1 Jan 25, 2022
A simple library for creating animated warnings/dialogs/alerts for Android.

Noty A simple library for creating animated warnings/notifications for Android. Examples Show me code Show me code Show me code Show me code Show me c

Emre 144 Nov 29, 2022
An Android library for simple notification displayed inside ViewGroup instead of system.

SimpleNotificationBar SimpleNotificationBar is an Android library that helps developers to easily create a Notification inside a view group, instead o

Tristan Le 2 Jul 29, 2022
Android Real Time Chat & Messaging SDK

Android Chat SDK Overview Applozic brings real-time engagement with chat, video, and voice to your web, mobile, and conversational apps. We power emer

Applozic 659 May 14, 2022
Kommunicate.io Android Chat SDK for Customer Support

Kommunicate Android Chat SDK for Customer Support An Open Source Android Live Chat SDK for Customer Support Overview Kommunicate provides open source

Kommunicate 68 Jan 3, 2023
Android has a built in microphone through which you can capture audio and store it , or play it in your phone. There are many ways to do that but with this dialog you can do all thats with only one dialog.

# Media Recorder Dialog ![](https://img.shields.io/badge/Platform-Android-brightgreen.svg) ![](https://img.shields.io/badge/Android-CustomView-blue.sv

Abdullah Alhazmy 73 Nov 29, 2022
Conversations is an open source XMPP/Jabber client for Android

Conversations Conversations: the very last word in instant messaging Design principles Be as beautiful and easy to use as possible without sacrificing

Daniel Gultsch 4.2k Dec 30, 2022