Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
/ frog Public archive

Frog is a library that can handle notifications for Android with compatibility on different devices.

Notifications You must be signed in to change notification settings

jjrodcast/frog

Repository files navigation

Frog

Frog is a library that can handle notifications for Android with compatibility on different devices.

frog-logo

Download

For now just download the project

How do I use Frog?

To create a notification using Frog you have to do the next:

You can use other configuration methods that the library provides you.

Frog Simple Notification:

FrogNotification.get()
  .init(FrogChannel("channelId", "channelName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
  .contentTitle("Simple Notification")
  .contentText("This is a content for the simple notification")
  .smallIcon(R.drawable.frog)
  .showWhen(true)
  .build()

Frog BigText Notification:

FrogNotification.get()
  .init(FrogChannel("channelExpandId", "channelExpandName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
  .smallIcon(R.drawable.frog)
  .contentTitle("Expandable big text notification")
  .contentText("This is a content for the expandable notification")
  .largeIcon(R.drawable.frog)
  .style(FrogBigTextStyle("This is a content for the expandable notification. Lorem ipsum dolor..."))
  .build()

Frog BigPicture Notification

 FrogNotification.get()
  .init(FrogChannel("channelExpandId", "channelExpandName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
  .smallIcon(R.drawable.frog)
  .contentTitle("Expandable big picture notification")
  .contentText("Image of my frog")
  .largeIcon(R.drawable.frog)
  .style(FrogBigPictureStyle(bitmap).enableThumbnail())
  .build()

Frog Inbox Notification:

  FrogNotification.get()
    .init(FrogChannel("channelExpandId", "channelExpandName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
    .smallIcon(R.drawable.frog)
    .contentTitle("3 New mails from OneCode")
    .contentText("Important mails")
    .largeIcon(R.drawable.frog)
    .style(FrogInboxStyle().addLines(messages))
    .build()

Frog Messaging Notification:

// 1. Create a FrogPerson
val person = FrogPerson(name = "OneCode", isImportant = true)
// 2. Create the messages
val messages = createMessages()
// 3. Create the notification with FrogMessagingStyle
FrogNotification.get()
  .init(FrogChannel("channelExpandId", "channelExpandName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
  .smallIcon(R.drawable.frog)
  .largeIcon(R.drawable.frog)
  .style(FrogMessagingStyle(person)
         .conversationTitle("Conversation title")
         .isGroupConversation(true).addMessages(messages))
  .build()

Frog with Activity Navigation:

//1. Metadata for the notification
val bundle = Bundle()
bundle.putString("name", "OneCode-Frog")
bundle.putInt("version", 1)
bundle.putBoolean("fromNotification", true)
//2. Create the notification with click method
FrogNotification.get()
  .init(FrogChannel("channelId", "channelName", NotificationManagerCompat.IMPORTANCE_DEFAULT))
  .contentTitle("Open Activity Notification")
  .contentText("Click to open other activity")
  .smallIcon(R.drawable.frog)
  .autoCancel(true)
  .click(TargetActivity::class.java, bundle)
  .showWhen(true)
  .build()

Frog using Groups Notification:

// 1. Group Name
val groupKey = "groupkey"
// 2. Create the channel
val channel = FrogChannel("channelGroupId", "channelGroupName", NotificationManagerCompat.IMPORTANCE_DEFAULT)
// 2. Create the independent notification (set a different id that's why we use System.currentTimeMillis())
FrogNotification.get()
  .init(channel)
  .id(System.currentTimeMillis().toInt())
  .smallIcon(R.drawable.frog)
  .contentTitle("Noti1: Content Title")
  .contentText("Noti1: Content Text information")
  .alertOnce(true)
  .group(groupKey)
  .build()

FrogNotification.get()
  .init(channel)
  .id(System.currentTimeMillis().toInt())
  .smallIcon(R.drawable.frog)
  .contentTitle("Noti2: Content Title")
  .contentText("Noti2: Content Text information")
  .alertOnce(true)
  .group(groupKey)
  .build()

// 3. Create the notification with initGroup (use the same id  or the notification will be updated)
FrogNotification.get()
  .initGroup(channel, groupKey)
  .id(100)
  .contentTitle("Title for group messages")
  .contentText("Content of messages")
  .alertOnce(true)
  .smallIcon(R.drawable.frog)
  .largeIcon(R.drawable.frog)
  .style(FrogInboxStyle()
         .addLines(arrayListOf("Person 1 sent new message", "Person 2 sent new message"))
         .bigContentTitle("Group big content title")
         .summaryText("Group summary text"))
  .build()

Author

Jorge Rodríguez Castillo - @jjrodcast on GitHub, @jjrodcast on Twitter

Licences

Copyright 2019 OneCode. All rights reserved.

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.

About

Frog is a library that can handle notifications for Android with compatibility on different devices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published